nabeel shahzad

ezDB 2.0

with 15 comments

Note

The latest version, docs, etc can now be found on github, at:

http://wiki.github.com/nshahzad/ezdb/

Written by Nabeel

March 3rd, 2009 at 9:45 pm

Posted in

  • Pingback: ezSQL Database Library (Improved!) | nsslive

  • http://www.calinsoft.com CalinSoft

    Nice Works.!

    You can add this feature?

    $table_prefix =”m2_”;

    $tables = array( ‘table1′ => ‘table1′,
    ‘table2′ => ‘menu’,
    ‘table3′ => ‘users’ );

    $db->mapping_tables($tables,$table_prefix);

    echo $db->users; // m2_table3

    —————
    classs db

    function mapping_tables($tables = array(), $prefix=”m2_”)
    {
    $this->tables = $tables;
    $this->prefix = $prefix;

    // build the mapping with prefixes
    foreach ( $this->tables as $s => $t ) {
    $this->$t= $prefix .$s ;
    }
    }

  • Jay

    Your class really takes ezSQL to the next level. I’m a big fan of SQLite, so I’ve ported a PDO module to your improved ezSQL. You can find the source code here:

    http://github.com/jaywilliams/ultralite/raw/012e2cfeced015c4bc5658ad85e726cd1ea2780f/app/classes/Pixelpost/DB/PDO.php

    You’ll probably have to make a few modifications from the source, but the bulk of it should be usable.

  • http://blog.nye.cat nyë

    Hello,

    How can I get the last inserted id after doing $res=DB::query(“INSERT…”);

    I’ve tried with $id=DB::$insert_id; but a I get an empty value…

    Thanks

  • http://blog.nye.cat nyë

    I forgot to say that I use the mysqli class “ezDB_MySQLi.class.php”

  • Nabeel

    Sounds like a bug. I have a few fixes, which I need to commit upto github.

  • http://blog.nye.cat nyë

    Hello,

    Are you going to commit it soon? Or maybe you can give me a clue on how to fix it meanwhile…

    Many thanks!

  • Jon

    I really appreciate this script. Thank you for working on it!
    I believe there is one issue in error handling.
    In ezDB.class.php on line 58, we see:

    [code]public static $throw_exceptions = true;[/code]

    then, throughout the rest of the scripts we see:

    [code]if($this->use_exceptions)[/code]

    shouldn’t these be the same?

    Thanks again!

  • Nabeel

    Thanks for your reply. I think I’ve fixed that, I will check it though. There’s an updated copy on github which I had updated a few days ago. Cheers!

  • Jon

    You replied so quickly! That’s wonderful!
    I downloaded the latest version you have posted and it is still like that. It’s an easy fix, I just changed

    public static $throw_exceptions = true;

    in ezdb.class.php to:

    public static $use_exceptions = true;

    I have another question.
    I would like to define the character encoding used in the database. There is an excellent page at http://www.stumbleupon.com/group/php/forum/37465/
    He suggests using something like:

    // Make sure we are using UTF-8 Character Encoding.
    mysql_query(“SET NAMES ‘utf8′;”, $this->dbh);
    mysql_query(“SET CHARACTER SET ‘utf8′;”, $this->dbh);

    just after opening the connection to the database.
    How could I incorporate this into the ezdb script most elegantly?

    Thank you once again for the great scripts!

  • Nabeel

    Hi Jon,

    It’s updated on github, I had fixed that, along with a few mysqli issues. You can also post issues on the site there :)

    The easiest way for that might just be:

    DB::query(‘SET NAMES `utf8`’)
    DB::query(‘SET CHARACTER SET `utf8`’);

  • Jackie

    Thanks to improve ezsql.
    I really love ezsql.
    but want to have ezDB and use it with codeigniter..
    so help me how to use ezDB with codeigniter….

  • Nabeel

    Hi Jackie, Thanks! I’m not too familiar with CodeIgnitor, but it doesn’t have it own database functions? If it doesn’t, I’m sure there’s a way to include external libraries

  • Enes

    Hi Nabeel!

    Happy new year to you.

    Are you planning to add memcache functionality to the ezsql? I have just checked the github and last commit made in October.

    So, what’s the plan?

  • Nabeel

    Hi Enes, happy new year to you too! I haven’t had time to add memcache integration just yet, it’s been a very very busy few months…