Never try to change anything using WordPress.com
A few weeks ago I learned of a cool little statistics package that you can install on your WordPress blog that does a really good job of managing your stats. So I installed it here on this blog to see what people are searching for, reading and generally interested in and tied it an API key from WordPress.com account that I have used for my Akismet (anti-spam) plugin.
A few days later I realized that the WordPress.com account I have been using for Akismet was tied to my old business profile name, Everah, and not my newer, more open identity of RobertGonzalez. So I decided to change the API key I am using for Akismet and Stats to the API key for my personal account rather than my business account. And that, my friends, is wherein my biggest pain in the butt for the last two weeks has resided.
It started with the fact that there is really not a clear set of instructions for changing your Stats API key. Unlike Akismet, where you can go to Plugins -> Akistmet Configuration from inside your admin panel and change your API key, Stats requires that you deactivate it as a plugin first, then reactivate it then go through all the rigmarole of setting it all back up again. After finding the instructions to do that - thanks to Google and a lot of pissed of WordPress.com Stats users - I deactivated the plugin and reactivated it again, setting it up this time with my personal API key. Which, in my case didn't, seem work.
So after playing around with this forever I decided that it was time to submit a help ticket to the WordPress crew. The context of the ticket was pretty simple, I wanted to swap API keys between my personal and business accounts on their end, which in my opinion, would have been the easiest thing to do. Their support response, looking back on it now, were actually pretty good, except they did not answer my questions and actually led to more questions on top of the ones I had. When you get to the end of it all you will see that their initial suggestion (or second one) is in fact what I ended up doing. But it was a nightmare going through all of this.
The following is the transcript of all of our conversations (skip this and continue on the other side of it):
from: Anthony - WordPress.com
to: robert@robert-gonzalez.com
date: Sat, Feb 7, 2009 at 7:15 AM
subject [WordPress #252013]: General - That I really only need one. But I cannot merge thHi,
You cannot move API keys around. If you wish for us to transfer a blog to a different account, we can do that: http://support.wordpress.com/moving-a-blog/#transferring-your-blog-to-another-user-or-accountBest,
Anthony
Automattic | WordPress.com
from: Robert Gonzalez
to: support@wordpress.com
date: Sat, Feb 7, 2009 at 10:05 AM
subject Re: [WordPress #252013]: General - That I really only need one. But I cannot merge thWhat I really want is to use the API key and history from the "everah" account only have it under the "robertgonzalez" account. My self hosted blog has a pretty decent Akismet history from the API key associated with the everah account and I just installed the stats plugin. I really want to not have my self hosted blog associated with the "everah" account at all and would prefer to have everything run from the "robertgonzalez" API key.
Should I just abandon the history I have with the everah account and start all over with the robertgonzalez account?
from: Anthony - WordPress.com
to: robert@robert-gonzalez.com
date: Sat, Feb 7, 2009 at 10:51 AM
subject [WordPress #252013]: General - That I really only need one. But I cannot merge thHi,
I can add the robertgonzalez account to the self-hosted blog's access list from this end - so that it can access the blog stats. If this is what you would like, please verify the blog URL.Best,
Anthony
Automattic | WordPress.com
from: Robert Gonzalez
to: support@wordpress.com
date: Sat, Feb 7, 2009 at 7:38 PM
subject Re: [WordPress #252013]: General - That I really only need one. But I cannot merge thDoes that mean if I switch the Akismet and WordPress.com Stats API key then the data that has been collected so far would transfer as well? What I really would like is to not lose the Akismet stats I have collected under the everah account. Both everah and robertgonzalez have the same email and same URL for the blog address (http://www.robert-gonzalez.com) which is my self-hosted blog.
from: Nick - WordPress.com
to: robert@robert-gonzalez.com
date: Wed, Feb 11, 2009 at 6:33 AM
subject [WordPress #252013]: General - That I really only need one. But I cannot merge thHi,
The stats aren't stored with the account, they are stored with the blog. So giving another user access doesn't do anything to the stats.
--
Nick
Automattic | WordPress.com
from: Robert Gonzalez
to: support@wordpress.com
date: Wed, Feb 11, 2009 at 7:20 AM
subject Re: [WordPress #252013]: General - That I really only need one. But I cannot merge thI tried that, switching the API key from the everah API key to the robertgonzalez API key and my stat count dropped from thousands down to 8 for akismet. Both accounts have my self hosted blog url registered to it. That is why I thought that switching was going to cause stat trouble.
So if I change the API key then theoretically nothing should change as long as the blog is registered to the account?
Robert
from: Nick - WordPress.com
to: robert@robert-gonzalez.com
date: Wed, Feb 11, 2009 at 7:45 AM
subject [WordPress #252013]: General - That I really only need one. But I cannot merge thCorrect. You mention Akismet, but Akismet isn't blog stats, it's for blocking spam on your blog.
--
Nick
Automattic | WordPress.com
from: Robert Gonzalez
to: support@wordpress.com
date: Wed, Feb 11, 2009 at 8:56 AM
subject Re: [WordPress #252013]: General - That I really only need one. But I cannot merge thRight, by my akismet numbers changed too when I changed the API key which led me to believe that the API key was holding the stats, not the blog URL. Also, when I switched the API keys my stats basically vanished and I was told that I didn't have access to the stats. I am guessing that had something to do with me being logged in to WordPress.com under everah while trying to hook into the robertgonzalez api key.
Really I just want everything to roll into one account: robertgonzalez. But I have history with the everah account that I want to make sure I don't lose. If I need to massage the stats and akismet stuff though I guess I can.
Also, when are the developers of the stats plugin going to offer the ability to change the API key like Akisment does? Right now you either have to change the API key in akismet or, short of that, edit the wordpress_api_key config value to change it for stats.
from: Sheri - WordPress.com
to: robert@robert-gonzalez.com
date: Wed, Feb 11, 2009 at 4:42 PM
subject [WordPress #252013]: General - That I really only need one. But I cannot merge thHi,
Akismet should work the same even if the numbers are different because it's collective. Are you saying that spam is getting blocked differently if you switch the API key?Also note that there is no way to look up Akismet stats on the wordpress.com system, so it really doesn't matter which wordpress.com account you connect Akismet to from our point of view.
--
Sheri
Automattic | WordPress.comhttp://support.wordpress.com/
http://en.forums.wordpress.com/
from: Robert Gonzalez
to: support@wordpress.com
date: Wed, Feb 11, 2009 at 5:03 PM
subject Re: [WordPress #252013]: General - That I really only need one. But I cannot merge thWhat I am saying is right now, under Akismet stats, using the API key from the "everah" account, I see this:
4,396 spams caught, 228 legitimate comments, and an overall accuracy rate of 99.805%.When I change my API key in the akismet admin screen to the API key for the "robertgonzalez" account, that line becomse something like:
8 spams caught, 0 legitimate comments, and an overall accuracy rate of 100.00%.That is why I asked about the API keys. Also, when I switched the API key in akismet, the wordpress.com stats plugin seemed to go haywire. Like it didn't know who I was or something.
I just want to make sure that the few days of stat harvesting and the last few months of akismet data harvesting doesn't get whacked with a single change to the API key.
from: Sheri - WordPress.com
to: robert@robert-gonzalez.com
date: Wed, Feb 11, 2009 at 5:17 PM
subject [WordPress #252013]: General - That I really only need one. But I cannot merge thThe data cannot be transferred between wordpress.com accounts. If you want to keep the same Akismet numbers showing in your blog, then you must use the first API key. If you want to change it, then it should not effect the future accuracy of the spam blocking, you will just see different numbers. It's up to you if you whether to switch it or not.
When you change your API key for Akismet, it should not affect the stats. However, if you switch the API key for stats, make sure to select the "replace an existing blog" option in step 2.
--
Sheri
Automattic | WordPress.comhttp://support.wordpress.com/
http://en.forums.wordpress.com/
from: Robert Gonzalez
to: support@wordpress.com
date: Wed, Feb 11, 2009 at 9:39 PM
subject Re: [WordPress #252013]: General - That I really only need one. But I cannot merge thHow do you unregister a blog from wordpress.com? I just tried switching API keys and I think since http://www.robert-gonzalez.com is registered to my "everah" account I cannot associate it with my "robertgonzalez" account. I keep getting this error when I input my API key:
WordPress.com Stats
Error from last API Key attempt:Missing API Key
The WordPress.com Stats Plugin is not working because it needs to be linked to a WordPress.com account.
Enter your WordPress.com API key to link this blog to your WordPress.com account. Be sure to use your own API key! Using any other key will lock you out of your stats. (Get your key here.)
This is after I enter the API key and hit the "Add new blog" button. What do I do now?
from: Nick - WordPress.com
to: robert@robert-gonzalez.com
date: Thu, Feb 12, 2009 at 6:14 PM
subject [WordPress #252013]: General - That I really only need one. But I cannot merge thIf you log into WordPress.com with the 'everah' account and then visit http://support.wordpress.com/contact/ to send us a request, we can change the owner of the WordPress.com stats for the domain. Make sure to let us know the domain name and the user you want to have access.
--
Nick
Automattic | WordPress.com
from: Robert Gonzalez
to: support@wordpress.com
date: Wed, Feb 18, 2009 at 10:53 AM
subject Re: [WordPress #252013]: General - That I really only need one. But I cannot merge thI can't submit a contact to you using the link below because the only blog attached to that account is my self hosted blog and your ticket system will not accept messages from blogs that are not hosted on your site.
This is a monumental pain in the ass. I really wish you would fix this. Seriously, it shouldn't be this freaking hard to make a simple change.
from: Nick - WordPress.com
to: robert@robert-gonzalez.com
date: Thu, Feb 19, 2009 at 6:44 AM
subject [WordPress #252013]: General - That I really only need one. But I cannot merge thThere may be a bug in our system them. Because it should let you message us about a blog connected to our system through WordPress.com stats. Is the form giving you an error?
--
Nick
Automattic | WordPress.com
from: Robert Gonzalez
to: support@wordpress.com
date: Thu, Feb 19, 2009 at 9:40 AM
subject Re: [WordPress #252013]: General - That I really only need one. But I cannot merge thYes. Here are the steps I took:
1. Log in to WordPress.com using the account "everah".
2. Go to http://support.wordpress.com/contact/
3. Fill out the form and leave the Blog URL field empty
4. SubmitError: Let us know the URL of your blog.
I then select the only Blog URL that is on my account, http://www.robert-gonzalez.com and submit...
Error: We only provide support for WordPress.com blogs here. Please go to the WordPress.org Support Forum for further help.
from: Robert Gonzalez
to: support@wordpress.com
date: Thu, Feb 19, 2009 at 9:45 AM
subject Re: [WordPress #252013]: General - That I really only need one. But I cannot merge thYou know, I was just reading the tips above the form and #3 says:
We only support WordPress blogs hosted here on WordPress.com. If your blog is running the self-hosted version of WordPress, you should seek support elsewhere.So dude, what the hell? Am I stuck in the position I am in?
Ultimately what I needed to do was remove this blog's URL from my business account, where it was primary, and move it to my personal account as the primary blog. But I had to have some way of doing that so I could request it through their system. So I had to get crafty, tricksy if you will, so I could circumvent the stupid trouble ticket form on their web site. Wanna know how I did it?
What I finally ended up doing was creating a new WordPress.com blog under my "everah" username so I could submit a help ticket to the crew. I then logged into that account and sent them a trouble ticket in which I told them to reference this long string of emails that we vollied to one another and asked that they just move this blog's url from one account to the other. Which is what they suggested in the first place.
They did it. And of course, now stats work properly, but Akismet is now down to nothing again, so I ended up going back to API key from my business for that. But at least stats are working. And at least I was able to get this situation mostly resolved. But if there is one thing I would suggest you never do, it is try to change anything on your own blog and then ask for help from the WordPress.com crew to make it happen smoother.
Teaching your child beyond the textbook
The other day I was at my sister's house. While I was there I noticed by niece doing her math homework and as I sat next to her my sister asked me to help her because she was having a hard time with it. As I reviewed the material and looked at the problem it became clear that my niece's struggle with her homework was not because she couldn't do it or because it was too hard. The struggle was that context of the problem was completely irrelevant to her and as such, didn't offer much in the way of motivating her.
So I decided to do to her what I do to my kids: teach her outside the textbook in a real life context that would make sense to her. This isn't a cutting-edge principle by any stretch of the imagination, but it is one in which many parents fail to provide adequately for their children's learning. And please don't take that to mean that parents are failures at teaching. To the contrary, parents that invest time into their children are smashing successes. It's just that often children need more out of their young education than their school or teacher can give them (hence my love for homeschooling).
The problem that my niece was working was pretty simple as it was stated: "A basketball team has won 15 out of 21 games. What percentage of games did they win?" Simple enough, right? But beyond setting up a percentage division equation, where is the thought supposed to come from in this problem? When is the last time you had a problem to solve that was written down on a piece of paper for you?
So after I explained how to set up the necessary equations to determine a percentage from a total and a quantity and I threw a few problems at her. The first was a handful of crayons. There were broken crayons and complete crayons. I asked her to first tell me what the total was. Then I asked her to count how many of the crayons were complete. Then I asked her to tell what percentage of crayons were complete.
We moved on from there to looking at the complete crayons and I asked her to tell me how many of the complete crayons had yellow wrappers and then tell me the percentage of complete crayons that had yellow wrappers. Each time I asked her to set the problem up on paper only after she was able to look at the situation and determine the variables and values for herself.
Then I gave her another problem, a little more relevant to what she does for fun. She is one a swim team. So I told her that there is a swim team that just competed at the championships. The team had 150 swimmers on the team. Of those 150 swimmers 20% were girls under the age of 12. I then asked her how many of the girls on the team were under 12. After that I told her that the coach wanted to surprise the girls under 12 on the team by taking them to a water park to celebrate their season. But the coach found out at the last minute that only kids 8 and over were allowed in the park. I told her that there were 9 girls on the team that under 8 years old that wouldn't be allowed to go. I then asked her to calculate the percentage of girls under 12 that would not be allowed to go to the water park. Then, as a recap, I asked he to tell me the percentage of the swim team those 9 girls represented.
I set up problems like this for my kids all the time. I can, because I am one of their teachers. Very seldom do I take a problem as it was written in a book and hand it to them to solve. I am actually looking for a few things from my kids when I teach them, none of which is available from them calculating numbers on a page.
The first thing I want them to do is understand the nature of the problem they are solving. Setting up a solution to a problem has to start with understanding the problem at hand. If not, well your foundation will suck and will ultimately lead to potentially questionable results.
The next thing I want them to do is think about the simplest way to solve the problem. Complex problems can sometimes be solved by simple means. But looking at something and thinking right away that it is a huge problem and then getting worked up over it can and usually does lead to something going haywire. Thinking about the nature of the problem often presents potential paths to a solution, and sometimes even offers a simple solution.
After figuring the best way to solve the problem I like my kids to setup the way in which they will solve it. This can be the part where they write and equation, or using block put some on one side of a table and some on the other, or using army men or ... you get the point. Whatever path they have chosen to solve the problem needs to then be converted to a solvable schematic.
From there it is just a matter of arithmetic or simple logic. When it comes to math I am really not at all concerned with the correct answer being returned so much as I am with the correct means to a solution being used. Arithmetic is the easier of the things to teach when it comes to math. Logic, not so much.
And such is the case with almost all disciplines of education. Language, history, science... all disciplines have challenges that need to be solved, solutions to those challenges and basics that are used in those solutions. unfortunately schools, textbooks and teachers often have to rely on making things as simple as they can for the bulk of the students being taught and this often results in many students that could learn more or learn faster being restrained and often retarded in their learning.
But if you are a parent you have opportunities every day to test your children, teach your children and train your children. In fact, it isn't so much an opportunity as it is a responsibility. And it is a responsibility that parents must necessarily take seriously given the condition of our public education system.
Wrapping it up
Just for grins I gave this problem to my three older daughters yesterday after watching a cake competition on Food Network. Sarah gave me the answer before I finished telling her the problem. Lets see how well you do:
Say you are making a stacked cake. The bottom layer of the cake is a perfect square in shape with a known side length of L. Now say we are going to put a round cake on top of this layer and we want the round cake to be exactly in the middle of the square cake below it. The round cake will have a diameter, D, that is smaller than the length L of the square cake. How would you determine where on the square cake to place the round cake so that the round cake was exactly in the middle of the square cake?
Ready? Go!
Building the PHP MS SQL Server extension from source on Ubuntu 8.10
Yesterday I wrote about how I got an enhanced Sybase CT extension for PHP built on Ubuntu 8.10 from source files and from Red Hat RPM archives. Today I wanted to write about installing the SQL Server extension from source on Ubuntu 8.10.
I have written about this once before but it was for a Red Hat environment. Seeing as we are converting all of our system at work to Ubuntu I had to do the same thing for the Ubuntu platform. And wouldn't you know it, Debian and Red Hat are vastly different from each other.
Aside from the stupidity that is the Ubuntu package manager's rendition of the SQL Server extension for PHP the fact remained for me that I had to be able to integrate database communication from LAMP to a SQL Server on Windows as well to a Sybase server on Unix. The Sybase bit was taken care of in yesterday's write up. But how do we get PHP to talk to SQL Server on Ubuntu 8.10?
Throw out the notion that you can use the php-sybase package from the package manager. It munges stuff up pretty badly and at the same time does things to the Sybase extension that make it unusable for my needs. Not to mention that if their is a Sybase extension already installed then it really pukes because the php-sybase extension that installs the SQL Server functions actually installs the mssql_* functions then maps the sybase_* functions to them, which makes PHP squawk since those functions are already defined.
So the only way to make this happen is to build the SQL Server extension from source.
Building and installing the mssql extension from source
The follow steps will guide you through how I got the mssql extension built and installed on Ubuntu 8.10:
- Build the FreeTDS library
FreeTDS is a free, open source library of clients that allow Linux machines to talk to SQL servers and Sybase servers. Download the latest stable version of the FreeTDS library (as of this writing it was 0.82) and unpack the source to a directory on your machine. Once the source is unpacked, change to the directory where the source is located and configure and make the library:
$ ./configure --prefix=/usr/local/freetds --enable-msdblib
$ make
$ sudo make installDO NOT MAKE CLEAN AT THIS POINT.
Before you do anything else you must make sure that you have copied over all the necessary files from FreeTDS. "Wait, didn't the installation routine do that?" you might ask. No, it doesn't, because of a change made on the part of the FreeTDS developers. There are two files that are needed in order to build the mssql extension. Those files are among the make files and must be copied over to the freetds install directory.
From inside the source directory of freetds, where you built it from, enter:
$ sudo cp include/tds.h /usr/local/freetds/include
$ sudo cp src/tds/.libs/libtds.a /usr/local/freetds/lib - Get the PHP source code
Change to a directory where you wouldn't mind having the entirety of the PHP source stashed. From the command line type:
$ apt-get source php5 - Copy the mssql extension files to a directory you can build from
My preference is to leave source alone and work from copies. So I always copy the files I need to a different location and build from the copies. To that end, I created a directory at ~/SourceCode/php-mssql and copied the following files from the original PHP source directory:
$ cp ext/mssql/config.m4 ~/SourceCode/php-mssql
$ cp ext/mssql/php_mssql.c ~/SourceCode/php-mssql
$ cp ext/mssql/php_mssql.h ~/SourceCode/php-mssql - Make and install the extension
Make sure you have the php5-dev package installed on your system so that you can build PHP extensions from source. From inside the directory where your mssql extension source code is, at the command line, enter:
$ phpize
$ ./configure --with-mssql=/usr/local/freetds
$ make
$ make installFind out where your extensions directory is on your machine and quickly check it to make sure there is a php_mssql.so file living in it. On my machine the extension directory is /usr/lib/php5/20060613+lfs/. Yours may be different.
- Configure PHP to use the new extension we just made
Now we need to tell PHP to use the new extension we just built. To do that we need to create an ini file for the extension and put it inside of the extensions directory where PHP can find it. On my machine PHP looks for ini files to parse in /etc/php5/conf.d/ so naturally that is where I am going to go to to tell PHP to use this extension.$ cd /etc/php5/conf.d/Now we need to create an ini file and put into a directive to load the extension. You can use whatever editor you like. I prefer to use vim:
$ sudo vim mssql.iniInside this file place the following two lines:
; Enable the mssql extension
extension=mssql.so - Configure your environment to load a much needed environment variable whenever the machine starts
Much like the Sybase extension we did yesterday the mssql extension needs an environment variable in order to function properly. Again, this one caused me fits for a long time in Ubuntu. To be sure you can use the SQL Server extension from both the CLI and the web server you will need to add an environment variable to both the /etc/profile startup script AND the web servers environment variable setting script.$ sudo vim /etc/profileAt the end of the file add:
export FREETDSCONF=/etc/freetds/freetds.confNow add this same entry into your web server’s environment variables. I am using apache and assuming you are to. If not, consult your web server’s documentation for how to do this:
$ sudo vim /etc/apache2/envvarsNow add these entries to the end of the file:
export FREETDSCONF=/etc/freetds/freetds.conf - Configure FreeTDS
In order for FreeTDS to communicate properly with the SQL server a DSN of sorts needs to be created. To make a DSN you need to edit the freetds.conf file:
$ sudo vim /etc/freetds/freetds.confGo to the end of the file and add the following lines (MAKE SURE TO INDENT ALL OF THE CONFIG VALUES FOR THE SERVERNAME):
;--- Custom MSSQL server name ---
; THIS CAN BE ANY NAMED SERVER REFERENCE YOU WANT TO CREATE
[SERVERNAME]
; This is the host name of the MSSQL server
host=HOSTNAME
; This is the port number to use
port=PORTNUMBER
; This is the TDS version to use for anything over Server 2000
tds version=8.0Now we need to add the freetds library to the load library stack.
$ sudo vi /etc/ld.so.confGo to the end of the file and add the following line:
/usr/local/freetds/lib - Restart your web server
Like everything that involves a change to the PHP environment or configuration on your machine, restart the web server. I am assuming this is being built upon an apache server. If not, you will need to know how to stop and start your web server or, at the very least, know how to reboot your machine:
$ sudo apache2ctl stop
$ sudo apache2ctl startRun a PHP info page or CLI call to see if it is loaded:
$ php -mYou should now see mssql.
Again, I hope this was helpful to you. If it was, please leave a comment and let me know. It something went haywire for you, leave me a comment, too. Systems being what they are, it is never unheard of for two almost identical systems to have vastly different experiences with building software from source.
Handling multiple Sybase result sets in PHP on Ubuntu 8.10
A long time ago I was tasked with creating a PHP application that would talk to our Sybase database that drives our entire enterprise at work. This is not normally a big thing to do as one can simply enable the Sybase extension for PHP and have a database connection generally within minutes. However there was one thing that was an absolute necessity in this application that made it significantly more difficult to get it working: some parts of the application would be reliant upon stored procedures that returned multiple result sets.
First off let me say that any time you have the option to build stored procedures for your database quieries, do it. They are faster, safer, compiled and centralized and they keep your code from being littered with query builders all over the place. That said, this is neither the time nor the place to talk about the merits of stored procedures in application development. Just know that where I work there are no direct queries ever allowed to touch our database servers.
Knowing that I had to work under the requirement of handling multiple Sybase result sets I set out to find out how to do it and what I found was alarming. Few database extensions in PHP handle multiple result sets. In fact, as I was looking around it seemed that only the MySQLi extension and the SQL Server extension handled multiple result sets. But after a little searching around I found something called the "PHP Sybase CT driver enhancements" project on Sourceforge that essentially provided prepared statement handling and multiple result set handling for the PHP Sybase Extension. However, after trying to install it it became evident that the extension, as it was written, was still not usable in the state it was offered up for download in.
Not to worry, I have modified the package for compiling within a PHP 5 environment and have made a few changes to it that should allow it to be used as is. The source code archive file can be downloaded (in tar.gz format) by clicking here.
Please read the notes on this source code before installing it!
Before installation
Before we get started we need to cover a few assumptions:
- You have a licensed copy of Sybase Adaptive Server
I have not tried this against any Sybase database server other than Adaptive server. - You have the Sybase client installed or at the very least have the installer available
For this exercise we are using a Red Hat RPM of the Sybase 12.5 client. Yes, we are installing on Ubuntu, which is essentially Debian and therefore does not use RPM files, but we will burn that bridge when we come to it. - You are comfortable building PHP extensions from source
There is no way around this. In order to get this to work you will need to be able to build from source. - You have the php-devel package installed on the machine you building this extension for
If you don't have it, a quicksudo apt-get install php5-devshould do the trick. This will be necessary to build the Sybase extension from source.
Installation instructions
Ok, these are the steps I took in order to build the enhanced Sybase extension for PHP on my Ubuntu 8.10 desktop machine starting with Sybase ASE client and common packages in Red Hat RPM format.
- Convert the Sybase 12.5 OpenClient and Sybase 12.5 Common RPM archives to DEB packages and install them
To do this I used the alien package converter tool and, while inside the directory where the RPMs were living, issued the following command:
$ alien -k sybase-common-12.5.0.1de-1.i386.rpm
$ alien -k sybase-openclient-12.5.0.1esd-1.i386.rpmThis created two new archives, in the directory I was in, in debian format named
- sybase-common-12.5.0.1DE-1_i386.deb
- sybase-openclient-12.5.0.1ESD-1_i386.deb
I then issued the following commands to install them:
$ sudo dpkg --install sybase-common-12.5.0.1DE-1_i386.deb
$ sudo dpkg --install sybase-openclient-12.5.0.1ESD-1_i386.debThis made a directory named sybase-12.5 in the /opt directory.
- Prepare your environment to build the extension
To make things easier (and a little more compatible with the Red Hat way of doing things) I created a link inside of /top called sybase and pointed it to the sybase-12.5 directory.
$ cd /opt
$ ln -s -T /opt/sybase-12.5 sybaseI then had to export some environment vars that are needed by the extension and the web server in order to handle communication with the Sybase server:
$ export SYBASE=/opt/sybase
$ export SYBASE_OCS=OCS-12_5
$ export PATH=/opt/sybase/OCS-12_5/bin:$PATH
$ export LD_LIBRARY_PATH=/opt/sybase/OCS-12_5/lib:/opt/sybase/OCS-12_5/lib3p:$LD_LIBRARY_PATH
$ export INCLUDE=/opt/sybase/OCS-12_5/include:$INCLUDE
$ export LIB=/opt/sybase/OCS-12_5/lib:$LIBYes, I know that each one of these commands could have been placed in a file and sourced, but for some reason source is not available to my installation of Ubuntu so it was in fact easier and faster for me to do it this way. Do this how you will, but remember the values because you will need these later.
- Build and install the php-sybase-ct extension from source against the Sybase client you just installed
Remember that package I told you about earlier? The one that I said you could download? If not, get it now and unpack it to a directory somewhere where you have permission to unpack stuff on your system. For me, it was ~/Temp.Change to the directory you unpacked the source code to and configure it for make and installation using the php-devel package:
$ cd ~/Temp
$ phpize
$ ./configure --with-sybase-ct=$SYBASE/$SYBASE_OCS
$ make
$ sudo make installFind out where your extensions directory is on your machine and quickly check it to make sure there is a php_sybase_ct.so file living in it. On my machine the extension directory is /usr/lib/php5/20060613+lfs/. Yours may be different.
At this point you can safely do a
sudo make cleanbut you might want to hold off on that until it is all working in case you need to rebuild at all. It does happen from time to time. Just sayin'. - Configure PHP to use the new extension
Now we need to tell PHP to use the new extension we just built. To do that we need to create an ini file for the extension and put it inside of the extensions directory where PHP can find it. On my machine PHP looks for ini files to parse in /etc/php5/conf.d/ so naturally that is where I am going to go to to tell PHP to use this extension.$ cd /etc/php5/conf.d/Now we need to create an ini file and put into a directive to load the extension. You can use whatever editor you like. I prefer to use vim:
$ sudo vim sybase_ct.iniInside this file place the following two lines:
; Enable the sybase extension
extension=sybase_ct.so - Configure your environment to load the correct environment variables whenever the machine starts
This one caused me fits for a long time in Ubuntu. In order to ensure that you can use the Sybase extension from both the CLI and the web server you will need to take all of the environment variables that exported prior to building the extension and place them in both the /etc/profile startup script AND the web servers environment variable setting script. This caused countless hours of frustration and anger for me and I hope I can save you some angst with this little snippet.Add the environment vars to /etc/profile. You can use any editor you like. I like vim:
$ sudo vim /etc/profileAt the end of the file add the environment vars:
export SYBASE=/opt/sybase
export SYBASE_OCS=OCS-12_5
export PATH=/opt/sybase/OCS-12_5/bin:$PATH
export LD_LIBRARY_PATH=/opt/sybase/OCS-12_5/lib:/opt/sybase/OCS-12_5/lib3p:$LD_LIBRARY_PATH
export INCLUDE=/opt/sybase/OCS-12_5/include:$INCLUDE
export LIB=/opt/sybase/OCS-12_5/lib:$LIBNow add these same entries into your web server's environment variables. I am using apache and assuming you are to. If not, consult your web server's documentation for how to do this:
$ sudo vim /etc/apache2/envvarsNow add these entries to the end of the file:
export SYBASE=/opt/sybase
export SYBASE_OCS=OCS-12_5
export PATH=/opt/sybase/OCS-12_5/bin:$PATH
export LD_LIBRARY_PATH=/opt/sybase/OCS-12_5/lib:/opt/sybase/OCS-12_5/lib3p:$LD_LIBRARY_PATH
export INCLUDE=/opt/sybase/OCS-12_5/include:$INCLUDE
export LIB=/opt/sybase/OCS-12_5/lib:$LIB - Restart your web server
Like everything that involves a change to the PHP environment or configuration on your machine, restart the web server. I am assuming this is being built upon an apache server. If not, you will need to know how to stop and start your web server or, at the very least, know how to reboot your machine:
$ sudo apache2ctl stop
$ sudo apache2ctl startRun a PHP info page or CLI call to see if it is loaded:
$ php -mYou should see sybase_ct. If not, something went wrong. If so, you are now golden.
At this point you should be able to run queries against your Sybase server AND handle multiple result sets using the sybase_next_result() function. There is no documentation for this function, but a quick read through of the mssql_next_result() function will tell pretty well how to use it.
Enjoy! And if this was at all helpful please leave a comment to let me know.
Notes on the PHP Sybase CT Enhanced extension
Some things to keep in mind when using this extension:
- This extension is coded in PHP 4 source.
- When I got my hands on it the code was still much in development phase. Not much has changed about that other than I removed debug output from it.
- It does not handle connection failure well when the server does not respond. So unwell in fact that internally it causes segmentation faults and results in blank web pages upon failure. I do not know how to fix that.
- If you know how to program in c or want to make it better, please feel free to do so. I have contacted the original authors of this extension and of the three only one has done any real work on it and none have worked on it in the last five years and really do not intend to. I was given permission to distribute it and modify it. But I really do not know what I am doing in c. Yet.
An all day sleep
You ever had one of those really weird days where things go different than you thought they would and leave you wondering what happened at the end of the day? Yeah, I kinda had one of those yesterday. And today, too, actually.
I think this has to do a lot with the way Valentine's day went and the subsequent collapse of said day at the end. Whatever the case, all I know is that my wife was laid up today like she has not been in a long while. She got up to go to church and when she got home she went straight to bed. And stayed there. Pretty much all day.
I am cool with that. It gave me and the kids time to spend together. I was able to handle not only lunch for them but dinner as well. And we were able to play the Wii a lot. But I think I rather missed my wife being part of our family today. About a year and a half ago, when she began what would become a heated year long battle with depression and anxiety, she would spend days on end like this. Up until three or four in the morning then sleep all day long. She would have bouts with physical ailments and conditions. It was a rough time.
And though I believe it is possible to be healed of disease and sickness quickly, historically depression takes a long time to work out. Not to be counted out, Sandi has shown remarkable signs of improvement since this past October and it wasn't until today that there seemed even the most remote chance of it creeping back. I pray that is not the case. I hope Sandi is just not feeling well and needed the rest all day to help her body recover. Whatever the case, I did enjoy my day today with my kids. I kinda wish the weather was better so we could have gone out and done something, but still, just having time with them was pretty rad.
In any event, today being as strange and long as it was, I had a good day. I hope your Sunday was good, too.
Between a father and his son
Last night, when I got home, I was tired. And hungry. And ready to rest. I wanted some quiet time and some relaxation time. Did I get that? No. Am I complaining? No, though it sounds that way. What I got was something better.
As the night wore on I noticed my son was just all over the place. He was loud, getting into stuff, moving things, climbing things, just doing things. He apparently had a bunch of pent up energy that needed exhausting in some capacity. So as he was doing something he probably should not have been doing down the hallway I went to him and asked him "Dude, you want daddy to go thrash you in the bedroom?". You should have seen those three year old eyes light up.
"Yes!" he said as he dropped everything in his arms and ran to my room. I unlocked the door (it is locked specifically because of him) and he ran to my bed laughing his head off. As he was about to make it on to the bed I tackled him, and the fun began. We wrestled, tickled, punched, swung, and punched each other for a food fifteen minutes before he said "Dad, lets play boxing.". How could I resist that?
So we started wailing on each other. Not hard of course, but with enough force to know that we were hitting each other. He was loving every minute of it. Then we started wrestling again. And tickling. And thrashing. And then it happened... he ran into me trying to tackle me and I didn't really notice until he bounced off of my shoulder. Looking down at him I noticed his lip was bleeding so I told him to hang on while I got some tissue for his mouth. His reply? "No dad, I want to keep playing boxing."
I cleaned up his mouth anyway. Then we got to boxing again. And it was just after this that Sandi walked in with cookies and the fund and games stopped right then. It was a blast, but it got better this morning.
AJ decided he wanted to come into my bed this morning as I was waking up. I let him and went to take my shower. As I left the bathroom after finishing my shower I noticed he was under the covers. Then suddenly he threw open the covers trying to scare me. He wanted more.
Now this is where husbanding comes in to play. Men, if you have a wife and she is in bed sleeping when you come out of the shower and your son is in that bed wanting to fight with you while your wife sleeps right next to him, you need to make a decision. The wise decision in this case is to tell your son that you need to wait.
My son didn't understand that. But we squared it up pretty quick and, to make the situation more top his liking, I laid down next to him and we talked. We talked about boxing the night before, about him waking his sisters up, about him wanting breakfast, about his dreams from the previous night, about his toy cars. I then told him how grown up he seemed, having this wonderful conversation with me at just three and a half years old. I also mentioned to him that in a few months, when he turns four, he will be able to start going to the church class room that Alaynah gets to go to, but how that since she will be turning six she will only be with him for about two weeks.
He then told me that he wants to go to her class so he can spin the wheel and play in the bounce house and all of the fun stuff in that room. But immediately after this he told me that he would go back to his three year old class since he would be embarrassed to go to Alaynah's class. It was as we were talking about this that Alaynah came in and our conversation was totally dashed. But it's all good. I had an amazing talk with my son.
And therein lies the moral of this post. Men, if you have a son, or more than one son, take amoment every now and again to have some aggressive, man time with him. He wants that, no matter his age, and he will love it. He will also love that you want to spend any time with him at all and he will totally cherish that moment and remember it. Even if he doesn't let on to it. Let him hold your tools, or wear your safety goggles, or put shaving cream on his face while he watches you shave. Let him be a boy trying to become a man.
My son loves that time. And I, as a recovering young boy myself, really look forward to those moments, too.
American Idol is back, and it’s way different
Last night I watched American Idol as the final TV show contestants were picked. That is one of my favorite parts of the show, seeing people melt in either joy or heartbreak as the judges tell them "Yes" or "No". I can imagine that the highest of the highs, those that get the few yes votes alloted, would be so overfilled with excitement that they breakdown and cry. I mean, it is a yes to getting on to national TV on American Idol. Who wouldn't want that?
And then there are those few that get the nos and appear to have their world shattered because to them American Idol was their life's work and they will never, ever amount to anything ever again. Or perhaps they just give that impression.
In any event, it has always been a fun part of the show for me to watch because the magic number of 24 seemed so perfect with all those people making it to the final round of judgement. But wouldn't you know that in the air of keeping things fresh the producers of American Idol have decided to allow 36 contestants into the TV stage this year? Why would they do this? I mean other than to make the season a tad longer which in turn would generate more ad revenue which in turn would pay the executives higher bonuses?
Anyway, I am cranky about this. I know I cannot do anything about it and that my opinion, in the grand scheme of things, means absolutely crap to anyone. But this here blog is my platform for communication of all things rant, rave and opinion. So you, loyal reader number one of three, get to hear it. Read it. Get a taste of my opinion.
I hope it works out good this year. I really do. It has gotten better just about every year. And this year's talent pool runs pretty deep.