Skip navigation

Category Archives: MYSQL

AjaxLine gives 32 ways to speed up MySQL queries

Advertisements

We use PHP and MySQL extensively here at Frontier.  We’ve found it to be the most cost efficient way for us to accomplish things on the web quickly and efficiently.  During the course of our development, we’ve constantly been looking for better ways to do things that are commonly done in the code world.  In that spirit, DevShed has an article on building a PHP basedActive Record Pattern” and “Database abstraction layer” that simplifies and unifies MySQL manipulations via PHP.  Really good stuff. 

Although I’m sure many people already knew the answer to this, I wanted to post the solution mainly so that I don’t forget.  I spent about 30 mins looking for the answer again yesterday since I had forgotten it from the last time I used it. 

To store an array (even a multi-dimensional array) from PHP into MySQL, use the serialize() and unserialize() functions.  There’s other ways of doing it I’m sure, but this has proven quick and painless for myself.  So, sample code might be:

//To insert
$SampleArray = array();
$SampleArray = serialize($SampleArray);

$sql = “INSERT INTO table (‘ArrayField’) VALUES (‘$SampleArray’);
//Run sql statement

//To retrieve
$SampleArray = unserialize($row_table[‘ArrayField’]);

I’ve seen some debate floating around about manipulating MySQL via the command line or via a GUI app like Sequel Pro, Navicat, etc

I personally are using both the command line and a GUI.  I mainly use the Sequel Pro for table structure manipulation and browsing table contents similar to PHPMyAdmin.  However, with Coda’s nice built command line interface, I use the command line to insert, select, update, etc. 

Is there any credence to this argument?  Is there really a GUI that can easily replace the command line?  Should I be creating my statements in a GUI? 

Right now, I’m enjoying:

1) This bit of MySQL that will show duplicate entries

2) Sequel Pro, an open source database management program similar to Navicat, but better for my purposes.

In my dealings with MySQL, I’ve typically relied on a combo of Terminal and the MySQL Administration package from MySQL.  I know many people rely on PHPMyAdmin and we’ve toyed with Navicat before.  In my web rummaging this morning, I came across Sequel Pro from mjmedia.  Sequel Pro is the leftovers from CocoaMySQL and looks to be a promising database administration/browsing program for the mac.