A MySQL functions wrapper. Provides ability to get results as arrays and query logging (inc. execution time).
By : jestempies
<?PHP /* * Name: PiesDBO * Author: Michal Tatarynowicz (pies /at/ sputnik /dot/ pl) * Version: 1.0 * Release date: 2004-09-16 * Licence: Public Domain * * Description: * A MySQL functions wrapper. Provides ability to get results as arrays. * * Example usage: * require_once('dbo.inc');
// create and connect the object $db = new PiesDBO(array( 'host'=>'localhost', 'user'=>'username', 'pass'=>'password', 'db'=>'database'));
// read the whole query result array (of rows) $all_rows = $db->all("SELECT a,b,c FROM table");
// read the first row with debugging on $first_row_only = $db->one("SELECT a,b,c FROM table WHERE a=1", TRUE);
// emulate the usual MySQL way of reading query results if ( $db->q("SELECT a,b,c FROM table") ) { while ( $row = $db->farr() ) { print $row['a'].$row['b'].$row['c']; } }
// show a log of all queries, sorted by execution time showLog(TRUE);
*/
class PiesDBO {
// public var $connected=FALSE; var $debug=FALSE; var $error=NULL; var $insert_id=NULL; var $affected=NULL; var $took=NULL;
// private var $_conn=NULL; var $_result=NULL; var $_queries_cnt=0; var $_queries_time=NULL; var $_queries_log=array();
function PiesDBO($config=NULL,$DEBUG=FALSE) { $this->__constructor($config); }
function __constructor($config=NULL,$DEBUG=FALSE) { $this->debug = $DEBUG; Return $this->connect($config); }
foreach( $sa as $key=>$val ) $out[] = $array[$key];
Return $out;
} else Return null; } }
?>
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.