[Vtigercrm-commits] [vtiger-commits] r4240 - /vtigercrm/trunk/include/database/PearDatabase.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Thu Mar 16 04:16:56 EST 2006
Author: richie
Date: Thu Mar 16 02:16:51 2006
New Revision: 4240
Log:
overwriting with the 4.2.4 changes for vtlogger and other misc fixes
Modified:
vtigercrm/trunk/include/database/PearDatabase.php
Modified: vtigercrm/trunk/include/database/PearDatabase.php
==============================================================================
--- vtigercrm/trunk/include/database/PearDatabase.php (original)
+++ vtigercrm/trunk/include/database/PearDatabase.php Thu Mar 16 02:16:51 2006
@@ -14,11 +14,12 @@
********************************************************************************/
require_once('include/logging.php');
-//include('adodb/adodb.inc.php');
-include_once('adodb/adodb.inc.php');
+include('adodb/adodb.inc.php');
require_once("adodb/adodb-xmlschema.inc.php");
-$log1 =& LoggerManager::getLogger('VT');
+require_once('vtigerlogger.php');
+global $vtlog;
+$vtlog = new vtigerLogger();
class PearDatabase{
var $database = null;
@@ -34,11 +35,8 @@
var $lastmysqlrow = -1;
var $enableSQLlog = false;
-
function isMySQL() { return dbType=='mysql'; }
-
function isOracle() { return dbType=='oci8'; }
-
function println($msg)
{
@@ -46,13 +44,11 @@
$log1 =& LoggerManager::getLogger('VT');
if(is_array($msg))
{
- //$log1->fatal("PearDatabse ->".print_r($msg,true));
- $log1->info("PearDatabse ->".print_r($msg,true));
+ $log1->fatal("PearDatabse ->".print_r($msg,true));
}
else
{
- //$log1->fatal("PearDatabase ->".$msg);
- $log1->info("PearDatabase ->".$msg);
+ $log1->fatal("PearDatabase ->".$msg);
}
return $msg;
}
@@ -162,13 +158,13 @@
if($this->dieOnError || $dieOnError)
{
- $this->println("ADODB error ".$msg."->[".$this->database->ErrorNo()."]".$this->database->ErrorMsg(),'error');
+ $this->println("ADODB error ".$msg."->[".$this->database->ErrorNo()."]".$this->database->ErrorMsg());
die ($msg."ADODB error ".$msg."->".$this->database->ErrorMsg());
}
else
{
- //$this->println("ADODB error ".$msg."->[".$this->database->ErrorNo()."]".$this->database->ErrorMsg());
- $this->println("ADODB error ".$msg."->[".$this->database->ErrorNo()."]".$this->database->ErrorMsg()." (SQL=".$this->sql.")",'error');
+ $this->println("ADODB error ".$msg."->[".$this->database->ErrorNo()."]".$this->database->ErrorMsg());
+
}
return false;
}
@@ -189,7 +185,7 @@
* Contributor(s): ______________________________________..
*/
function checkConnection(){
-global $log1;
+global $vtlog;
if(!isset($this->database))
{
$this->println("TRANS creating new connection");
@@ -206,9 +202,8 @@
else
{
// $this->println("checkconnect using old connection");
- //commenting as the above log will suffice. this was filling up the logs too much
- //$log1->info('checkconnect using old connection');
- }
+ $vtlog->logthis('checkconnect using old connection','info');
+ }
}
/* ADODB converted
@@ -232,16 +227,11 @@
function query($sql, $dieOnError=false, $msg='')
{
- global $log1;
+ global $vtlog;
//$this->println("ADODB query ".$sql);
- $log1->debug('query being executed : '.$sql);
- $mytime["start"] = $this->microtime_float();
+ $vtlog->logthis('query being executed : '.$sql,'debug');
$this->checkConnection();
$result = & $this->database->Execute($sql);
- $mytime["execute"] = $this->microtime_float();
- $mytime["total"] = $mytime["execute"]-$mytime["start"];
- if ( $mytime["total"] > 0.5 )
- $log1->error("TIME: sql statement $sql took {$mytime['total']} seconds.");
$this->lastmysqlrow = -1;
if(!$result)$this->checkError($msg.' Query Failed:' . $sql . '::', $dieOnError);
return $result;
@@ -261,6 +251,15 @@
$this->checkConnection();
$result = $this->database->UpdateBlob($tablename, $colname, $data, $id);
$this->println("updateBlob t=".$tablename." c=".$colname." id=".$id." status=".$result);
+ return $result;
+ }
+
+ function updateBlobFile($tablename, $colname, $id, $filename)
+ {
+ $this->println("updateBlobFile t=".$tablename." c=".$colname." id=".$id." f=".$filename);
+ $this->checkConnection();
+ $result = $this->database->UpdateBlobFile($tablename, $colname, $filename, $id);
+ $this->println("updateBlobFile t=".$tablename." c=".$colname." id=".$id." f=".$filename." status=".$result);
return $result;
}
@@ -283,9 +282,9 @@
function limitQuery($sql,$start,$count, $dieOnError=false, $msg='')
{
- global $log1;
+ global $vtlog;
//$this->println("ADODB limitQuery sql=".$sql." st=".$start." co=".$count);
- $log1->debug(' limitQuery sql = '.$sql .' st = '.$start .' co = '.$count);
+ $vtlog->logthis(' limitQuery sql = '.$sql .' st = '.$start .' co = '.$count,'debug');
$this->checkConnection();
$result =& $this->database->SelectLimit($sql,$count,$start);
if(!$result) $this->checkError($msg.' Limit Query Failed:' . $sql . '::', $dieOnError);
@@ -398,12 +397,12 @@
*/
function getRowCount(&$result){
- global $log1;
+ global $vtlog;
//$this->println("ADODB getRowCount");
if(isset($result) && !empty($result))
$rows= $result->RecordCount();
//$this->println("ADODB getRowCount rows=".$rows);
- $log1->debug('getRowCount rows= '.$rows);
+ $vtlog->logthis('getRowCount rows= '.$rows,'debug');
return $rows;
}
@@ -430,23 +429,13 @@
//$this->println("ADODB fetch_array return null");
return NULL;
}
- //return $this->change_key_case($result->FetchRow());
- $ret = @ $this->change_key_case($result->FetchRow());
- if ( !is_array($ret) )
- {
- $this->println( "ERROR: SQL (".$this->sql.")" );
- $this->println( print_r($result,1) );
- //die;
- }
- return $ret;
-
+ return $this->change_key_case($result->FetchRow());
}
/* ADODB newly added. replacement for mysql_result() */
function query_result(&$result, $row, $col=0)
- {
- if ( !$result ) return;
+ {
//$this->println("ADODB query_result r=".$row." c=".$col);
$result->Move($row);
$rowdata = $this->change_key_case($result->FetchRow());
@@ -470,12 +459,12 @@
}*/
function getAffectedRowCount(&$result){
- global $log1;
+ global $vtlog;
// $this->println("ADODB getAffectedRowCount");
- $log1->debug('getAffectedRowCount');
+ $vtlog->logthis('getAffectedRowCount','debug');
$rows =$this->database->Affected_Rows();
// $this->println("ADODB getAffectedRowCount rows=".rows);
- $log1->info('getAffectedRowCount rows = '.$rows);
+ $vtlog->logthis('getAffectedRowCount rows = '.$rows,'debug');
return $rows;
}
@@ -585,10 +574,10 @@
*/
function getNextRow(&$result, $encode=true){
- global $log1;
+ global $vtlog;
//$this->println("ADODB getNextRow");
- $log1->info('getNextRow');
+ $vtlog->logthis('getNextRow','info');
if(isset($result)){
$row = $this->change_key_case($result->FetchRow());
if($row && $encode&& is_array($row))return array_map('to_html', $row);
@@ -608,12 +597,6 @@
return $result->FetchField($col);
}
- function microtime_float()
- {
- list($usec, $sec) = explode(" ", microtime());
- return ((float)$usec + (float)$sec);
- }
-
function getQueryTime(){
return $this->query_time;
}
@@ -773,7 +756,7 @@
function quote($string){
- return ADOConnection::qstr($string,get_magic_quotes_gpc());
+ return ADOConnection::qstr($string);
}
@@ -825,12 +808,16 @@
//$this->println("ADODB createTables connect status=".$db->Connect($this->dbHostName, $this->userName, $this->userPassword, $this->dbName));
$schema = new adoSchema( $db );
+ //Debug Adodb XML Schema
+ $sehema->XMLS_DEBUG = TRUE;
+ //Debug Adodb
+ $sehema->debug = true;
$sql = $schema->ParseSchema( $schemaFile );
$this->println("--------------Starting the table creation------------------");
//$this->println($sql);
-
+ //integer ExecuteSchema ([array $sqlArray = NULL], [boolean $continueOnErr = NULL])
$result = $schema->ExecuteSchema( $sql, true );
if($result)
print $db->errorMsg();
More information about the vtigercrm-commits
mailing list