Posted By

axisweb on 08/07/14


Tagged

mysql php dibi


Versions (?)

Dibi snippets


 / Published in: PHP
 

URL: http://dibiphp.com/

Using Dibi database framework

  1. echo dibi::$sql; // last cmd
  2. echo dibi::$elapsedTime; // his time in sec
  3. echo dibi::$numOfQueries; // how many commands
  4. echo dibi::$totalTime; // total time in sec
  5.  
  6. //connecting
  7. dibi::connect(array(
  8. 'driver' => 'mysql',
  9. 'host' => $settings['dbhost'],
  10. 'username' => $settings['dbuser'],
  11. 'password' => $settings['dbpass'],
  12. 'database' => $settings['dbname'],
  13. ));
  14.  
  15.  
  16. //get one column as numbered array
  17. $result=dibi::fetchPairs('show tables like %s','%prefx_%');
  18.  
  19. $result=dibi::query('select * from myrecords limit %i',100);
  20.  
  21. $all=$result->fetchAll();//numbered
  22. $all=$result->fetchAssoc('id');//associated
  23. $all=$result->fetchAssoc('parentid,id'); //multidimensional
  24.  
  25. //load dump file
  26. dibi::connect();
  27. dibi::loadFile('dump.sql');
  28. //or compressed
  29. dibi::loadFile('compress.zlib://dump.sql.gz');

Report this snippet  

You need to login to post a comment.