Posted By

Abe on 01/28/08


Tagged

mysql database class php


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Nix


MySQL Class Cheat Sheet


 / Published in: PHP
 

URL: http://snipplr.com/view/2739/mysql-database-class/

Cheat sheet for the MySQL Databse Class

  1. <?php
  2. require_once 'mysql_class.php';
  3. $db = array('host'=>'localhost', 'name'=>'dbname', 'user'=>'', 'pass'=>'');
  4. $sql = new Database($db);
  5. $sql -> connect();
  6.  
  7. /*/ CREATE
  8. $sqlData = array(''=>'');
  9. $sql -> runInsert('tableName', $sqlData);//*/
  10.  
  11. // READ
  12. $result = $sql -> runSelect('tableName');
  13. while ($r = mysql_fetch_assoc($result)) {
  14. echo 'ID: '.$r['id']."<br />\n";
  15. }
  16. mysql_free_result($result);//*/
  17.  
  18. /*/ UPDATE
  19. $sqlData = array(''=>'');
  20. $sql -> runUpdate('tableName', $sqlData, 'id=1');//*/
  21.  
  22. /*/ DELETE
  23. $sql -> runDelete('tableName', 'id=1');//*/
  24.  
  25. $sql -> close();
  26. ?>

Report this snippet  

You need to login to post a comment.