Today I released a small and quick side-project called LiteMySQL. It’s basically a PHP5 class which is designed to automate the boring repetitive tasks of opening and managing database connections, looping through the query result resource to get an array and so on.

I created this for a small project I’m working on which basically needs database access on less than a handful of pages. And so I’d have a ready to use MySQL solution other small projects in the future.

And sorry for the lack of information on the project page as of now, but I gotta finish off the original project which motivated me to create LiteMySQL. Once done I’ll update the project page with relevant information :)

Example Usage:

# general usage
$sql = new litemysql('host', 'username', 'password', 'database', 'table');
$rows = $sql->find_all();

# conditions
# - the following three uses of the find
#   function all produce identical results
$result = $sql->find(3);
$result = $sql->find(array('id' => 3));
$result = $sql->find('`id` = 3');

# insert a single row
$sql->insert(
   array(
      'title' => 'hello world',
      'body' => 'my first blog post :D',
      'author' => 'John Doe'
   )
);

4 Responses to “LiteMySQL — A quick and simple MySQL class for PHP5”

  1. Fraeon Says:

    I should be credited for coming up with such an awesome name.

  2. jimeh Says:

    lol Fraeon, your suggestion was MyLiteSQL though ;)

  3. George Antoniadis Says:

    Cute! :D
    It’s pretty straight forward and simple!
    I like the array conditions btw!

    I’d really like to make this play with ms sql too ;)
    Is there a place (wiki, forum, mailing list, etc) for suggestions and stuff?

    ps. Nice work :)

  4. jimeh Says:

    heh… glad you like it george :)

    MSSQL isn’t a bad idea. I’ll be setting up a forum/wiki/something soon about LiteMySQL. I’m not even really sure what google code offers in that area yet, but worst case scenario i’ll setup a forum here just… lol

    Gotta finish off the current site project at hand first just :)

Leave a Reply