Speaking too Soon

In a previous post, I had spoken of a true solution. Now I will break down the lessons learned because I have never seen a contrast of the draw backs of the various past mssql solutions.

PDO tdslib driver:

This is the installation I recommended last. It was my most recent discovery and fixed all issues I had previously had except for one. Output variables are not to be binded to, and there is no support for multiple result sets, so it can be easy to get the error of all results were not exhausted.

In comparison with the previous driver, these are small fry.

PDO mssql through freetds as odbc driver:

This driver had many problems. Nulls would crash processing, strings above 255 characters would try to allocate 4gb ram, exceptions were not reported. This was the first segment we tackled and we worked around all these failings, but a permanent solution, never.

Solution 3:

A newcomer solution with much experience is now on the scene. Stay tuned for my analysis of its readyness :)

PHP 5.3, MSSQL Server, Centos and You

One day, I found myself needing to use MSSQL Server Procs, using PHP 5.3 in a Linux environment. I soon found out that this was easier said than done as PHP 5.3 had removed built-in MSSQL support from the linux distribution and a proper install guide was far more common for Windows PHP users and PHP 5.2.

My first solution was to use FreeTDS, Linux ODBC and PDO ODBC. Out of a myriad voodoo style solutions, this one seemed the most straight forward. Unfortunately, there were issues. Exceptions never really worked right (caused the PHP module to die), NULL values were essentially unsupported, and if any string took more than 255 characters, PHP would demand 4GB of RAM.

Due to the short deadline of the project, crazed hacks were implemented, but I vowed to solve the issue properly at a later date.

So, after having long since conquered the beast, I present the ultimate guide, cradle to grave.

First step is a proper driver for MSSQL that works in Linux. The best and officially PHP supported is FreeTDS at http://www.freetds.org/

This guide assumes freetds-0.91.

Once you have it:

tar xzf freetds.tar.gz
cd freetds-0.91
./configure --with-tdsver=7.1 --enable-msdblib --with-gnu-ld && make
sudo make install
sudo /sbin/ldconfig

Once installed, you can do a basic connectivity test.

/usr/local/bin/tsql -S host -U username

You will be prompted for password. If you get a prompt, all is well.

Now for PHP, assuming PHP 5.3.8.

./configure line should have whatever your environment needs, but the key addition is the following:

--with-pdo-dblib=/usr/local

The libraries from FreeTDS by default go there in Centos, so that is where PHP needs to look.

Once PHP is all installed, we can do a basic test that things are working with a quick script.

<?php
$dbh= new PDO('dblib:host=hostserverhere;dbname=databasename;appname=MySweetApp', 'username', 'password');
$stmt = $dbh->prepare("SELECT SYSDATETIME()");
$stmt->execute();
while ($row = $stmt->fetch()) {
print_r($row);
}
unset($dbh); unset($stmt);
?>

Run that and if you get output, congrats, you have succeeded.

That should be enough to get you started. Next edition, I share some PDO recipes to help the non-MSSQL familiar.

Battlefield 3 Joystick Fix

It seems from a search that a lot of people are having issues with using a joystick with battlefield 3. While seeing what types of conflicting drivers I had, I went to control panel and searched for game. Windows apparently still has the legacy game controller icon. In here, you can see what joysticks are claimed to be installed. On my system, I found a virtual hid device in the list. Checking the advanced button yielded that this fake controller was the default.

I removed that controller from device manager and then all was well. Next step is to setup the Saitek X52 Pro :D

Richard Tsosie Site Re-launch

The previous Richard Tsosie Gallery site used Magento, a product whose company has since been purchased by eBay. The template system, from my point of view, was very peculiar. I understand their desire to create a versatile template concept, but the idea of unlimited themes (while only actually supporting two) and the override method for changing the template was a bit overboard when small changes are needed.

And the stock template needed these changes, as back to school ads were default present. Product management also made a lot more sense for bulk goods sellers. As I researched the various eCommerce solutions, I found few that catered to the type of products artists deal with, that is one of a kind products.

The closest I found was opencart. The result of my brief experience is now at the relaunched Richard Tsosie Gallery. The backend of this cart has my attention and I definitely am contemplating making a batch of changes to suite my needs and push upstream.

Vi Level 3 Reached

Level 1 is the start, where you begin making small changes in vi because the sys admin forgot to install nano.

Level 2 was being forsaken by textmate and forced to use windows as a dev environment. Being trapped into any environment because of a tool was not good times. I tried many IDE’s but I preferred the quick simplicity of textmate. I also had a coworker who was big on the Vi. I started with just basic functions like syntax highlighting. Little did I know what would come.

Level 3 is comfort with VI and missing it when not available. Vi works on everything? How could it not be available you may ask? This is the distinction between IDE’s and Vi in my opinion. Vi is not an IDE. No one wants FireFox to act like Visual Studio. But thanks to the good people who created http://vimperator.org/vimperator there is a way to have command line functionality in firefox and vi flavor.

Mouse and Keyboard is leet for FPS, but most functions don’t need analog input and so you waste one hand using the mouse. Apply both hands to browsing and such and you have a very neutral resting position and skip the repeated movements from keyboard to mouse.
Include command line like syntax for debugging which I hope to investigate soon, I have a fun time ahead indeed. Can’t wait for what I find in level 4.

Leveled Up On VI

I think I’m finally coming over the hill of learning VI. A key collection of plugins I found via http://spf13.com/post/the-15-best-vim-plugins

I used most but the SQL plugin. One lacking from the list is the command-t plugin. It requires you to install ruby and its dev headers, but in return you get a file finder almost better than TextMates. Folding I must learn and windows, but my coding speed with VI nav short cuts and block editting have been tremendous. Taking 3 lines and moving them down while indenting them without moving from the home row keys is pretty cool. I also think Its more comfortable since I was getting some RSD from moving to the mouse but without that motion, my hands feel much better.

I highly advise learning vi, even a little at a time. I thought I couldn’t live without TextMate. But now I know I can have the same level of editting (minus cool plugins) on any nix box by default. Much cooler than being stuck on an IDE Island.

Learning VI

I recently took a new position and unfortunately was unable to obtain (for now) a OSX based workstation. Moving to windows from OSX is a night and day transition. But it also taught me new survival skills. I learned that I was dependent on the environment I was in and had been creating test environments to suit my dev station. No more, I thought, it was time to find some thing new.  I tried Visual Studio with a wealth of Plug-Ins, Eclipse, and VI. What I started learning is that when you have more than a few servers, text editing in any Nix environment efficiently becomes awesome. I had learned Vi enough to get by in the past, but once it was embraced, the world changed. When I thought back to why I liked it, I thought back to my Mechwarrior 2 days. Nearly every key binding was on the main keyboard. A mouse may have given you a tad bit better aim, but you’d loose the ability to vent heat, jumpjet, torso turn, shutdown and countless other Mech’ly functions. When split seconds count, moving to the mouse isn’t an option if you can get by with the keyboard. Same so with VI. That said, project management is something I need to solve. There is a Viemu program for VS that lets you use VI functions in VS. But I think Ill try to tweak Vim to get those features. Far leeter.