function(). * * Functions that interact with the resetset created by a query should * be placed inside the blob_ResultSet class. These are functions accessed using * $result->function(). * * Example: * $result = $db->Execute($sql); * echo $result->function(); * * Place the file into the approriate database driver directory. You should create one * for each database you would like to support. * * To use your blob module start ADOdb Lite using. * * $db = ADONewConnection($databasetype, 'blob'); * */ if (!defined('TIMESTAMP_FIRST_YEAR')) define('TIMESTAMP_FIRST_YEAR',100); eval('class time_EXTENDER extends '. $last_module . '_ADOConnection { }'); class time_ADOConnection extends time_EXTENDER { var $fmtTimeStamp = "'Y-m-d, h:i:s A'"; /// used by DBTimeStamp as the default timestamp fmt. var $fmtDate = "'Y-m-d'"; /// used by DBDate() as the default date format used by the database function DBDate($d) { if (empty($d) && $d !== 0) return 'null'; if (is_string($d) && !is_numeric($d)) { if ($d === 'null' || strncmp($d,"'",1) === 0){ return $d; } if ($this->isoDates){ return "'$d'"; } $d = UnixDate($d); } require_once(dirname(__FILE__).'/../../adodb-time.inc.php'); $adodblite_time = new adodblite_time; return $adodblite_time->adodb_date($this->fmtDate,$d); } function DBTimeStamp($ts) { require_once(dirname(__FILE__).'/../../adodb-time.inc.php'); $adodblite_time = new adodblite_time; if (empty($ts) && $ts !== 0) { return 'null'; } # strlen(14) allows YYYYMMDDHHMMSS format if (!is_string($ts) || (is_numeric($ts) && strlen($ts)<14)) { return $adodblite_time->adodb_date($this->fmtTimeStamp,$ts); } if ($ts === 'null') { return $ts; } if ($this->isoDates && strlen($ts) !== 14) { return "'$ts'"; } $ts = UnixTimeStamp($ts); return $adodblite_time->adodb_date($this->fmtTimeStamp,$ts); } function UnixDate($v) { require_once(dirname(__FILE__).'/../../adodb-time.inc.php'); $adodblite_time = new adodblite_time; if (is_object($v)) { // odbtp support //( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 ) return $adodblite_time->adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year); } if (is_numeric($v) && strlen($v) !== 8) return $v; if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|", ($v), $rr)) return false; if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0; // h-m-s-MM-DD-YY return @$adodblite_time->adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); } } eval('class time_resultset_EXTENDER extends '. $last_module . '_ResultSet { }'); class time_ResultSet extends time_resultset_EXTENDER { function UnixDate($v) { return ADOConnection::UnixDate($v); } function UserTimeStamp($v,$fmt='Y-m-d H:i:s',$gmt=false) { require_once(dirname(__FILE__).'/../../adodb-time.inc.php'); $adodblite_time = new adodblite_time; if (!isset($v)) return $this->emptyTimeStamp; # strlen(14) allows YYYYMMDDHHMMSS format if (is_numeric($v) && strlen($v)<14) return ($gmt) ? $adodblite_time->adodb_gmdate($fmt,$v) : $adodblite_time->adodb_date($fmt,$v); $tt = $adodblite_time->UnixTimeStamp($v); // $tt == -1 if pre TIMESTAMP_FIRST_YEAR if (($tt === false || $tt == -1) && $v != false) return $v; if ($tt == 0) return $this->emptyTimeStamp; return ($gmt) ? $adodblite_time->adodb_gmdate($fmt,$tt) : $adodblite_time->adodb_date($fmt,$tt); } } ?>