[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: phpgwapi/inc class.db_msql.inc.php,1.5,1.6 class
From: |
Miles Lott <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: phpgwapi/inc class.db_msql.inc.php,1.5,1.6 class.db_mssql.inc.php,1.20,1.21 class.db_mysql.inc.php,1.30,1.31 class.db_oracle.inc.php,1.6,1.7 class.db_pgsql.inc.php,1.30,1.31 class.db_sybase.inc.php,1.6,1.7 |
Date: |
Sun, 10 Feb 2002 07:04:15 -0500 |
Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv5190
Modified Files:
class.db_msql.inc.php class.db_mssql.inc.php
class.db_mysql.inc.php class.db_oracle.inc.php
class.db_pgsql.inc.php class.db_sybase.inc.php
Log Message:
Formatting
Index: class.db_msql.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.db_msql.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** class.db_msql.inc.php 29 Sep 2001 00:33:05 -0000 1.5
--- class.db_msql.inc.php 10 Feb 2002 12:04:10 -0000 1.6
***************
*** 28,36 ****
var $Error = '';
! var $Auto_Free = 0; ## Set this to 1 for automatic
msql_free_result()
function connect()
{
! // Not connected? Then connect?
if ( 0 == $this->Link_ID )
{
--- 28,36 ----
var $Error = '';
! var $Auto_Free = 0; /* Set this to 1 for automatic
msql_free_result() */
function connect()
{
! /* Not connected? Then connect? */
if ( 0 == $this->Link_ID )
{
***************
*** 41,46 ****
}
! // Still not connected? Raise error.
! if ( 0 == $this->Link_ID )
{
$this->halt('Link-ID == false, pconnect
failed');
--- 41,46 ----
}
! /* Still not connected? Raise error. */
! if(0 == $this->Link_ID)
{
$this->halt('Link-ID == false, pconnect
failed');
***************
*** 48,52 ****
// Select current database
! if (!msql_select_db($this->Database, $this->Link_ID))
{
$this->halt('cannot use database
'.$this->Database);
--- 48,52 ----
// Select current database
! if(!msql_select_db($this->Database, $this->Link_ID))
{
$this->halt('cannot use database
'.$this->Database);
***************
*** 58,67 ****
$this->connect();
! # printf("Debug: query = %s<br>\n", $Query_String);
$this->Query_ID =
msql_query($Query_String,$this->Link_ID);
$this->Row = 0;
$this->Error = msql_error();
! if (!$this->Query_ID)
{
$this->halt('Invalid SQL: '.$Query_String);
--- 58,67 ----
$this->connect();
! /* printf("Debug: query = %s<br>\n", $Query_String); */
$this->Query_ID =
msql_query($Query_String,$this->Link_ID);
$this->Row = 0;
$this->Error = msql_error();
! if(!$this->Query_ID)
{
$this->halt('Invalid SQL: '.$Query_String);
***************
*** 77,81 ****
$stat = is_array($this->Record);
! if (!$stat && $this->Auto_Free)
{
msql_free_result($this->Query_ID);
--- 77,81 ----
$stat = is_array($this->Record);
! if(!$stat && $this->Auto_Free)
{
msql_free_result($this->Query_ID);
***************
*** 88,92 ****
{
$status = msql_data_seek($this->Query_ID, $pos);
! if ($status)
{
$this->Row = $pos;
--- 88,92 ----
{
$status = msql_data_seek($this->Query_ID, $pos);
! if($status)
{
$this->Row = $pos;
***************
*** 103,107 ****
$this->connect();
$id = @msql_list_fields($this->Database, $table);
! if ($id < 0)
{
$this->Error = msql_error();
--- 103,107 ----
$this->connect();
$id = @msql_list_fields($this->Database, $table);
! if($id < 0)
{
$this->Error = msql_error();
***************
*** 110,114 ****
$count = msql_num_fields($id);
! for ($i=0; $i<$count; $i++)
{
$res[$i]['table'] = msql_fieldtable ($id, $i);
--- 110,114 ----
$count = msql_num_fields($id);
! for($i=0; $i<$count; $i++)
{
$res[$i]['table'] = msql_fieldtable ($id, $i);
Index: class.db_mssql.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.db_mssql.inc.php,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** class.db_mssql.inc.php 14 Dec 2001 03:42:17 -0000 1.20
--- class.db_mssql.inc.php 10 Feb 2002 12:04:10 -0000 1.21
***************
*** 4,8 ****
* (C) Copyright 1998 Cameron Taggart (address@hidden) *
* Modified by Guarneri carmelo (address@hidden) *
! * Modified by Cameron Just (address@hidden) *
* ------------------------------------------------------------------------ *
* This is not part of phpGroupWare, but is used by phpGroupWare.
*
--- 4,8 ----
* (C) Copyright 1998 Cameron Taggart (address@hidden) *
* Modified by Guarneri carmelo (address@hidden) *
! * Modified by Cameron Just (address@hidden) *
* ------------------------------------------------------------------------ *
* This is not part of phpGroupWare, but is used by phpGroupWare.
*
***************
*** 17,22 ****
/* $Id$ */
! /* echo "<BR>This is using the MSSQL class<BR>"; */
! // ^^ really ?! :)
class db
--- 17,23 ----
/* $Id$ */
! /* echo '<BR>This is using the MSSQL class<BR>'; */
! /* ^^ really ?! :) */
! /* mdean, put your info in the banner, mkay? */
class db
***************
*** 41,47 ****
function connect()
{
! if ( 0 == $this->Link_ID )
{
! if
($GLOBALS['phpgw_info']['server']['db_persistent'])
{
$this->Link_ID=mssql_pconnect($this->Host, $this->User, $this->Password);
--- 42,48 ----
function connect()
{
! if(0 == $this->Link_ID)
{
!
if($GLOBALS['phpgw_info']['server']['db_persistent'])
{
$this->Link_ID=mssql_pconnect($this->Host, $this->User, $this->Password);
***************
*** 51,55 ****
$this->Link_ID=mssql_connect($this->Host, $this->User, $this->Password);
}
! if (!$this->Link_ID)
{
$this->halt('Link-ID == false,
mssql_'.($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'').'connect
failed');
--- 52,56 ----
$this->Link_ID=mssql_connect($this->Host, $this->User, $this->Password);
}
! if(!$this->Link_ID)
{
$this->halt('Link-ID == false,
mssql_'.($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'').'connect
failed');
***************
*** 68,72 ****
function db_addslashes($str)
{
! if (!IsSet($str) || $str == '')
{
return '';
--- 69,73 ----
function db_addslashes($str)
{
! if(!isset($str) || $str == '')
{
return '';
***************
*** 86,90 ****
$this->VEOF = -1;
! if (!$this->Link_ID)
{
$this->connect();
--- 87,91 ----
$this->VEOF = -1;
! if(!$this->Link_ID)
{
$this->connect();
***************
*** 93,97 ****
$this->Query_ID = mssql_query($Query_String,
$this->Link_ID);
$this->Row = 0;
! if (!$this->Query_ID)
{
$this->halt("Invalid SQL: " . $Query_String,
$line, $file);
--- 94,98 ----
$this->Query_ID = mssql_query($Query_String,
$this->Link_ID);
$this->Row = 0;
! if(!$this->Query_ID)
{
$this->halt("Invalid SQL: " . $Query_String,
$line, $file);
***************
*** 114,123 ****
function limit_query($Query_String, $offset, $line = '', $file
= '', $num_rows = '')
{
! if (! $num_rows)
{
$num_rows =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
}
! if ($this->Debug)
{
printf("Debug: limit_query = %s<br>offset=%d,
num_rows=%d<br>\n", $Query_String, $offset, $num_rows);
--- 115,124 ----
function limit_query($Query_String, $offset, $line = '', $file
= '', $num_rows = '')
{
! if(!$num_rows)
{
$num_rows =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
}
! if($this->Debug)
{
printf("Debug: limit_query = %s<br>offset=%d,
num_rows=%d<br>\n", $Query_String, $offset, $num_rows);
***************
*** 125,133 ****
$this->query($Query_String, $line, $file);
! if ($this->Query_ID)
{
$this->Row = $offset;
// Push cursor to appropriate row in case
next_record() is used
! if ($offset > 0)
{
@mssql_data_seek($this->Query_ID,
$offset);
--- 126,134 ----
$this->query($Query_String, $line, $file);
! if($this->Query_ID)
{
$this->Row = $offset;
// Push cursor to appropriate row in case
next_record() is used
! if($offset > 0)
{
@mssql_data_seek($this->Query_ID,
$offset);
***************
*** 141,145 ****
function next_record()
{
! if (!$this->Query_ID)
{
$this->halt("next_record called with no query
pending.");
--- 142,146 ----
function next_record()
{
! if(!$this->Query_ID)
{
$this->halt("next_record called with no query
pending.");
***************
*** 147,158 ****
}
! if ($this->VEOF == -1 || ($this->Row++ <= $this->VEOF))
{
// Work around for buggy mssql_fetch_array
$rec = @mssql_fetch_row($this->Query_ID);
! if ($rec)
{
$this->Record = array();
! for ($i = 0; $i < count($rec); $i++)
{
$this->Record[$i] = $rec[$i];
--- 148,159 ----
}
! if($this->VEOF == -1 || ($this->Row++ <= $this->VEOF))
{
// Work around for buggy mssql_fetch_array
$rec = @mssql_fetch_row($this->Query_ID);
! if($rec)
{
$this->Record = array();
! for($i = 0; $i < count($rec); $i++)
{
$this->Record[$i] = $rec[$i];
***************
*** 172,176 ****
$stat = is_array($this->Record);
! if (!$stat && $this->Auto_Free)
{
$this->free();
--- 173,177 ----
$stat = is_array($this->Record);
! if(!$stat && $this->Auto_Free)
{
$this->free();
***************
*** 188,192 ****
function transaction_commit()
{
! if (!$this->Errno && $this->Transaction)
{
$this->Transaction = false;
--- 189,193 ----
function transaction_commit()
{
! if(!$this->Errno && $this->Transaction)
{
$this->Transaction = false;
***************
*** 199,203 ****
function transaction_abort()
{
! if ($this->Transaction)
{
$this->Transaction = false;
--- 200,204 ----
function transaction_abort()
{
! if($this->Transaction)
{
$this->Transaction = false;
***************
*** 222,226 ****
$this->connect();
$id = mssql_query("select * from $table",
$this->Link_ID);
! if (!$id)
{
$this->halt('Metadata query failed.');
--- 223,227 ----
$this->connect();
$id = mssql_query("select * from $table",
$this->Link_ID);
! if(!$id)
{
$this->halt('Metadata query failed.');
***************
*** 229,233 ****
$count = mssql_num_fields($id);
! for ($i=0; $i<$count; $i++)
{
$info = mssql_fetch_field($id, $i);
--- 230,234 ----
$count = mssql_num_fields($id);
! for($i=0; $i<$count; $i++)
{
$info = mssql_fetch_field($id, $i);
***************
*** 284,288 ****
* identity on the connection, so table and field are
ignored here as well.
*/
! if (!isset($table) || $table == '' || !isset($field) ||
$field == '')
{
return -1;
--- 285,289 ----
* identity on the connection, so table and field are
ignored here as well.
*/
! if(!isset($table) || $table == '' || !isset($field) ||
$field == '')
{
return -1;
***************
*** 290,294 ****
$result = @mssql_query("select @@identity",
$this->Link_ID);
! if (!$result)
{
return -1;
--- 291,295 ----
$result = @mssql_query("select @@identity",
$this->Link_ID);
! if(!$result)
{
return -1;
***************
*** 299,303 ****
function lock($table, $mode="write")
{
! // /me really, really, really hates locks -
transactions serve just fine
return $this->transaction_begin();
}
--- 300,304 ----
function lock($table, $mode="write")
{
! /* /me really, really, really hates locks -
transactions serve just fine */
return $this->transaction_begin();
}
***************
*** 315,324 ****
$this->Errno = 1;
$this->Error = mssql_get_last_message();
! if ($this->Error == '')
{
$this->Error = "General Error (The MS-SQL
interface did not return a detailed error message).";
}
! if ($this->Halt_On_Error == "no")
{
return;
--- 316,325 ----
$this->Errno = 1;
$this->Error = mssql_get_last_message();
! if($this->Error == '')
{
$this->Error = "General Error (The MS-SQL
interface did not return a detailed error message).";
}
! if($this->Halt_On_Error == "no")
{
return;
***************
*** 327,341 ****
$this->haltmsg($msg);
! if ($file)
{
printf("<br><b>File:</b> %s",$file);
}
! if ($line)
{
printf("<br><b>Line:</b> %s",$line);
}
! if ($this->Halt_On_Error != "report")
{
echo "<p><b>Session halted.</b>";
--- 328,342 ----
$this->haltmsg($msg);
! if($file)
{
printf("<br><b>File:</b> %s",$file);
}
! if($line)
{
printf("<br><b>Line:</b> %s",$line);
}
! if($this->Halt_On_Error != "report")
{
echo "<p><b>Session halted.</b>";
***************
*** 347,351 ****
{
printf("<b>Database error:</b> %s<br>\n", $msg);
! if ($this->Errno != "0" && $this->Error != "()")
{
printf("<b>MS-SQL Error</b>: %s (%s)<br>\n",
$this->Errno, $this->Error);
--- 348,352 ----
{
printf("<b>Database error:</b> %s<br>\n", $msg);
! if($this->Errno != "0" && $this->Error != "()")
{
printf("<b>MS-SQL Error</b>: %s (%s)<br>\n",
$this->Errno, $this->Error);
***************
*** 357,361 ****
$this->query("select name from sysobjects where
type='u' and name != 'dtproperties'");
$i = 0;
! while ($info = @mssql_fetch_row($this->Query_ID))
{
$return[$i]['table_name'] = $info[0];
--- 358,362 ----
$this->query("select name from sysobjects where
type='u' and name != 'dtproperties'");
$i = 0;
! while($info = @mssql_fetch_row($this->Query_ID))
{
$return[$i]['table_name'] = $info[0];
Index: class.db_mysql.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.db_mysql.inc.php,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** class.db_mysql.inc.php 28 Dec 2001 05:25:07 -0000 1.30
--- class.db_mysql.inc.php 10 Feb 2002 12:04:10 -0000 1.31
***************
*** 67,90 ****
{
/* Handle defaults */
! if ('' == $Database)
{
$Database = $this->Database;
}
! if ('' == $Host)
{
$Host = $this->Host;
}
! if ('' == $User)
{
$User = $this->User;
}
! if ('' == $Password)
{
$Password = $this->Password;
}
/* establish connection, select database */
! if ( 0 == $this->Link_ID )
{
! if
($GLOBALS['phpgw_info']['server']['db_persistent'])
{
$this->Link_ID=mysql_pconnect($Host,
$User, $Password);
--- 67,90 ----
{
/* Handle defaults */
! if('' == $Database)
{
$Database = $this->Database;
}
! if('' == $Host)
{
$Host = $this->Host;
}
! if('' == $User)
{
$User = $this->User;
}
! if('' == $Password)
{
$Password = $this->Password;
}
/* establish connection, select database */
! if(0 == $this->Link_ID)
{
!
if($GLOBALS['phpgw_info']['server']['db_persistent'])
{
$this->Link_ID=mysql_pconnect($Host,
$User, $Password);
***************
*** 95,99 ****
}
! if (!$this->Link_ID)
{
$this->halt(($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'')."connect($Host,
$User, \$Password) failed.");
--- 95,99 ----
}
! if(!$this->Link_ID)
{
$this->halt(($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'')."connect($Host,
$User, \$Password) failed.");
***************
*** 101,107 ****
}
! if (address@hidden($Database,$this->Link_ID))
{
! $this->halt("cannot use database
".$this->Database);
return 0;
}
--- 101,107 ----
}
! if(address@hidden($Database,$this->Link_ID))
{
! $this->halt('cannot use database ' .
$this->Database);
return 0;
}
***************
*** 127,131 ****
function db_addslashes($str)
{
! if (!isset($str) || $str == '')
{
return '';
--- 127,131 ----
function db_addslashes($str)
{
! if(!isset($str) || $str == '')
{
return '';
***************
*** 151,161 ****
echo '<b>Warning: limit() is no longer used, use
limit_query()</b>';
! if ($start == 0)
{
! $s = 'limit ' .
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
}
else
{
! $s = "limit $start," .
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
}
return $s;
--- 151,161 ----
echo '<b>Warning: limit() is no longer used, use
limit_query()</b>';
! if($start == 0)
{
! $s = 'LIMIT ' .
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
}
else
{
! $s = "LIMIT $start," .
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
}
return $s;
***************
*** 178,186 ****
* like these: '$db = new db_Subclass;'
*/
! if ($Query_String == '')
{
return 0;
}
! if (!$this->connect())
{
return 0; /* we already complained in connect()
about that. */
--- 178,186 ----
* like these: '$db = new db_Subclass;'
*/
! if($Query_String == '')
{
return 0;
}
! if(!$this->connect())
{
return 0; /* we already complained in connect()
about that. */
***************
*** 188,197 ****
# New query, discard previous result.
! if ($this->Query_ID)
{
$this->free();
}
! if ($this->Debug)
{
printf("Debug: query = %s<br>\n",
$Query_String);
--- 188,197 ----
# New query, discard previous result.
! if($this->Query_ID)
{
$this->free();
}
! if($this->Debug)
{
printf("Debug: query = %s<br>\n",
$Query_String);
***************
*** 202,208 ****
$this->Errno = mysql_errno();
$this->Error = mysql_error();
! if (! $this->Query_ID)
{
! $this->halt("Invalid SQL: ".$Query_String,
$line, $file);
}
--- 202,208 ----
$this->Errno = mysql_errno();
$this->Error = mysql_error();
! if(!$this->Query_ID)
{
! $this->halt('Invalid SQL: ' . $Query_String,
$line, $file);
}
***************
*** 214,223 ****
function limit_query($Query_String, $offset, $line = '', $file
= '', $num_rows = '')
{
! if (! $num_rows)
{
$num_rows =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
}
! if ($offset == 0)
{
$Query_String .= ' LIMIT ' . $num_rows;
--- 214,223 ----
function limit_query($Query_String, $offset, $line = '', $file
= '', $num_rows = '')
{
! if(!$num_rows)
{
$num_rows =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
}
! if($offset == 0)
{
$Query_String .= ' LIMIT ' . $num_rows;
***************
*** 228,232 ****
}
! if ($this->Debug)
{
printf("Debug: limit_query = %s<br>offset=%d,
num_rows=%d<br>\n", $Query_String, $offset, $num_rows);
--- 228,232 ----
}
! if($this->Debug)
{
printf("Debug: limit_query = %s<br>offset=%d,
num_rows=%d<br>\n", $Query_String, $offset, $num_rows);
***************
*** 239,243 ****
function next_record()
{
! if (!$this->Query_ID)
{
$this->halt('next_record called with no query
pending.');
--- 239,243 ----
function next_record()
{
! if(!$this->Query_ID)
{
$this->halt('next_record called with no query
pending.');
***************
*** 251,255 ****
$stat = is_array($this->Record);
! if (!$stat && $this->Auto_Free)
{
$this->free();
--- 251,255 ----
$stat = is_array($this->Record);
! if(!$stat && $this->Auto_Free)
{
$this->free();
***************
*** 262,266 ****
{
$status = @mysql_data_seek($this->Query_ID, $pos);
! if ($status)
{
$this->Row = $pos;
--- 262,266 ----
{
$status = @mysql_data_seek($this->Query_ID, $pos);
! if($status)
{
$this->Row = $pos;
***************
*** 268,273 ****
else
{
! $this->halt("seek($pos) failed: result has
".$this->num_rows()." rows");
! /* half assed attempt to save the day,
* but do not consider this documented or even
* desireable behaviour.
--- 268,273 ----
else
{
! $this->halt("seek($pos) failed: result has " .
$this->num_rows() . ' rows');
! /* half assed attempt to save the day,
* but do not consider this documented or even
* desireable behaviour.
***************
*** 303,307 ****
*/
! if (!isset($table) || $table == '' || !isset($field) ||
$field == '')
{
return -1;
--- 303,307 ----
*/
! if(!isset($table) || $table == '' || !isset($field) ||
$field == '')
{
return -1;
***************
*** 316,325 ****
$this->connect();
! $query = "lock tables ";
! if (is_array($table))
{
! while (list($key,$value)=each($table))
{
! if ($key == "read" && $key!=0)
{
$query .= "$value read, ";
--- 316,325 ----
$this->connect();
! $query = 'LOCK TABLES ';
! if(is_array($table))
{
! while(list($key,$value)=each($table))
{
! if($key == 'read' && $key!=0)
{
$query .= "$value read, ";
***************
*** 337,341 ****
}
$res = @mysql_query($query, $this->Link_ID);
! if (!$res)
{
$this->halt("lock($table, $mode) failed.");
--- 337,341 ----
}
$res = @mysql_query($query, $this->Link_ID);
! if(!$res)
{
$this->halt("lock($table, $mode) failed.");
***************
*** 349,356 ****
$this->connect();
! $res = @mysql_query("unlock tables");
! if (!$res)
{
! $this->halt("unlock() failed.");
return 0;
}
--- 349,356 ----
$this->connect();
! $res = @mysql_query('UNLOCK TABLES');
! if(!$res)
{
! $this->halt('unlock() failed.');
return 0;
}
***************
*** 358,362 ****
}
-
/* public: evaluate the result (size, width) */
function affected_rows()
--- 358,361 ----
***************
*** 386,392 ****
}
! function f($Name, $strip_slashes = "")
{
! if ($strip_slashes || ($this->auto_stripslashes && !
$strip_slashes))
{
return stripslashes($this->Record[$Name]);
--- 385,391 ----
}
! function f($Name, $strip_slashes='')
{
! if($strip_slashes || ($this->auto_stripslashes && !
$strip_slashes))
{
return stripslashes($this->Record[$Name]);
***************
*** 408,415 ****
$this->connect();
! if ($this->lock($this->Seq_Table))
{
/* get sequence number (locked) and increment */
! $q = sprintf("select nextid from %s where
seq_name = '%s'",
$this->Seq_Table,
$seq_name);
--- 407,414 ----
$this->connect();
! if($this->lock($this->Seq_Table))
{
/* get sequence number (locked) and increment */
! $q = sprintf("SELECT nextid FROM %s WHERE
seq_name = '%s'",
$this->Seq_Table,
$seq_name);
***************
*** 418,425 ****
/* No current value, make one */
! if (!is_array($res))
{
$currentid = 0;
! $q = sprintf("insert into %s
values('%s', %s)",
$this->Seq_Table,
$seq_name,
--- 417,424 ----
/* No current value, make one */
! if(!is_array($res))
{
$currentid = 0;
! $q = sprintf("INSERT INTO %s
VALUES('%s', %s)",
$this->Seq_Table,
$seq_name,
***************
*** 429,436 ****
else
{
! $currentid = $res["nextid"];
}
$nextid = $currentid + 1;
! $q = sprintf("update %s set nextid = '%s' where
seq_name = '%s'",
$this->Seq_Table,
$nextid,
--- 428,435 ----
else
{
! $currentid = $res['nextid'];
}
$nextid = $currentid + 1;
! $q = sprintf("UPDATE %s SET nextid = '%s' WHERE
seq_name = '%s'",
$this->Seq_Table,
$nextid,
***************
*** 441,445 ****
else
{
! $this->halt("cannot lock ".$this->Seq_Table." -
has it been created?");
return 0;
}
--- 440,444 ----
else
{
! $this->halt('cannot lock ' . $this->Seq_Table .
' - has it been created?');
return 0;
}
***************
*** 448,452 ****
/* public: return table metadata */
! function metadata($table='',$full=false)
{
$count = 0;
--- 447,451 ----
/* public: return table metadata */
! function metadata($table='',$full=False)
{
$count = 0;
***************
*** 482,492 ****
/* if no $table specified, assume that we are working
with a query */
/* result */
! if ($table)
{
$this->connect();
$id = @mysql_list_fields($this->Database,
$table);
! if (!$id)
{
! $this->halt("Metadata query failed.");
}
}
--- 481,491 ----
/* if no $table specified, assume that we are working
with a query */
/* result */
! if($table)
{
$this->connect();
$id = @mysql_list_fields($this->Database,
$table);
! if(!$id)
{
! $this->halt('Metadata query failed.');
}
}
***************
*** 494,500 ****
{
$id = $this->Query_ID;
! if (!$id)
{
! $this->halt("No query specified.");
}
}
--- 493,499 ----
{
$id = $this->Query_ID;
! if(!$id)
{
! $this->halt('No query specified.');
}
}
***************
*** 503,509 ****
/* made this IF due to performance (one if is faster
than $count if's) */
! if (!$full)
{
! for ($i=0; $i<$count; $i++)
{
$res[$i]['table'] = @mysql_field_table
($id, $i);
--- 502,508 ----
/* made this IF due to performance (one if is faster
than $count if's) */
! if(!$full)
{
! for($i=0; $i<$count; $i++)
{
$res[$i]['table'] = @mysql_field_table
($id, $i);
***************
*** 517,523 ****
{
/* full */
! $res["num_fields"]= $count;
! for ($i=0; $i<$count; $i++)
{
$res[$i]['table'] = @mysql_field_table
($id, $i);
--- 516,522 ----
{
/* full */
! $res['num_fields']= $count;
! for($i=0; $i<$count; $i++)
{
$res[$i]['table'] = @mysql_field_table
($id, $i);
***************
*** 531,535 ****
/* free the result only if we were called on a table */
! if ($table)
{
@mysql_free_result($id);
--- 530,534 ----
/* free the result only if we were called on a table */
! if($table)
{
@mysql_free_result($id);
***************
*** 545,549 ****
$this->Error = @mysql_error($this->Link_ID);
$this->Errno = @mysql_errno($this->Link_ID);
! if ($this->Halt_On_Error == "no")
{
return;
--- 544,548 ----
$this->Error = @mysql_error($this->Link_ID);
$this->Errno = @mysql_errno($this->Link_ID);
! if($this->Halt_On_Error == 'no')
{
return;
***************
*** 551,566 ****
$this->haltmsg($msg);
! if ($file)
{
! printf("<br><b>File:</b> %s",$file);
}
! if ($line)
{
! printf("<br><b>Line:</b> %s",$line);
}
! if ($this->Halt_On_Error != "report")
{
! echo "<p><b>Session halted.</b>";
$GLOBALS['phpgw']->common->phpgw_exit(True);
}
--- 550,565 ----
$this->haltmsg($msg);
! if($file)
{
! printf('<br><b>File:</b> %s',$file);
}
! if($line)
{
! printf('<br><b>Line:</b> %s',$line);
}
! if($this->Halt_On_Error != 'report')
{
! echo '<p><b>Session halted.</b>';
$GLOBALS['phpgw']->common->phpgw_exit(True);
}
***************
*** 570,574 ****
{
printf("<b>Database error:</b> %s<br>\n", $msg);
! if ($this->Errno != "0" && $this->Error != "()")
{
printf("<b>MySQL Error</b>: %s
(%s)<br>\n",$this->Errno,$this->Error);
--- 569,573 ----
{
printf("<b>Database error:</b> %s<br>\n", $msg);
! if($this->Errno != '0' && $this->Error != '()')
{
printf("<b>MySQL Error</b>: %s
(%s)<br>\n",$this->Errno,$this->Error);
***************
*** 578,584 ****
function table_names()
{
! $this->query("SHOW TABLES");
$i=0;
! while ($info=mysql_fetch_row($this->Query_ID))
{
$return[$i]['table_name'] = $info[0];
--- 577,583 ----
function table_names()
{
! $this->query('SHOW TABLES');
$i=0;
! while($info=mysql_fetch_row($this->Query_ID))
{
$return[$i]['table_name'] = $info[0];
***************
*** 596,600 ****
}
! function create_database($adminname = '', $adminpasswd = '')
{
$currentUser = $this->User;
--- 595,599 ----
}
! function create_database($adminname='', $adminpasswd='')
{
$currentUser = $this->User;
***************
*** 602,614 ****
$currentDatabase = $this->Database;
! if ($adminname != '')
{
$this->User = $adminname;
$this->Password = $adminpasswd;
! $this->Database = "mysql";
}
$this->disconnect();
! $this->query("CREATE DATABASE $currentDatabase");
! $this->query("grant all on $currentDatabase.* to
address@hidden identified by '$currentPassword'");
$this->disconnect();
--- 601,613 ----
$currentDatabase = $this->Database;
! if($adminname != '')
{
$this->User = $adminname;
$this->Password = $adminpasswd;
! $this->Database = 'mysql';
}
$this->disconnect();
! $this->query('CREATE DATABASE ' . $currentDatabase);
! $this->query("GRANT all on $currentDatabase.* to
address@hidden IDENTIFIED BY '$currentPassword'");
$this->disconnect();
Index: class.db_oracle.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.db_oracle.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** class.db_oracle.inc.php 28 Sep 2001 21:27:40 -0000 1.6
--- class.db_oracle.inc.php 10 Feb 2002 12:04:10 -0000 1.7
***************
*** 46,50 ****
var $revision = '1.2';
! var $Halt_On_Error = 'yes'; ## 'yes' (halt with message), 'no'
(ignore errors quietly), 'report' (ignore errror, but spit a warning)
/* public: constructor */
--- 46,50 ----
var $revision = '1.2';
! var $Halt_On_Error = 'yes'; /* 'yes' (halt with message), 'no'
(ignore errors quietly), 'report' (ignore errror, but spit a warning) */
/* public: constructor */
***************
*** 67,77 ****
function connect()
{
! ## see above why we do this
! if ($this->OraPutEnv)
{
PutEnv("ORACLE_SID=$this->Database");
PutEnv("ORACLE_HOME=$this->Home");
}
! if ( 0 == $this->Link_ID )
{
if($this->Debug)
--- 67,77 ----
function connect()
{
! /* see above for why we do this */
! if($this->OraPutEnv)
{
PutEnv("ORACLE_SID=$this->Database");
PutEnv("ORACLE_HOME=$this->Home");
}
! if(0 == $this->Link_ID)
{
if($this->Debug)
***************
*** 122,126 ****
printf("<br>connect() Link_ID:
$this->Link_ID<br>\n");
}
! if (!$this->Link_ID)
{
$this->halt('connect() Link-ID == false
'
--- 122,126 ----
printf("<br>connect() Link_ID:
$this->Link_ID<br>\n");
}
! if(!$this->Link_ID)
{
$this->halt('connect() Link-ID == false
'
***************
*** 139,161 ****
}
! ## In order to increase the # of cursors per system/user go
edit the
! ## init.ora file and increase the max_open_cursors parameter.
Yours is on
! ## the default value, 100 per user.
! ## We tried to change the behaviour of query() in a way, that
it tries
! ## to safe cursors, but on the other side be carefull with
this, that you
! ## don't use an old result.
! ##
! ## You can also make extensive use of ->disconnect()!
! ## The unused QueryIDs will be recycled sometimes.
function query($Query_String)
{
/* No empty queries, please, since PHP4 chokes on them.
*/
! if ($Query_String == '')
{
/* The empty query string is passed on from the
constructor,
! * when calling the class without a query, e.g.
in situations
! * like these: '$db = new DB_Sql_Subclass;'
! */
return 0;
}
--- 139,163 ----
}
! /*
! * In order to increase the # of cursors per system/user go
edit the
! * init.ora file and increase the max_open_cursors parameter.
Yours is on
! * the default value, 100 per user.
! * We tried to change the behaviour of query() in a way, that
it tries
! * to safe cursors, but on the other side be carefull with
this, that you
! * don't use an old result.
! *
! * You can also make extensive use of ->disconnect()!
! * The unused QueryIDs will be recycled sometimes.
! */
function query($Query_String)
{
/* No empty queries, please, since PHP4 chokes on them.
*/
! if($Query_String == '')
{
/* The empty query string is passed on from the
constructor,
! * when calling the class without a query, e.g.
in situations
! * like these: '$db = new DB_Sql_Subclass;'
! */
return 0;
}
***************
*** 163,167 ****
$this->lastQuery=$Query_String;
! if (!$this->Query_ID)
{
$this->Query_ID = ora_open($this->Link_ID);
--- 165,169 ----
$this->lastQuery=$Query_String;
! if(!$this->Query_ID)
{
$this->Query_ID = ora_open($this->Link_ID);
***************
*** 179,183 ****
$this->halt("<BR>ora_parse()
failed:<BR>$Query_String<BR><small>Snap & paste this to sqlplus!</SMALL>");
}
! elseif (address@hidden($this->Query_ID))
{
$this->Errno=ora_errorcode($this->Query_ID);
--- 181,185 ----
$this->halt("<BR>ora_parse()
failed:<BR>$Query_String<BR><small>Snap & paste this to sqlplus!</SMALL>");
}
! elseif(address@hidden($this->Query_ID))
{
$this->Errno=ora_errorcode($this->Query_ID);
***************
*** 198,205 ****
function next_record()
{
! if (!$this->no_next_fetch &&
0 == ora_fetch($this->Query_ID))
{
! if ($this->Debug)
{
printf("<br>next_record(): ID: %d,Rows:
%d<br>\n",
--- 200,207 ----
function next_record()
{
! if(!$this->no_next_fetch &&
0 == ora_fetch($this->Query_ID))
{
! if($this->Debug)
{
printf("<br>next_record(): ID: %d,Rows:
%d<br>\n",
***************
*** 210,223 ****
$errno=ora_errorcode($this->Query_ID);
if(1403 == $errno)
! { # 1043 means no more records found
$this->Errno = 0;
$this->Error = '';
$this->disconnect();
! $stat=0;
}
else
{
! $this->Error=ora_error($this->Query_ID);
! $this->Errno=$errno;
if($this->Debug)
{
--- 212,226 ----
$errno=ora_errorcode($this->Query_ID);
if(1403 == $errno)
! {
! /* 1043 means no more records found */
$this->Errno = 0;
$this->Error = '';
$this->disconnect();
! $stat = 0;
}
else
{
! $this->Error =
ora_error($this->Query_ID);
! $this->Errno = $errno;
if($this->Debug)
{
***************
*** 226,264 ****
$this->Error);
}
! $stat=0;
}
}
else
{
! $this->no_next_fetch=false;
for($ix=0;$ix<ora_numcols($this->Query_ID);$ix++)
{
$col=strtolower(ora_columnname($this->Query_ID,$ix));
$value=ora_getcolumn($this->Query_ID,$ix);
! $this->Record[ "$col" ] = $value;
! # echo"<b>[$col]</b>: $value <br>\n";
}
! $stat=1;
}
return $stat;
}
! ## seek() works only for $pos - 1 and $pos
! ## Perhaps I make a own implementation, but my
! ## opinion is, that this should be done by PHP3
function seek($pos)
{
if($this->Row - 1 == $pos)
{
! $this->no_next_fetch=true;
}
! elseif ($this->Row == $pos )
{
! ## do nothing
}
else
{
! $this->halt("Invalid seek(): Position is cannot
be handled by API.<BR>".
! "Difference too big. Wanted: $pos Current pos:
$this->Row");
}
if($Debug)
--- 229,269 ----
$this->Error);
}
! $stat = 0;
}
}
else
{
! $this->no_next_fetch = False;
for($ix=0;$ix<ora_numcols($this->Query_ID);$ix++)
{
$col=strtolower(ora_columnname($this->Query_ID,$ix));
$value=ora_getcolumn($this->Query_ID,$ix);
! $this->Record["$col"] = $value;
! /* echo"<b>[$col]</b>: $value <br>\n";
*/
}
! $stat = 1;
}
return $stat;
}
! /*
! * seek() works only for $pos - 1 and $pos
! * Perhaps I make a own implementation, but my
! * opinion is, that this should be done by PHP3
! */
function seek($pos)
{
if($this->Row - 1 == $pos)
{
! $this->no_next_fetch = True;
}
! elseif($this->Row == $pos)
{
! /* do nothing */
}
else
{
! $this->halt('Invalid seek(): Position cannot be
handled by API.<BR>'
! . "Difference too big. Wanted: $pos
Current pos: $this->Row");
}
if($Debug)
***************
*** 269,275 ****
}
! function lock($table, $mode = 'write')
{
! if ($mode == 'write')
{
$result = ora_do($this->Link_ID, "lock table
$table in row exclusive mode");
--- 274,280 ----
}
! function lock($table, $mode='write')
{
! if($mode == 'write')
{
$result = ora_do($this->Link_ID, "lock table
$table in row exclusive mode");
***************
*** 327,346 ****
$this->connect();
! ## This is a RIGHT OUTER JOIN: '(+)', if you want to
see, what
! ## this query results try the following:
! ## $table = new Table; $db = new my_DB_Sql; # you have
to make
! ## # your own class
! ## $table->show_results($db->query(see query vvvvvv))
! ##
! $this->query("SELECT
T.table_name,T.column_name,T.data_type,".
!
"T.data_length,T.data_precision,T.data_scale,T.nullable,".
! "T.char_col_decl_length,I.index_name".
! " FROM ALL_TAB_COLUMNS T,ALL_IND_COLUMNS I".
! " WHERE T.column_name=I.column_name (+)".
! " AND T.table_name=I.table_name (+)".
! " AND T.table_name=UPPER('$table') ORDER BY
T.column_id");
$i=0;
! while ($this->next_record())
{
$res[$i]['table'] = $this->Record[table_name];
--- 332,353 ----
$this->connect();
! /*
! * This is a RIGHT OUTER JOIN: '(+)', if you want to
see, what
! * this query results try the following:
! * $table = new Table; $db = new my_DB_Sql;
! * you have to make your own class
! * $table->show_results($db->query(see query vvvvvv))
! *
! */
! $this->query("SELECT
T.table_name,T.column_name,T.data_type,"
! .
"T.data_length,T.data_precision,T.data_scale,T.nullable,"
! . "T.char_col_decl_length,I.index_name"
! . " FROM ALL_TAB_COLUMNS T,ALL_IND_COLUMNS I"
! . " WHERE T.column_name=I.column_name (+)"
! . " AND T.table_name=I.table_name (+)"
! . " AND T.table_name=UPPER('$table') ORDER BY
T.column_id");
$i=0;
! while($this->next_record())
{
$res[$i]['table'] = $this->Record[table_name];
***************
*** 348,352 ****
$res[$i]['type'] = $this->Record[data_type];
$res[$i]['len'] = $this->Record[data_length];
! if ($this->Record[index_name])
{
$res[$i]['flags'] = 'INDEX ';
--- 355,359 ----
$res[$i]['type'] = $this->Record[data_type];
$res[$i]['len'] = $this->Record[data_length];
! if($this->Record[index_name])
{
$res[$i]['flags'] = 'INDEX ';
***************
*** 355,359 ****
$res[$i]['format']=
(int)$this->Record['data_precision'].','.
(int)$this->Record[data_scale];
! if ('0,0'==$res[$i]['format'])
{
$res[$i]['format']='';
--- 362,366 ----
$res[$i]['format']=
(int)$this->Record['data_precision'].','.
(int)$this->Record[data_scale];
! if('0,0'==$res[$i]['format'])
{
$res[$i]['format']='';
***************
*** 361,365 ****
$res[$i]['index'] = $this->Record[index_name];
$res[$i]['chars'] =
$this->Record[char_col_decl_length];
! if ($full)
{
$j=$res[$i]['name'];
--- 368,372 ----
$res[$i]['index'] = $this->Record[index_name];
$res[$i]['chars'] =
$this->Record[char_col_decl_length];
! if($full)
{
$j=$res[$i]['name'];
***************
*** 367,371 ****
$res['meta'][strtoupper($j)] = $i;
}
! if ($full)
{
$res['meta'][$res[$i]['name']] = $i;
--- 374,378 ----
$res['meta'][strtoupper($j)] = $i;
}
! if($full)
{
$res['meta'][$res[$i]['name']] = $i;
***************
*** 373,388 ****
$i++;
}
! if ($full)
{
$res['num_fields']=$i;
}
! # $this->disconnect();
return $res;
}
! ## THIS FUNCTION IS UNSTESTED!
function affected_rows()
{
! if ($Debug)
{
echo '<BR>Debug: affected_rows='.
ora_numrows($this->Query_ID).'<BR>';
--- 380,395 ----
$i++;
}
! if($full)
{
$res['num_fields']=$i;
}
! /* $this->disconnect(); */
return $res;
}
! /* THIS FUNCTION IS UNSTESTED! */
function affected_rows()
{
! if($Debug)
{
echo '<BR>Debug: affected_rows='.
ora_numrows($this->Query_ID).'<BR>';
***************
*** 391,409 ****
}
! ## Known bugs: It will not work for SELECT DISTINCT and any
! ## other constructs which are depending on the resulting rows.
! ## So you *really need* to check every query you make, if it
! ## will work with it.
! ##
! ## Also, for a qualified replacement you need to parse the
! ## selection, cause this will fail: 'SELECT id, from FROM ...').
! ## 'FROM' is - as far as I know a keyword in Oracle, so it can
! ## only be used in this way. But you have been warned.
function num_rows()
{
$curs=ora_open($this->Link_ID);
! ## this is the important part and it is also the HACK!
! if
(eregi("^[[:space:]]*SELECT[[:space:]]",$this->lastQuery) )
{
$from_pos =
strpos(strtoupper($this->lastQuery),'FROM');
--- 398,418 ----
}
! /*
! * Known bugs: It will not work for SELECT DISTINCT and any
! * other constructs which are depending on the resulting rows.
! * So you *really need* to check every query you make, if it
! * will work with it.
! *
! * Also, for a qualified replacement you need to parse the
! * selection, cause this will fail: 'SELECT id, from FROM ...').
! * 'FROM' is - as far as I know a keyword in Oracle, so it can
! * only be used in this way. But you have been warned.
! */
function num_rows()
{
$curs=ora_open($this->Link_ID);
! /* this is the important part and it is also the HACK!
*/
!
if(eregi("^[[:space:]]*SELECT[[:space:]]",$this->lastQuery) )
{
$from_pos =
strpos(strtoupper($this->lastQuery),'FROM');
***************
*** 413,417 ****
ORA_exec($curs);
ORA_fetch($curs);
! if ($Debug)
{
echo '<BR>Debug: num_rows='.
ORA_getcolumn($curs,0).'<BR>';
--- 422,426 ----
ORA_exec($curs);
ORA_fetch($curs);
! if($Debug)
{
echo '<BR>Debug: num_rows='.
ORA_getcolumn($curs,0).'<BR>';
***************
*** 464,468 ****
if(address@hidden($Query_ID,"SELECT $seq_name.NEXTVAL
FROM DUAL"))
{
! // There is no such sequence yet, then create it
if(address@hidden($Query_ID,"CREATE SEQUENCE
$seq_name") ||
address@hidden($Query_ID))
--- 473,477 ----
if(address@hidden($Query_ID,"SELECT $seq_name.NEXTVAL
FROM DUAL"))
{
! /* There is no such sequence yet, then create
it */
if(address@hidden($Query_ID,"CREATE SEQUENCE
$seq_name") ||
address@hidden($Query_ID))
***************
*** 473,481 ****
@ora_parse($Query_ID,"SELECT $seq_name.NEXTVAL
FROM DUAL");
}
! if (address@hidden($Query_ID))
{
$this->halt("<BR>ora_exec() failed:<BR>nextID
function");
}
! if (@ora_fetch($Query_ID) )
{
$next_id = ora_getcolumn($Query_ID, 0);
--- 482,490 ----
@ora_parse($Query_ID,"SELECT $seq_name.NEXTVAL
FROM DUAL");
}
! if(address@hidden($Query_ID))
{
$this->halt("<BR>ora_exec() failed:<BR>nextID
function");
}
! if(@ora_fetch($Query_ID) )
{
$next_id = ora_getcolumn($Query_ID, 0);
***************
*** 485,489 ****
$next_id = 0;
}
! if ( Query_ID > 0 )
{
ora_close(Query_ID);
--- 494,498 ----
$next_id = 0;
}
! if($Query_ID > 0)
{
ora_close(Query_ID);
***************
*** 498,508 ****
echo "Debug: Disconnecting
$this->Query_ID...<br>\n";
}
! if ( $this->Query_ID < 1 )
{
echo "<B>Warning</B>: disconnect(): Cannot free
ID $this->Query_ID\n";
! # return();
}
ora_close($this->Query_ID);
! $this->Query_ID=0;
}
--- 507,517 ----
echo "Debug: Disconnecting
$this->Query_ID...<br>\n";
}
! if($this->Query_ID < 1)
{
echo "<B>Warning</B>: disconnect(): Cannot free
ID $this->Query_ID\n";
! /* return(); */
}
ora_close($this->Query_ID);
! $this->Query_ID = 0;
}
***************
*** 510,514 ****
function halt($msg)
{
! if ($this->Halt_On_Error == 'no')
{
return;
--- 519,523 ----
function halt($msg)
{
! if($this->Halt_On_Error == 'no')
{
return;
***************
*** 517,521 ****
$this->haltmsg($msg);
! if ($this->Halt_On_Error != 'report')
{
die('Session halted.');
--- 526,530 ----
$this->haltmsg($msg);
! if($this->Halt_On_Error != 'report')
{
die('Session halted.');
***************
*** 535,540 ****
$this->connect();
$this->query('SELECT table_name,tablespace_name FROM
user_tables');
! $i=0;
! while ($this->next_record())
{
$info[$i]['table_name'] =
$this->Record['table_name'];
--- 544,549 ----
$this->connect();
$this->query('SELECT table_name,tablespace_name FROM
user_tables');
! $i = 0;
! while($this->next_record())
{
$info[$i]['table_name'] =
$this->Record['table_name'];
Index: class.db_pgsql.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.db_pgsql.inc.php,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** class.db_pgsql.inc.php 28 Dec 2001 06:02:30 -0000 1.30
--- class.db_pgsql.inc.php 10 Feb 2002 12:04:10 -0000 1.31
***************
*** 25,29 ****
var $auto_stripslashes = False;
! /* "yes" (halt with message), "no" (ignore errors quietly),
"report" (ignore errror, but spit a warning) */
var $Halt_On_Error = 'yes';
--- 25,29 ----
var $auto_stripslashes = False;
! /* 'yes' (halt with message), 'no' (ignore errors quietly),
'report' (ignore errror, but spit a warning) */
var $Halt_On_Error = 'yes';
***************
*** 41,48 ****
var $Auto_Free = 0;
! // PostgreSQL changed somethings from 6.x -> 7.x
var $db_version;
! // For our error handling
var $xmlrpc = False;
var $soap = False;
--- 41,48 ----
var $Auto_Free = 0;
! /* PostgreSQL changed some things from 6.x -> 7.x */
var $db_version;
! /* For our error handling */
var $xmlrpc = False;
var $soap = False;
***************
*** 61,70 ****
$this->query($query);
! if (ereg('xmlrpc.php',$GLOBALS['PHP_SELF']))
{
$this->xmlrpc = True;
}
! if (ereg('soap.php',$GLOBALS['PHP_SELF']))
{
$this->soap = True;
--- 61,70 ----
$this->query($query);
! if(ereg('xmlrpc.php',$GLOBALS['PHP_SELF']))
{
$this->xmlrpc = True;
}
! if(ereg('soap.php',$GLOBALS['PHP_SELF']))
{
$this->soap = True;
***************
*** 74,78 ****
function connect()
{
! if (0 == $this->Link_ID)
{
$cstr = 'dbname=' . $this->Database
--- 74,78 ----
function connect()
{
! if(0 == $this->Link_ID)
{
$cstr = 'dbname=' . $this->Database
***************
*** 81,85 ****
. $this->ifadd($this->User, 'user=')
. $this->ifadd("'".$this->Password."'",
'password=');
! if
($GLOBALS['phpgw_info']['server']['db_persistent'])
{
$this->Link_ID=pg_pconnect($cstr);
--- 81,85 ----
. $this->ifadd($this->User, 'user=')
. $this->ifadd("'".$this->Password."'",
'password=');
!
if($GLOBALS['phpgw_info']['server']['db_persistent'])
{
$this->Link_ID=pg_pconnect($cstr);
***************
*** 90,94 ****
}
! if (! $this->Link_ID)
{
$this->halt('Link-ID == false,
'.($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'').'connect failed');
--- 90,94 ----
}
! if(!$this->Link_ID)
{
$this->halt('Link-ID == false,
'.($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'').'connect failed');
***************
*** 96,100 ****
else
{
! $this->query("select
version()",__LINE__,__FILE__);
$this->next_record();
--- 96,100 ----
else
{
! $this->query('SELECT
version()',__LINE__,__FILE__);
$this->next_record();
***************
*** 109,113 ****
{
$db_version = $this->db_version;
! if (floor($db_version) == 6)
{
return $this->to_timestamp_6($epoch);
--- 109,113 ----
{
$db_version = $this->db_version;
! if(floor($db_version) == 6)
{
return $this->to_timestamp_6($epoch);
***************
*** 121,125 ****
function from_timestamp($timestamp)
{
! if (floor($this->db_version) == 6)
{
return $this->from_timestamp_6($timestamp);
--- 121,125 ----
function from_timestamp($timestamp)
{
! if(floor($this->db_version) == 6)
{
return $this->from_timestamp_6($timestamp);
***************
*** 131,135 ****
}
! // For PostgreSQL 6.x
function to_timestamp_6($epoch)
{
--- 131,135 ----
}
! /* For PostgreSQL 6.x */
function to_timestamp_6($epoch)
{
***************
*** 137,141 ****
}
! // For PostgreSQL 6.x
function from_timestamp_6($timestamp)
{
--- 137,141 ----
}
! /* For PostgreSQL 6.x */
function from_timestamp_6($timestamp)
{
***************
*** 143,163 ****
}
! // For PostgreSQL 7.x
function to_timestamp_7($epoch)
{
! // This needs the GMT offset!
return date('Y-m-d H:i:s-00',$epoch);
}
! // For PostgreSQL 7.x
function from_timestamp_7($timestamp)
{
ereg('([0-9]{4})-([0-9]{2})-([0-9]{2})
([0-9]{2}):([0-9]{2}):([0-9]{2})',$timestamp,$parts);
!
return
mktime($parts[4],$parts[5],$parts[6],$parts[2],$parts[3],$parts[1]);
}
-
-
function limit($start)
{
--- 143,161 ----
}
! /* For PostgreSQL 7.x */
function to_timestamp_7($epoch)
{
! /* This needs the GMT offset! */
return date('Y-m-d H:i:s-00',$epoch);
}
! /* For PostgreSQL 7.x */
function from_timestamp_7($timestamp)
{
ereg('([0-9]{4})-([0-9]{2})-([0-9]{2})
([0-9]{2}):([0-9]{2}):([0-9]{2})',$timestamp,$parts);
!
return
mktime($parts[4],$parts[5],$parts[6],$parts[2],$parts[3],$parts[1]);
}
function limit($start)
{
***************
*** 166,174 ****
if ($start == 0)
{
! $s = 'limit ' .
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
}
else
{
! $s = 'limit ' .
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] . ',' .
$start;
}
return $s;
--- 164,172 ----
if ($start == 0)
{
! $s = 'LIMIT ' .
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
}
else
{
! $s = 'LIMIT ' .
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] . ',' .
$start;
}
return $s;
***************
*** 183,187 ****
function db_addslashes($str)
{
! if (!IsSet($str) || $str == '')
{
return '';
--- 181,185 ----
function db_addslashes($str)
{
! if(!isset($str) || $str == '')
{
return '';
***************
*** 199,203 ****
* like these: '$db = new db_Subclass;'
*/
! if ($Query_String == '')
{
return 0;
--- 197,201 ----
* like these: '$db = new db_Subclass;'
*/
! if($Query_String == '')
{
return 0;
***************
*** 213,217 ****
$this->Error = pg_ErrorMessage($this->Link_ID);
$this->Errno = ($this->Error == '') ? 0 : 1;
! if (! $this->Query_ID)
{
$this->halt('Invalid SQL: ' . $Query_String,
$line, $file);
--- 211,215 ----
$this->Error = pg_ErrorMessage($this->Link_ID);
$this->Errno = ($this->Error == '') ? 0 : 1;
! if(!$this->Query_ID)
{
$this->halt('Invalid SQL: ' . $Query_String,
$line, $file);
***************
*** 224,233 ****
function limit_query($Query_String, $offset, $line = '', $file
= '', $num_rows = '')
{
! if (! $num_rows)
{
$num_rows =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
}
! if ($offset == 0)
{
$Query_String .= ' LIMIT ' . $num_rows;
--- 222,231 ----
function limit_query($Query_String, $offset, $line = '', $file
= '', $num_rows = '')
{
! if(!$num_rows)
{
$num_rows =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
}
! if($offset == 0)
{
$Query_String .= ' LIMIT ' . $num_rows;
***************
*** 238,242 ****
}
! if ($this->Debug)
{
printf("Debug: limit_query = %s<br>offset=%d,
num_rows=%d<br>\n", $Query_String, $offset, $num_rows);
--- 236,240 ----
}
! if($this->Debug)
{
printf("Debug: limit_query = %s<br>offset=%d,
num_rows=%d<br>\n", $Query_String, $offset, $num_rows);
***************
*** 246,250 ****
}
! // public: discard the query result
function free()
{
--- 244,248 ----
}
! /* public: discard the query result */
function free()
{
***************
*** 261,265 ****
$stat = is_array($this->Record);
! if (!$stat && $this->Auto_Free)
{
pg_freeresult($this->Query_ID);
--- 259,263 ----
$stat = is_array($this->Record);
! if(!$stat && $this->Auto_Free)
{
pg_freeresult($this->Query_ID);
***************
*** 281,285 ****
function transaction_commit()
{
! if (! $this->Errno)
{
return pg_Exec($this->Link_ID,'commit');
--- 279,283 ----
function transaction_commit()
{
! if(!$this->Errno)
{
return pg_Exec($this->Link_ID,'commit');
***************
*** 304,308 ****
* conditional code to the apps.
*/
! if (!isset($table) || $table == '' || !isset($field) ||
$field == '')
{
return -1;
--- 302,306 ----
* conditional code to the apps.
*/
! if(!isset($table) || $table == '' || !isset($field) ||
$field == '')
{
return -1;
***************
*** 310,320 ****
$oid = pg_getlastoid($this->Query_ID);
! if ($oid == -1)
{
return -1;
}
! $result = @pg_Exec($this->Link_ID, "select $field from
$table where oid=$oid");
! if (!$result)
{
return -1;
--- 308,318 ----
$oid = pg_getlastoid($this->Query_ID);
! if($oid == -1)
{
return -1;
}
! $result = @pg_Exec($this->Link_ID, "SELECT $field FROM
$table WHERE oid=$oid");
! if(!$result)
{
return -1;
***************
*** 323,327 ****
$Record = @pg_fetch_array($result, 0);
@pg_freeresult($result);
! if (!is_array($Record)) /* OID not found? */
{
return -1;
--- 321,325 ----
$Record = @pg_fetch_array($result, 0);
@pg_freeresult($result);
! if(!is_array($Record)) /* OID not found? */
{
return -1;
***************
*** 331,343 ****
}
! function lock($table, $mode = 'write')
{
$result = $this->transaction_begin();
! if ($mode == 'write')
{
! if (is_array($table))
{
! while ($t = each($table))
{
$result =
pg_Exec($this->Link_ID,'lock table ' . $t[1] . ' in share mode');
--- 329,341 ----
}
! function lock($table, $mode='write')
{
$result = $this->transaction_begin();
! if($mode == 'write')
{
! if(is_array($table))
{
! while($t = each($table))
{
$result =
pg_Exec($this->Link_ID,'lock table ' . $t[1] . ' in share mode');
***************
*** 368,375 ****
$this->connect();
! if ($this->lock($this->Seq_Table))
{
/* get sequence number (locked) and increment */
! $q = sprintf("select nextid from %s where
seq_name = '%s'",
$this->Seq_Table,
$seq_name);
--- 366,373 ----
$this->connect();
! if($this->lock($this->Seq_Table))
{
/* get sequence number (locked) and increment */
! $q = sprintf("SELECT nextid FROM %s WHERE
seq_name = '%s'",
$this->Seq_Table,
$seq_name);
***************
*** 378,385 ****
/* No current value, make one */
! if (!is_array($res))
{
$currentid = 0;
! $q = sprintf("insert into %s
values('%s', %s)",
$this->Seq_Table,
$seq_name,
--- 376,383 ----
/* No current value, make one */
! if(!is_array($res))
{
$currentid = 0;
! $q = sprintf("INSERT INTO %s
VALUES('%s', %s)",
$this->Seq_Table,
$seq_name,
***************
*** 392,396 ****
}
$nextid = $currentid + 1;
! $q = sprintf("update %s set nextid = '%s' where
seq_name = '%s'",
$this->Seq_Table,
$nextid,
--- 390,394 ----
}
$nextid = $currentid + 1;
! $q = sprintf("UPDATE %s SET nextid = '%s' WHERE
seq_name = '%s'",
$this->Seq_Table,
$nextid,
***************
*** 414,419 ****
$this->connect();
! $id = pg_exec($this->Link_ID, "select * from $table");
! if ($id < 0)
{
$this->Error = pg_ErrorMessage($id);
--- 412,417 ----
$this->connect();
! $id = pg_exec($this->Link_ID, "SELECT * FROM $table");
! if($id < 0)
{
$this->Error = pg_ErrorMessage($id);
***************
*** 423,432 ****
$count = pg_NumFields($id);
! for ($i=0; $i<$count; $i++)
{
$res[$i]['table'] = $table;
! $res[$i]['name'] = pg_FieldName ($id, $i);
! $res[$i]['type'] = pg_FieldType ($id, $i);
! $res[$i]['len'] = pg_FieldSize ($id, $i);
$res[$i]['flags'] = '';
}
--- 421,430 ----
$count = pg_NumFields($id);
! for($i=0; $i<$count; $i++)
{
$res[$i]['table'] = $table;
! $res[$i]['name'] = pg_FieldName($id, $i);
! $res[$i]['type'] = pg_FieldType($id, $i);
! $res[$i]['len'] = pg_FieldSize($id, $i);
$res[$i]['flags'] = '';
}
***************
*** 463,467 ****
function f($Name,$strip_slashes = '')
{
! if ($strip_slashes || ($this->auto_stripslashes && !
$strip_slashes))
{
return stripslashes($this->Record[$Name]);
--- 461,465 ----
function f($Name,$strip_slashes = '')
{
! if($strip_slashes || ($this->auto_stripslashes && !
$strip_slashes))
{
return stripslashes($this->Record[$Name]);
***************
*** 480,484 ****
function halt($msg, $line = '', $file = '')
{
! if ($this->Halt_On_Error == 'no')
{
return;
--- 478,482 ----
function halt($msg, $line = '', $file = '')
{
! if($this->Halt_On_Error == 'no')
{
return;
***************
*** 489,493 ****
! if ($this->xmlrpc || $this->soap)
{
$s = sprintf("Database error: %s\n", $msg);
--- 487,491 ----
! if($this->xmlrpc || $this->soap)
{
$s = sprintf("Database error: %s\n", $msg);
***************
*** 500,530 ****
}
! if ($file)
{
! if ($this->xmlrpc || $this->soap)
{
! $s .= sprintf("File: %s\n",$file);
}
else
{
! $s .= sprintf("<br><b>File:</b>
%s",$file);
}
}
! if ($line)
{
! if ($this->xmlrpc || $this->soap)
{
! $s .= sprintf("Line: %s\n",$line);
}
else
{
! $s .= sprintf("<br><b>Line:</b>
%s",$line);
}
}
! if ($this->Halt_On_Error == 'yes')
{
! if (! $this->xmlrpc && ! $this->soap)
{
$s .= '<p><b>Session halted.</b>';
--- 498,528 ----
}
! if($file)
{
! if($this->xmlrpc || $this->soap)
{
! $s .= sprintf("File: %s\n",$file);
}
else
{
! $s .= sprintf('<br><b>File:</b>
%s',$file);
}
}
! if($line)
{
! if($this->xmlrpc || $this->soap)
{
! $s .= sprintf("Line: %s\n",$line);
}
else
{
! $s .= sprintf("<br><b>Line:</b>
%s",$line);
}
}
! if($this->Halt_On_Error == 'yes')
{
! if(!$this->xmlrpc && !$this->soap)
{
$s .= '<p><b>Session halted.</b>';
***************
*** 532,540 ****
}
! if ($this->xmlrpc)
{
xmlrpcfault($s);
}
! elseif ($this->soap)
{
--- 530,538 ----
}
! if($this->xmlrpc)
{
xmlrpcfault($s);
}
! elseif($this->soap)
{
***************
*** 549,555 ****
function table_names()
{
! $this->query("select relname from pg_class where
relkind = 'r' and not relname like 'pg_%'");
$i=0;
! while ($this->next_record())
{
$return[$i]['table_name']= $this->f(0);
--- 547,553 ----
function table_names()
{
! $this->query("SELECT relname FROM pg_class WHERE
relkind = 'r' AND NOT relname LIKE 'pg_%'");
$i=0;
! while($this->next_record())
{
$return[$i]['table_name']= $this->f(0);
***************
*** 565,569 ****
$this->query("SELECT relname FROM pg_class WHERE NOT
relname ~ 'pg_.*' AND relkind ='i' ORDER BY relname");
$i=0;
! while ($this->next_record())
{
$return[$i]['index_name']= $this->f(0);
--- 563,567 ----
$this->query("SELECT relname FROM pg_class WHERE NOT
relname ~ 'pg_.*' AND relkind ='i' ORDER BY relname");
$i=0;
! while($this->next_record())
{
$return[$i]['index_name']= $this->f(0);
***************
*** 581,585 ****
$currentDatabase = $this->Database;
! if ($adminname != "")
{
$this->User = $adminname;
--- 579,583 ----
$currentDatabase = $this->Database;
! if($adminname != '')
{
$this->User = $adminname;
***************
*** 587,591 ****
}
! if (! $this->Host)
{
system('createdb ' . $currentDatabase, $outval);
--- 585,589 ----
}
! if(!$this->Host)
{
system('createdb ' . $currentDatabase, $outval);
***************
*** 599,604 ****
{
/* either the rights r not available or the
postmaster is not running .... */
! echo 'database creation failure <BR>';
! echo 'please setup the postreSQL database
manually<BR>';
}
--- 597,602 ----
{
/* either the rights r not available or the
postmaster is not running .... */
! echo 'Database creation failure <BR>';
! echo 'Please setup the postreSQL database
manually<BR>';
}
Index: class.db_sybase.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.db_sybase.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** class.db_sybase.inc.php 29 Sep 2001 00:25:58 -0000 1.6
--- class.db_sybase.inc.php 10 Feb 2002 12:04:10 -0000 1.7
***************
*** 30,49 ****
var $Row;
! var $Auto_Free = 0; ## Set this to 1 for automatic
sybase_free_result()
function connect()
{
! if ( 0 == $this->Link_ID )
{
! if
($GLOBALS['phpgw_info']['server']['db_persistent'])
{
!
$this->Link_ID=sybase_pconnect($this->Host,$this->User,$this->Password);
}
else
{
!
$this->Link_ID=sybase_connect($this->Host,$this->User,$this->Password);
}
}
! if (!$this->Link_ID)
{
$this->halt('Link-ID == false,
'.($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'')..'connect failed');
--- 30,49 ----
var $Row;
! var $Auto_Free = 0; /* Set this to 1 for automatic
sybase_free_result() */
function connect()
{
! if(0 == $this->Link_ID)
{
!
if($GLOBALS['phpgw_info']['server']['db_persistent'])
{
! $this->Link_ID =
sybase_pconnect($this->Host,$this->User,$this->Password);
}
else
{
! $this->Link_ID =
sybase_connect($this->Host,$this->User,$this->Password);
}
}
! if(!$this->Link_ID)
{
$this->halt('Link-ID == false,
'.($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'')..'connect failed');
***************
*** 59,67 ****
$this->connect();
! # printf("Debug: query = %s<br>\n", $Query_String);
$this->Query_ID =
sybase_query($Query_String,$this->Link_ID);
$this->Row = 0;
! if (!$this->Query_ID)
{
$this->halt('Invalid SQL: '.$Query_String);
--- 59,67 ----
$this->connect();
! /* printf("Debug: query = %s<br>\n", $Query_String); */
$this->Query_ID =
sybase_query($Query_String,$this->Link_ID);
$this->Row = 0;
! if(!$this->Query_ID)
{
$this->halt('Invalid SQL: '.$Query_String);
***************
*** 77,81 ****
$stat = is_array($this->Record);
! if (!$stat && $this->Auto_Free)
{
sybase_free_result($this->Query_ID);
--- 77,81 ----
$stat = is_array($this->Record);
! if(!$stat && $this->Auto_Free)
{
sybase_free_result($this->Query_ID);
***************
*** 88,92 ****
{
$status = sybase_data_seek($this->Query_ID, $pos);
! if ($status)
{
$this->Row = $pos;
--- 88,92 ----
{
$status = sybase_data_seek($this->Query_ID, $pos);
! if($status)
{
$this->Row = $pos;
***************
*** 103,107 ****
$this->connect();
$result = $this->query("exec sp_columns $table");
! if ($result < 0)
{
$this->Errno = 1;
--- 103,107 ----
$this->connect();
$result = $this->query("exec sp_columns $table");
! if($result < 0)
{
$this->Errno = 1;
***************
*** 111,115 ****
$count = sybase_num_rows($result);
! for ($i=0; $i<$count; $i++)
{
$res[$i]['table'] = $table ;
--- 111,115 ----
$count = sybase_num_rows($result);
! for($i=0; $i<$count; $i++)
{
$res[$i]['table'] = $table ;
***************
*** 119,123 ****
$res[$i]['position'] = sybase_result ($result,
$i, 'ORDINAL_POSITION');
$res[$i]['flags'] = sybase_result ($result, $i,
'REMARKS');
-
}
}
--- 119,122 ----
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: phpgwapi/inc class.db_msql.inc.php,1.5,1.6 class.db_mssql.inc.php,1.20,1.21 class.db_mysql.inc.php,1.30,1.31 class.db_oracle.inc.php,1.6,1.7 class.db_pgsql.inc.php,1.30,1.31 class.db_sybase.inc.php,1.6,1.7,
Miles Lott <address@hidden> <=