Opcode Caching
Posted in Tech
First dog watch, 2 bells (5:02 pm)

I'm testing out an opcode cacher (xcache, if you're interested) for this site before deploying it to production servers. It should accelerate my PHP scripts, but only time (and you) can tell. Let me know if things are snappier, if you even notice…

Leave a Comment »
Apache and PHP Extensions in Windows
Posted in Tech
Forenoon watch, 6 bells (11:28 am)

I've been fighting an error with my PHP installation in Windows with Apache related to loadable extensions. In my error log, I kept getting the errors:

PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\Program Files\\PHP\\ext\\php_mssql.dll
PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\Program Files\\PHP\\ext\\php_pdo_mssql.dll

Interestingly enough, if I ran PHP through the console, it loaded PDO and mssql just fine, the problem was only with the environment in Apache. Turns out the ntwdblib.dll wasn't being located by Apache. I could probably have added the PHP path to the environment variable PATH, but the easiest solution was to copy the dll to the Windows\System32 directory. A restart of Apache after that cured the problem.

Leave a Comment »
PHP, PDO, and MSSQL in Windows
Posted in Tech
Last dog watch, 1 bell (6:33 pm)

If, like me, you've been using PHP's PDO via the MSSQL driver, be aware that newer versions of PHP do not support MSSQL natively. Microsoft has it's own PHP driver now, or you can use the FreeTDS MSSQL extension, but I strongly recommend just switching to use the provided ODBC and PDO_ODBC extensions and save yourself the trouble. If you're already using PDOs, then you just have to create the object a little differently. For example:

$sql = new PDO("odbc:Driver={SQL Native Client};Server=ip.add.re.ss;Database=dbname;Uid=user;Pwd=password");

That worked for me. Not sure what you can do about the old mssql_guid_string function if you need that, though. I have the FreeTDS lib installed as well and that lets me call it, until I figure out how to do the same thing in ODBC.

Yes, ASP fans, that's a ONE LINE connection to a database. That's all anyone should need!

Leave a Comment »
New Server
Posted in Tech
First dog watch, 3 bells (5:45 pm)

I'm currently building a new server for our colo facility to host streaming video. It's a nice machine, quad-core Xeon processor, 4Gb of RAM, 750Gb of RAID-1. When compiling PHP I kept running in to a problem with the gd library configuration. The shared object files are installed into /usr/lib64 (because it's a 64-bit operating system), but the header files are installed into /usr/include and are not being found.

If you tell the configure script to --enable-gd=/usr it balks about not finding the libgd.(a|so) file. If you rerun configure and use --enable-gd=/usr/lib64 it finds libgd.so, but then doesn't pick up the header files.

Turns out the problem is pretty simple to solve: add --with-libdir=lib64 to the configure script and it will fix everything. It's just not obvious when reading the configure help, especially when you come from a primarily 32-bit background.

Leave a Comment »
Certification Test
Last dog watch, 1 bell (6:59 pm)

Well, I didn't pass the test I mentioned before. It wasn't for lack of knowledge of how to program, or even much syntax. Several of the questions asked for free-form entry of INI file fields that did certain things. Other questions asked how the engine deals with things like switch statements when the default case is not the last case in the code block and what happens to cases after that. Several questions also concerned the nth argument of some arbitrary function, or required intimate knowledge of lesser-known array functions.

What a bunch of crap. I can write great code anyway. I don't have to memorize API functions and INI settings I don't use, and when I need to use array functions I'll look up the argument order. I don't need to know how the engine processes things when you feed it bad code—I refactor bad code when I see it so I don't run it.


Crash Course
Posted in Tech
First watch, 4 bells (10:22 pm)

Today I went through the crash course on Zend Certification by Christian Wenz. I met him before at an ApacheCon in either 2000 or 2001, I don't remember. He's a great speaker, and although the course was riddled with information, I think he did a good job going over everything he could in the 6 or so hours he had.

Tomorrow at 10am I go to take my certification test. The trick questions worry me, but I don't think I'll have too much trouble passing—I have been using PHP since version 3. I have a lot of C and C++ experience to call on, I just have to pay attention and not miss any of the small, tricky details.

It's interesting how much PHP has evolved in the last few years. Today we talked about object oriented design patterns, something you just couldn't really implement even in PHP v4.

Leave a Comment »