Looking for a lightweight and clean database class (php4 and php5 campatable)

Discussion in 'PHP' started by Greg-J, Jan 19, 2008.

  1. #1
    I tell you, I'm having a hell of a time finding a database class that is compatible with php4 and php5. I'm looking for something simple and lightweight.

    If you have one or can point me in the direction of one, I'd be very grateful.
     
    Greg-J, Jan 19, 2008 IP
  2. mvl

    mvl Peon

    Messages:
    147
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I use Adodb for almost everything. It is not very lightweight but if you do a lot of database stuff it will speed up development. It has an abstraction layer so you can use it with all major databases (MySQL, PostGreSQL, Oracle, etc. etc.)
     
    mvl, Jan 19, 2008 IP
  3. Greg-J

    Greg-J I humbly return to you.

    Messages:
    1,844
    Likes Received:
    153
    Best Answers:
    0
    Trophy Points:
    135
    #3
    Thanks for the link, but I think ADOdb and ADOdblite are both more than I need. I don't have a use for an abstraction layer and after looking through their documentation it seems like they're over complicating things. At least for my needs anyway.

    Thank you though. I've bookmarked it as I think I might use it in the future.
     
    Greg-J, Jan 20, 2008 IP
  4. xxKillswitch

    xxKillswitch Peon

    Messages:
    331
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I have a simple database class I use, its good for simply executing queries, retrieving results as either arrays or objects, and counts number of rows. PM if you are interested.
     
    xxKillswitch, Jan 20, 2008 IP
  5. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #5
    Just use the inbuilt db functions, they are clean and lightweight, classes just gives you more headaches as you have to include it in the files you want to use them.

    What is wrong with this?
    
    <?php
    // Connecting, selecting database
    $link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
        or die('Could not connect: ' . mysql_error());
    echo 'Connected successfully';
    mysql_select_db('my_database') or die('Could not select database');
    
    // Performing SQL query
    $query = 'SELECT * FROM my_table';
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
    
    // Printing results in HTML
    echo "<table>\n";
    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
        echo "\t<tr>\n";
        foreach ($line as $col_value) {
            echo "\t\t<td>$col_value</td>\n";
        }
        echo "\t</tr>\n";
    }
    echo "</table>\n";
    
    // Free resultset
    mysql_free_result($result);
    
    // Closing connection
    mysql_close($link);
    ?>
    
    PHP:
     
    Kaizoku, Jan 20, 2008 IP
  6. ngcoders

    ngcoders Active Member

    Messages:
    206
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #6
    I had written LIMBO CMS long time back , Google it download it , it has a light adodb implementation.
     
    ngcoders, Jan 20, 2008 IP