For PHP web developers, there are any number of options to connect to a MySQL database. By far, the oldest and most widely used method is through the original MySQL extension in PHP. In recent years, the PHP development team have made efforts on two fronts to update the functionality and versaitlity of the connection extension through the MySQLi (“MySQL Improved”) and PDO (“PHP Data Object”) extensions, respectively. The PHP development team highly recommends migrating to MySQLi:
The mysql extension provides a procedural interface and is intended for use only with MySQL versions older than 4.1.3. This extension can be used with versions of MySQL 4.1.3 or newer, but not all of the latest MySQL server features will be available.
Note: If you are using MySQL versions 4.1.3 or later it is strongly recommended that you use the mysqli extension instead.
So what do you do if you’re a Dreamweaver user relying upon Server Behaviors? Until Adobe update their embedded server behaviors to use the updated standard, you don’t have a choice: you cannot use server behaviors with the MySQLi extension. To be clear, the Adobe team have never publicly announced their intention to update their code, so we developers need to look for help elsewhere.
This is where MyQuery Builder comes in. You can use MyQuery Builder’s SELECT and Utility Query editors to construct your queries regardless of the extension you use. You can then send your query to the PHP Code Builder tool to wrap your code in MySQLi extension functions. You even have the choice of using the MySQLi object-oriented syntax or the procedural syntax.
To help make your conversion even easier, you can use MyQuery Builder’s MySQL->MySQLi converter in the Tools tab. If you have built pages using Dreamweaver’s server behaviors, you can simply copy the contents of each page and paste it into the tool. Run the converter, and you get clean MySQLi extension code–again using either the object-oriented or the procedural syntax. Paste it back into each of your documents, and you’ll be good to go. Don’t forget to convert your main Connections file(s) in addition to each individual code page.
Just in case it’s not obvious, once you make these conversions, your code will work in a browser, but Dreamweaver will no longer recognize your server behaviors, databases, or any associated functionality. On the positive side, this opens the door to migrating away from Dreamweaver entirely to any IDE of your choice. You can read about my own experience eliminating Dreamweaver from my production workflow in my blog post, Divorcing Dreamweaver.