[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] phpgwapi/inc class.db.inc.php, 1.6, 1.7 class.db_msql
From: |
Dave Hall <address@hidden> |
Subject: |
[Phpgroupware-cvs] phpgwapi/inc class.db.inc.php, 1.6, 1.7 class.db_msql.inc.php, 1.6, 1.7 class.db_mssql.inc.php, 1.23, 1.24 class.db_mysql.inc.php, 1.38, 1.39 class.db_odbc.inc.php, 1.5, 1.6 class.db_oracle.inc.php, 1.8, 1.9 class.db_pgsql.inc.php, 1.34, 1.35 class.db_sybase.inc.php, 1.7, 1.8 |
Date: |
Thu, 09 Oct 2003 03:31:35 +0000 |
Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv9039
Modified Files:
class.db.inc.php class.db_msql.inc.php class.db_mssql.inc.php
class.db_mysql.inc.php class.db_odbc.inc.php
class.db_oracle.inc.php class.db_pgsql.inc.php
class.db_sybase.inc.php
Log Message:
merging db changes to head from 16
Index: class.db_mssql.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.db_mssql.inc.php,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** class.db_mssql.inc.php 28 Sep 2002 20:01:44 -0000 1.23
--- class.db_mssql.inc.php 9 Oct 2003 03:31:32 -0000 1.24
***************
*** 3,8 ****
* phpGroupWare API - MS SQL Server support *
* (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.
*
--- 3,7 ----
* phpGroupWare API - MS SQL Server support *
* (C) Copyright 1998 Cameron Taggart (address@hidden) *
! * Contributiors Guarneri Carmelo, Cameron Just, Dave Hall, Signude Ness *
* ------------------------------------------------------------------------ *
* This is not part of phpGroupWare, but is used by phpGroupWare.
*
***************
*** 14,56 ****
* any later version. *
\**************************************************************************/
-
/* $Id$ */
! /* echo '<BR>This is using the MSSQL class<BR>'; */
! /* ^^ really ?! :) */
! /* mdean, put your info in the banner, mkay? */
!
! class db
{
- var $Host = '';
- var $Database = '';
- var $User = '';
- var $Password = '';
-
- var $Link_ID = 0;
- var $Query_ID = 0;
- var $Record = array();
- var $Row = 0;
var $VEOF = -1;
-
- var $Errno = 0;
- var $Error = '';
- var $Auto_Free = 0; ## set this to 1 to automatically
free results
- var $Debug = false;
var $Transaction = false;
! 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);
}
else
{
!
$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');
--- 13,54 ----
* any later version. *
\**************************************************************************/
/* $Id$ */
! class db extends db_
{
var $VEOF = -1;
var $Transaction = false;
! function connect($Database = '', $Host = '', $User = '',
$Password = '')
{
! /* Handle defaults */
! if ($Database == '')
{
! $Database = $this->Database;
! }
! if ($Host == '')
! {
! $Host = $this->Host;
! }
! if ($User == '')
! {
! $User = $this->User;
! }
! if ($Password == '')
! {
! $Password = $this->Password;
! }
!
! if (! $this->Link_ID )
! {
! if
($GLOBALS['phpgw_info']['server']['db_persistent'])
{
! $this->Link_ID=mssql_pconnect($Host,
$User, $Password);
}
else
{
! $this->Link_ID=mssql_connect($Host,
$User, $Password);
}
! if (!$this->Link_ID)
{
$this->halt('Link-ID == false,
mssql_'.($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'').'connect
failed');
***************
*** 58,84 ****
else
{
! mssql_select_db($this->Database,
$this->Link_ID);
}
}
}
- function disconnect()
- {
- }
-
function db_addslashes($str)
{
! if(!isset($str) || $str == '')
{
return '';
}
! return ereg_replace("'", "''", $str);
}
function free_result()
{
- /*
- mssql_free_result($this->Query_ID);
- */
if ($this->Query_ID)
{
--- 56,75 ----
else
{
! mssql_select_db($Database,
$this->Link_ID);
}
}
}
function db_addslashes($str)
{
! if (!IsSet($str) || $str == '')
{
return '';
}
! return str_replace("'", "''", $str);
}
function free_result()
{
if ($this->Query_ID)
{
***************
*** 93,97 ****
$this->VEOF = -1;
! if(!$this->Link_ID)
{
$this->connect();
--- 84,88 ----
$this->VEOF = -1;
! if (!$this->Link_ID)
{
$this->connect();
***************
*** 100,104 ****
$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);
--- 91,95 ----
$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);
***************
*** 121,130 ****
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);
--- 112,121 ----
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);
***************
*** 132,140 ****
$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);
--- 123,131 ----
$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);
***************
*** 148,152 ****
function next_record()
{
! if(!$this->Query_ID)
{
$this->halt("next_record called with no query
pending.");
--- 139,143 ----
function next_record()
{
! if (!$this->Query_ID)
{
$this->halt("next_record called with no query
pending.");
***************
*** 154,165 ****
}
! 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];
--- 145,156 ----
}
! 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];
***************
*** 179,183 ****
$stat = is_array($this->Record);
! if(!$stat && $this->Auto_Free)
{
$this->free();
--- 170,174 ----
$stat = is_array($this->Record);
! if (!$stat && $this->Auto_Free)
{
$this->free();
***************
*** 195,199 ****
function transaction_commit()
{
! if(!$this->Errno && $this->Transaction)
{
$this->Transaction = false;
--- 186,190 ----
function transaction_commit()
{
! if (!$this->Errno && $this->Transaction)
{
$this->Transaction = false;
***************
*** 206,210 ****
function transaction_abort()
{
! if($this->Transaction)
{
$this->Transaction = false;
--- 197,201 ----
function transaction_abort()
{
! if ($this->Transaction)
{
$this->Transaction = false;
***************
*** 229,233 ****
$this->connect();
$id = mssql_query("select * from $table",
$this->Link_ID);
! if(!$id)
{
$this->halt('Metadata query failed.');
--- 220,224 ----
$this->connect();
$id = mssql_query("select * from $table",
$this->Link_ID);
! if (!$id)
{
$this->halt('Metadata query failed.');
***************
*** 236,240 ****
$count = mssql_num_fields($id);
! for($i=0; $i<$count; $i++)
{
$info = mssql_fetch_field($id, $i);
--- 227,231 ----
$count = mssql_num_fields($id);
! for ($i=0; $i<$count; $i++)
{
$info = mssql_fetch_field($id, $i);
***************
*** 250,261 ****
function affected_rows()
{
! return mssql_affected_rows($this->Query_ID);
}
function num_rows()
{
- /*
- return mssql_num_rows($this->Query_ID);
- */
if($this->Query_ID)
{
--- 241,250 ----
function affected_rows()
{
! $rsRows = mssql_query('SELECT @@rowcount as rows');
! return mssql_result($rsRows, 0, "rows");
}
function num_rows()
{
if($this->Query_ID)
{
***************
*** 273,311 ****
}
! function nf()
! {
! return $this->num_rows();
! }
!
! function np()
! {
! print $this->num_rows();
! }
!
! function f($Field_Name)
! {
! return $this->Record[strtolower($Field_Name)];
! }
!
! function p($Field_Name)
! {
! print $this->f($Field_Name);
}
- /* public: table locking */
function get_last_insert_id($table, $field)
{
! /* This will get the last insert ID created on the
current connection. Should only be called
! * after an insert query is run on a table that has an
auto incrementing field. Of note, table
! * and field are required for pgsql compatiblity.
MSSQL uses a query to retrieve the last
! * identity on the connection, so table and field are
ignored here as well.
! */
! if(!isset($table) || $table == '' || !isset($field) ||
$field == '')
{
! return -1;
}
$result = @mssql_query("select @@identity",
$this->Link_ID);
! if(!$result)
{
return -1;
--- 262,286 ----
}
! function f($Field_Name, $strip_slashes)
! {
! if ($strip_slashes || ($this->auto_stripslashes && !
$strip_slashes))
! {
! return str_replace("''", "'",
$this->Record[$Name]);
! }
! else
! {
! return $this->Record[$Name];
! }
}
function get_last_insert_id($table, $field)
{
! if (!isset($table) || $table == '' || !isset($field) ||
$field == '')
{
! return -1;
}
$result = @mssql_query("select @@identity",
$this->Link_ID);
! if (!$result)
{
return -1;
***************
*** 316,320 ****
function lock($table, $mode="write")
{
! /* /me really, really, really hates locks -
transactions serve just fine */
return $this->transaction_begin();
}
--- 291,295 ----
function lock($table, $mode="write")
{
! // /me really, really, really hates locks -
transactions serve just fine
return $this->transaction_begin();
}
***************
*** 325,329 ****
}
- /* private: error handling */
function halt($msg, $line = '', $file = '')
{
--- 300,303 ----
***************
*** 332,341 ****
$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;
--- 306,315 ----
$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;
***************
*** 344,360 ****
$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>";
exit;
}
--- 318,335 ----
$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>";
+ $this->transaction_abort();
exit;
}
***************
*** 364,368 ****
{
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);
--- 339,343 ----
{
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);
***************
*** 374,378 ****
$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];
--- 349,353 ----
$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];
***************
*** 381,391 ****
$i++;
}
- return $return;
- }
-
- /* Surely we can do this, eh */
- function index_names()
- {
- $return = array();
return $return;
}
--- 356,359 ----
Index: class.db_pgsql.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.db_pgsql.inc.php,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** class.db_pgsql.inc.php 5 May 2003 20:24:57 -0000 1.34
--- class.db_pgsql.inc.php 9 Oct 2003 03:31:32 -0000 1.35
***************
*** 1,54 ****
<?php
! /**************************************************************************\
! * phpGroupWare API - *
! * Copyright (c) 1998,1999 SH Online Dienst GmbH Boris Erdmann, *
! * Kristian Koehntopp *
! * ------------------------------------------------------------------------ *
! * This is not part of phpGroupWare, but is used by phpGroupWare.
*
! * http://www.phpgroupware.org/
*
! * ------------------------------------------------------------------------ *
! * This program is free software; you can redistribute it and/or modify it *
! * under the terms of the GNU Lesser General Public License as published *
! * by the Free Software Foundation; either version 2.1 of the License, or *
! * any later version. *
! \**************************************************************************/
!
! /* $Id$ */
! class db
{
- var $Host = '';
- var $Database = '';
- var $User = '';
- var $Password = '';
-
- var $auto_stripslashes = False;
-
- /* 'yes' (halt with message), 'no' (ignore errors quietly),
'report' (ignore errror, but spit a warning) */
- var $Halt_On_Error = 'yes';
-
- var $Link_ID = 0;
- var $Query_ID = 0;
- var $Record = array();
- var $Row = 0;
-
var $Seq_Table = 'db_sequence';
! var $Errno = 0;
! var $Error = '';
!
! /* Set this to 1 for automatic pg_freeresult on last record. */
! 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;
-
function ifadd($add, $me)
{
! if('' != $add)
{
return ' ' . $me . $add;
--- 1,30 ----
<?php
! /**********************************************************************\
! * phpGroupWare - API - Database Abstraction *
! * http://www.phpgroupware.org
*
! * This program is part of the GNU project, see http://www.gnu.org/ *
! * *
! * Portions Copyright 2001, 2002, 2003 Free Software Foundation, Inc. *
! * Based on phplib - Copyright 1998-2000 SH Online Dienst GmbH
*
! * Boris Erdmann, Kristian Koehntopp *
! * Contributions from Dan Kuykendall, Michael Dean, Dave Hall and others*
! * --------------------------------------------
*
! * This program is Free Software; you can redistribute it and/or *
! * modify it under the terms of the GNU Lesser General Public License
*
! * as published by the Free Software Foundation; either version 2.1 of *
! * the License, or (at your option) any later version.
*
! \**********************************************************************/
! /* $Id$ */
! class db extends db_
{
var $Seq_Table = 'db_sequence';
! // PostgreSQL changed somethings from 6.x -> 7.x
var $db_version;
function ifadd($add, $me)
{
! if($add != '')
{
return ' ' . $me . $add;
***************
*** 59,85 ****
function db($query = '')
{
! $this->query($query);
! if (ereg('xmlrpc.php',$_SERVER['PHP_SELF']))
{
! $this->xmlrpc = True;
}
!
! if (ereg('soap.php',$_SERVER['PHP_SELF']))
{
! $this->soap = True;
}
- }
! function connect()
! {
! if(0 == $this->Link_ID)
{
! $cstr = 'dbname=' . $this->Database
! . $this->ifadd($this->Host, 'host=')
! . $this->ifadd($this->Port, 'port=')
! . $this->ifadd($this->User, 'user=')
! . $this->ifadd("'".$this->Password."'",
'password=');
!
if($GLOBALS['phpgw_info']['server']['db_persistent'])
{
$this->Link_ID=pg_pconnect($cstr);
--- 35,69 ----
function db($query = '')
{
! $this->db_($query);
! }
! function connect($Database = '', $Host = '', $User = '',
$Password = '')
! {
! /* Handle defaults */
! if ($Database == '')
{
! $Database = $this->Database;
}
! if ($Host == '')
{
! $Host = $this->Host;
! }
! if ($User == '')
! {
! $User = $this->User;
! }
! if ($Password == '')
! {
! $Password = $this->Password;
}
! if (! $this->Link_ID)
{
! $cstr = 'dbname=' . $Database
! . $this->ifadd($Host, 'host=')
! . $this->ifadd($Port, 'port=')
! . $this->ifadd($User, 'user=')
! . $this->ifadd("'".$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');
--- 74,78 ----
}
! 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();
--- 80,84 ----
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);
--- 93,97 ----
{
$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);
--- 105,109 ----
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)
{
--- 115,119 ----
}
! // For PostgreSQL 6.x
function to_timestamp_6($epoch)
{
***************
*** 137,141 ****
}
! /* For PostgreSQL 6.x */
function from_timestamp_6($timestamp)
{
--- 121,125 ----
}
! // For PostgreSQL 6.x
function from_timestamp_6($timestamp)
{
***************
*** 143,176 ****
}
! /* 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)
- {
- 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 ' .
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] . ',' .
$start;
- }
- return $s;
- }
-
/* This only affects systems not using persistant connections */
function disconnect()
--- 127,145 ----
}
! // 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]);
}
/* This only affects systems not using persistant connections */
function disconnect()
***************
*** 179,201 ****
}
- function db_addslashes($str)
- {
- if(!isset($str) || $str == '')
- {
- return '';
- }
-
- return addslashes($str);
- }
-
- /* I added the line and file section so we can have better
error reporting. (jengo) */
function query($Query_String, $line = '', $file = '')
{
! /* No empty queries, please, since PHP4 chokes on them.
*/
! /* 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_Subclass;'
! */
! if($Query_String == '')
{
return 0;
--- 148,154 ----
}
function query($Query_String, $line = '', $file = '')
{
! if ($Query_String == '')
{
return 0;
***************
*** 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);
--- 164,168 ----
$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);
***************
*** 219,231 ****
}
- /* public: perform a query with limited result set */
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;
--- 172,183 ----
}
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;
***************
*** 236,240 ****
}
! if($this->Debug)
{
printf("Debug: limit_query = %s<br>offset=%d,
num_rows=%d<br>\n", $Query_String, $offset, $num_rows);
--- 188,192 ----
}
! if ($this->Debug)
{
printf("Debug: limit_query = %s<br>offset=%d,
num_rows=%d<br>\n", $Query_String, $offset, $num_rows);
***************
*** 244,248 ****
}
- /* public: discard the query result */
function free()
{
--- 196,199 ----
***************
*** 259,263 ****
$stat = is_array($this->Record);
! if(!$stat && $this->Auto_Free)
{
pg_freeresult($this->Query_ID);
--- 210,214 ----
$stat = is_array($this->Record);
! if (!$stat && $this->Auto_Free)
{
pg_freeresult($this->Query_ID);
***************
*** 279,283 ****
function transaction_commit()
{
! if(!$this->Errno)
{
return pg_Exec($this->Link_ID,'commit');
--- 230,234 ----
function transaction_commit()
{
! if (! $this->Errno)
{
return pg_Exec($this->Link_ID,'commit');
***************
*** 296,306 ****
function get_last_insert_id($table, $field)
{
! /* This will get the last insert ID created on the
current connection. Should only be called
! * after an insert query is run on a table that has an
auto incrementing field. Of note, table
! * and field are required because pgsql returns the
last inserted OID, which is unique across
! * an entire installation. These params allow us to
retrieve the sequenced field without adding
! * conditional code to the apps.
! */
! if(!isset($table) || $table == '' || !isset($field) ||
$field == '')
{
return -1;
--- 247,251 ----
function get_last_insert_id($table, $field)
{
! if (!isset($table) || $table == '' || !isset($field) ||
$field == '')
{
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;
--- 253,263 ----
$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;
***************
*** 321,325 ****
$Record = @pg_fetch_array($result, 0);
@pg_freeresult($result);
! if(!is_array($Record)) /* OID not found? */
{
return -1;
--- 266,270 ----
$Record = @pg_fetch_array($result, 0);
@pg_freeresult($result);
! if (!is_array($Record)) /* OID not found? */
{
return -1;
***************
*** 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');
--- 274,286 ----
}
! 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');
***************
*** 361,373 ****
- /* public: sequence numbers */
function nextid($seq_name)
{
$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);
--- 306,317 ----
function nextid($seq_name)
{
$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);
***************
*** 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,
--- 320,327 ----
/* No current value, make one */
! if (!is_array($res))
{
$currentid = 0;
! $q = sprintf("insert into %s
values('%s', %s)",
$this->Seq_Table,
$seq_name,
***************
*** 390,394 ****
}
$nextid = $currentid + 1;
! $q = sprintf("UPDATE %s SET nextid = '%s' WHERE
seq_name = '%s'",
$this->Seq_Table,
$nextid,
--- 334,338 ----
}
$nextid = $currentid + 1;
! $q = sprintf("update %s set nextid = '%s' where
seq_name = '%s'",
$this->Seq_Table,
$nextid,
***************
*** 412,417 ****
$this->connect();
! $id = pg_exec($this->Link_ID, "SELECT * FROM $table");
! if($id < 0)
{
$this->Error = pg_ErrorMessage($id);
--- 356,361 ----
$this->connect();
! $id = pg_exec($this->Link_ID, "select * from $table");
! if ($id < 0)
{
$this->Error = pg_ErrorMessage($id);
***************
*** 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'] = '';
}
--- 365,374 ----
$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'] = '';
}
***************
*** 449,482 ****
}
- function nf()
- {
- return $this->num_rows();
- }
-
- function np()
- {
- print $this->num_rows();
- }
-
- function f($Name,$strip_slashes = '')
- {
- if($strip_slashes || ($this->auto_stripslashes && !
$strip_slashes))
- {
- return stripslashes($this->Record[$Name]);
- }
- else
- {
- return $this->Record[$Name];
- }
- }
-
- function p($Name)
- {
- print $this->Record[$Name];
- }
-
function halt($msg, $line = '', $file = '')
{
! if($this->Halt_On_Error == 'no')
{
return;
--- 393,399 ----
}
function halt($msg, $line = '', $file = '')
{
! if ($this->Halt_On_Error == 'no')
{
return;
***************
*** 487,491 ****
! if($this->xmlrpc || $this->soap)
{
$s = sprintf("Database error: %s\n", $msg);
--- 404,408 ----
! if ($this->xmlrpc || $this->soap)
{
$s = sprintf("Database error: %s\n", $msg);
***************
*** 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>';
--- 415,445 ----
}
! 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>';
***************
*** 530,538 ****
}
! if($this->xmlrpc)
{
xmlrpcfault($s);
}
! elseif($this->soap)
{
--- 447,455 ----
}
! if ($this->xmlrpc)
{
xmlrpcfault($s);
}
! elseif ($this->soap)
{
***************
*** 541,545 ****
{
echo $s;
! exit;
}
}
--- 458,462 ----
{
echo $s;
! $GLOBALS['phpgw']->common->phpgw_exit(True);
}
}
***************
*** 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);
--- 464,471 ----
function table_names()
{
! $return = array();
! $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);
***************
*** 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);
--- 481,485 ----
$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);
***************
*** 579,583 ****
$currentDatabase = $this->Database;
! if($adminname != '')
{
$this->User = $adminname;
--- 497,501 ----
$currentDatabase = $this->Database;
! if ($adminname != "")
{
$this->User = $adminname;
***************
*** 585,589 ****
}
! if(!$this->Host)
{
system('createdb ' . $currentDatabase, $outval);
--- 503,507 ----
}
! if (! $this->Host)
{
system('createdb ' . $currentDatabase, $outval);
***************
*** 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>';
}
--- 515,520 ----
{
/* 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_msql.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.db_msql.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** class.db_msql.inc.php 10 Feb 2002 12:04:10 -0000 1.6
--- class.db_msql.inc.php 9 Oct 2003 03:31:32 -0000 1.7
***************
*** 1,46 ****
<?php
! /**************************************************************************\
! * phpGroupWare API - *
! * Copyright (c) 1998,1999 SH Online Dienst GmbH Boris Erdmann, *
! * Kristian Koehntopp *
! * ------------------------------------------------------------------------ *
! * This is not part of phpGroupWare, but is used by phpGroupWare.
*
! * http://www.phpgroupware.org/
*
! * ------------------------------------------------------------------------ *
! * This program is free software; you can redistribute it and/or modify it *
! * under the terms of the GNU Lesser General Public License as published *
! * by the Free Software Foundation; either version 2.1 of the License, or *
! * any later version. *
! \**************************************************************************/
!
! /* $Id$ */
! class db
{
! var $Host = '';
! var $Database = '';
!
! var $Link_ID = 0;
! var $Query_ID = 0;
! var $Record = array();
! var $Row;
!
! 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 )
{
// Check for local connect
! $this->Link_ID = empty($this->Host)?
$this->Link_ID=msql_pconnect():
! $this->Link_ID=msql_pconnect($this->Host);
}
! /* Still not connected? Raise error. */
! if(0 == $this->Link_ID)
{
$this->halt('Link-ID == false, pconnect
failed');
--- 1,52 ----
<?php
! /**********************************************************************\
! * phpGroupWare - API - Database Abstraction *
! * http://www.phpgroupware.org
*
! * This program is part of the GNU project, see http://www.gnu.org/ *
! * *
! * Portions Copyright 2001, 2002, 2003 Free Software Foundation, Inc. *
! * Based on phplib - Copyright 1998-2000 SH Dienst GmbH
*
! * Boris Erdmann, Kristian Koehntopp *
! * Contributions from Dan Kuykendall, Dave Hall and others *
! * --------------------------------------------
*
! * This program is Free Software; you can redistribute it and/or *
! * modify it under the terms of the GNU Lesser General Public License
*
! * as published by the Free Software Foundation; either version 2.1 of *
! * the License, or (at your option) any later version.
*
! \**********************************************************************/
! /* $Id$ */
! class db extends db_
{
! function connect($Database = '', $Host = '', $User = '',
$Password = '')
{
! /* Handle defaults */
! if ($Database == '')
! {
! $Database = $this->Database;
! }
! if ($Host == '')
! {
! $Host = $this->Host;
! }
! if ($User == '')
! {
! $User = $this->User;
! }
! if ($Password == '')
! {
! $Password = $this->Password;
! }
!
! if (! $this->Link_ID)
{
// Check for local connect
! $this->Link_ID = empty($Host)?
$this->Link_ID=msql_pconnect():
! $this->Link_ID=msql_pconnect($Host);
}
! // Still not connected? Raise error.
! if (! $this->Link_ID )
{
$this->halt('Link-ID == false, pconnect
failed');
***************
*** 48,54 ****
// Select current database
! if(!msql_select_db($this->Database, $this->Link_ID))
{
! $this->halt('cannot use database
'.$this->Database);
}
}
--- 54,60 ----
// Select current database
! if (!msql_select_db($Database, $this->Link_ID))
{
! $this->halt('cannot use database '.$Database);
}
}
***************
*** 138,161 ****
{
return msql_num_fields($this->Query_ID);
- }
-
- function nf()
- {
- return $this->num_rows();
- }
-
- function np()
- {
- print $this->num_rows();
- }
-
- function f($Name)
- {
- return $this->Record[$Name];
- }
-
- function p($Name)
- {
- print $this->Record[$Name];
}
--- 144,147 ----
Index: class.db.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.db.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** class.db.inc.php 2 Sep 2001 00:27:19 -0000 1.6
--- class.db.inc.php 9 Oct 2003 03:31:32 -0000 1.7
***************
*** 1,7 ****
! <?php
if (empty($GLOBALS['phpgw_info']['server']['db_type']))
{
$GLOBALS['phpgw_info']['server']['db_type'] = 'mysql';
}
!
include(PHPGW_API_INC.'/class.db_'.$GLOBALS['phpgw_info']['server']['db_type'].'.inc.php');
?>
--- 1,452 ----
! <?php
! /**********************************************************************\
! * phpGroupWare - API - Database Abstraction *
! * http://www.phpgroupware.org
*
! * This program is part of the GNU project, see http://www.gnu.org/ *
! * *
! * Portions Copyright 2001, 2002, 2003 Free Software Foundation, Inc. *
! * Based on phplib - Copyright 1998-2000 NetUSE AG, *
! * Boris Erdmann, Kristian Koehntopp *
! * Contributions from Dan Kuykendall, Dave Hall and others *
! * --------------------------------------------
*
! * This program is Free Software; you can redistribute it and/or *
! * modify it under the terms of the GNU Lesser General Public License
*
! * as published by the Free Software Foundation; either version 2.1 of *
! * the License, or (at your option) any later version.
*
! \**********************************************************************/
! /* $Id$ */
!
if (empty($GLOBALS['phpgw_info']['server']['db_type']))
{
$GLOBALS['phpgw_info']['server']['db_type'] = 'mysql';
}
!
include(PHPGW_API_INC.'/class.db_'.$GLOBALS['phpgw_info']['server']['db_type'].'.inc.php');
!
! /**
! * Database abstraction library
! *
! * This allows phpGroupWare to use multiple database backends
! *
! * @package phpgwapi
! * @subpackage db
! * @abstract
! * @author NetUSE AG Boris Erdmann, Kristian Koehntopp <br> hacked on by
phpGW
! * @copyright © 1998-2000 NetUSE AG Boris Erdmann, Kristian
Koehntopp <br> 2003 FreeSoftware Foundation
! * @license LGPL
! * @link http://www.sanisoft.com/phplib/manual/DB_sql.php
! */
!
! class db_
! {
! /**
! * @var string $Host database host to connect to
! */
! var $Host = '';
!
! /**
! * @var string $Database name of database to use
! */
! var $Database = '';
!
! /**
! * @var string $User name of database user
! */
! var $User = '';
!
! /**
! * @var string $Password password for database user
! */
! var $Password = '';
!
! /**
! * @var bool $auto_stripslashes automatically remove slashes
when returning field values - default False
! */
! var $auto_stripslashes = False;
!
! /**
! * @var int $Auto_Free automatically free results - 0 no, 1 yes
! */
! var $Auto_Free = 0;
!
! /**
! * @var int $Debug enable debuging - 0 no, 1 yes
! */
! var $Debug = 0;
!
! /**
! * @var string $Halt_On_Error "yes" (halt with message), "no"
(ignore errors quietly), "report" (ignore errror, but spit a warning)
! */
! var $Halt_On_Error = 'yes';
!
! /**
! * @var string $Seq_Table table for storing sequences ????
! */
! var $Seq_Table = 'db_sequence';
!
! /**
! * @var array $Record current record
! */
! var $Record = array();
!
! /**
! * @var int row number for current record
! */
! var $Row;
!
! /**
! * @var int $Errno internal rdms error number for last error
! */
! var $Errno = 0;
!
! /**
! * @var string descriptive text from last error
! */
! var $Error = '';
!
! //i am not documenting private vars - skwashd :)
! var $xmlrpc = False;
! var $soap = False;
!
! /**
! * @param string $query query to be executed (optional)
! */
!
! function db_($query = '')
! {
! $this->query($query);
! }
!
! /**
! * @return int current connection id
! */
! function link_id()
! {
! return $this->Link_ID;
! }
!
! /**
! * @return int id of current query
! */
! function query_id()
! {
! return $this->Query_ID;
! }
!
! /**
! * Open a connection to a database
! *
! * @param string $Database name of database to use (optional)
! * @param string $Host database host to connect to (optional)
! * @param string $User name of database user (optional)
! * @var string $Password password for database user (optional)
! */
! function connect($Database = '', $Host = '', $User = '',
$Password = '')
! {}
!
! /**
! * Close a connection to a database - only needed for persistent
connections
! */
! function disconnect()
! {}
!
! /**
! * Escape strings before sending them to the database
! *
! * @param string $str the string to be escaped
! * @return string escaped sting
! */
! function db_addslashes($str)
! {
! if (!isset($str) || $str == '')
! {
! return '';
! }
!
! return addslashes($str);
! }
!
! /**
! * Convert a unix timestamp to a rdms specific timestamp
! *
! * @param int unix timestamp
! * @return string rdms specific timestamp
! */
! function to_timestamp($epoch)
! {}
!
! /**
! * Convert a rdms specific timestamp to a unix timestamp
! *
! * @param string rdms specific timestamp
! * @return int unix timestamp
! */
! function from_timestamp($timestamp)
! {}
!
! /**
! * @deprecated
! * @see limit_query()
! */
! function limit($start)
! {}
!
! /**
! * Discard the current query result
! */
! function free()
! {}
!
! /**
! * Execute a query
! *
! * @param string $Query_String the query to be executed
! * @param mixed $line the line method was called from - use
__LINE__
! * @param string $file the file method was called from - use
__FILE__
! * @return int current query id if sucesful and null if fails
! */
! function query($Query_String, $line = '', $file = '')
! {}
!
! /**
! * Execute a query with limited result set
! *
! * @param string $Query_String the query to be executed
! * @param int $offset row to start from
! * @param mixed $line the line method was called from - use
__LINE__
! * @param string $file the file method was called from - use
__FILE__
! * @param int $num_rows number of rows to return (optional), if
unset will use
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']
! * @return int current query id if sucesful and null if fails
! */
! function limit_query($Query_String, $offset, $line = '', $file
= '', $num_rows = '')
! {}
!
! /**
! * Move to the next row in the results set
! *
! * @return bool was another row found?
! */
! function next_record()
! {}
!
! /**
! * Move to position in result set
! *
! * @param int $pos required row (optional), default first row
! * @return int 1 if sucessful or 0 if not found
! */
! function seek($pos = 0)
! {}
!
! /**
! * Begin Transaction
! *
! * @return int current transaction id
! */
! function transaction_begin()
! {
! return True;
! }
!
! /**
! * Complete the transaction
! *
! * @return bool True if sucessful, False if fails
! */
! function transaction_commit()
! {
! return True;
! }
!
! /**
! * Rollback the current transaction
! *
! * @return bool True if sucessful, False if fails
! */
! function transaction_abort()
! {
! return True;
! }
!
! /**
! * Find the primary key of the last insertion on the current db
connection
! *
! * @param string $table name of table the insert was performed on
! * @param string $field the autoincrement primary key of the
table
! * @return int the id, -1 if fails
! */
! function get_last_insert_id($table, $field)
! {}
!
! /**
! * Lock a table
! *
! * @param string $table name of table to lock
! * @param string $mode type of lock required (optional), default
write
! * @return bool True if sucessful, False if fails
! */
! function lock($table, $mode='write')
! {}
!
!
! /**
! * Unlock a table
! *
! * @return bool True if sucessful, False if fails
! */
! function unlock()
! {}
!
! /**
! * Get the number of rows affected by last update
! *
! * @return int number of rows
! */
! function affected_rows()
! {}
!
! /**
! * Number of rows in current result set
! *
! * @return int number of rows
! */
! function num_rows()
! {}
!
! /**
! * Number of fields in current row
! *
! * @return int number of fields
! */
!
! function num_fields()
! {}
!
! /**
! * short hand for @see num_rows()
! */
! function nf()
! {
! return $this->num_rows();
! }
!
! /**
! * short hand for print @see num_rows
! */
! function np()
! {
! print $this->num_rows();
! }
!
! /**
! * Return the value of a filed
! *
! * @param string $String name of field
! * @param bool $strip_slashes string escape chars from
field(optional), default false
! * @return string the field value
! */
! function f($Name, $strip_slashes = False)
! {
! if ($strip_slashes || ($this->auto_stripslashes && !
$strip_slashes))
! {
! return stripslashes($this->Record[$Name]);
! }
! else
! {
! return $this->Record[$Name];
! }
! }
!
! /**
! * Print the value of a field
! *
! * @param string $Name name of field to print
! * @param bool $strip_slashes string escape chars from
field(optional), default false
! */
! function p($Name, $strip_slashes = True)
! {
! print $this->f($Name, $strip_slashes);
! }
!
! /**
! * Get the id for the next sequence - not implemented!
! *
! * @param string $seq_name name of the sequence
! * @return int sequence id
! */
! function nextid($seq_name)
! {}
!
! /**
! * Get description of a table
! *
! * @param string $table name of table to describe
! * @param bool $full optional, default False summary
information, True full information
! * @return array table meta data
! */
! function metadata($table='',$full=false)
! {
! /*
! * Due to compatibility problems with Table we changed
the behavior
! * of metadata();
! * depending on $full, metadata returns the following
values:
! *
! * - full is false (default):
! * $result[]:
! * [0]["table"] table name
! * [0]["name"] field name
! * [0]["type"] field type
! * [0]["len"] field length
! * [0]["flags"] field flags
! *
! * - full is true
! * $result[]:
! * ["num_fields"] number of metadata records
! * [0]["table"] table name
! * [0]["name"] field name
! * [0]["type"] field type
! * [0]["len"] field length
! * [0]["flags"] field flags
! * ["meta"][field name] index of field named "field
name"
! * The last one is used, if you have a field name,
but no index.
! * Test: if (isset($result['meta']['myfield'])) { ...
! */
! }
!
! /**
! * Error handler
! *
! * @param string $msg error message
! * @param int $line line of calling method/function (optional)
! * @param string $file file of calling method/function (optional)
! */
! function halt($msg, $line = '', $file = '')
! {}
!
! /**
! * Get a list of table names in the current database
! *
! * @return array list of the tables
! */
! function table_names()
! {}
!
! /**
! * Return a list of indexes in current database
! *
! * @return array list of indexes
! */
! function index_names()
! {
! return array();
! }
!
! /**
! * Create a new database
! *
! * @param string $adminname name of database administrator user
(optional)
! * @param string $adminpasswd password for the database
administrator user (optional)
! */
! function create_database($adminname = '', $adminpasswd = '')
! {}
! }
?>
Index: class.db_odbc.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.db_odbc.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** class.db_odbc.inc.php 29 Sep 2001 00:30:07 -0000 1.5
--- class.db_odbc.inc.php 9 Oct 2003 03:31:32 -0000 1.6
***************
*** 17,41 ****
class db
{
- var $Host = '';
- var $Database = '';
- var $User = '';
- var $Password = '';
var $UseODBCCursor = 0;
! var $Link_ID = 0;
! var $Query_ID = 0;
! var $Record = array();
! var $Row = 0;
!
! var $Errno = 0;
! var $Error = '';
!
! var $Auto_Free = 0; ## set this to 1 to automatically free
results
!
! function connect()
{
! if ( 0 == $this->Link_ID )
{
! $this->Link_ID=odbc_pconnect($this->Database,
$this->User, $this->Password, $this->UseODBCCursor);
if (!$this->Link_ID)
{
--- 17,45 ----
class db
{
var $UseODBCCursor = 0;
! function connect($Database = '', $Host = '', $User = '',
$Password = '')
{
! /* Handle defaults */
! if ($Database == '')
{
! $Database = $this->Database;
! }
! if ($Host == '')
! {
! $Host = $this->Host;
! }
! if ($User == '')
! {
! $User = $this->User;
! }
! if ($Password == '')
! {
! $Password = $this->Password;
! }
!
! if (! $this->Link_ID)
! {
! $this->Link_ID=odbc_pconnect($Database, $User,
$Password, $this->UseODBCCursor);
if (!$this->Link_ID)
{
***************
*** 183,204 ****
}
- function nf()
- {
- return $this->num_rows();
- }
-
- function np()
- {
- print $this->num_rows();
- }
-
function f($Field_Name)
{
return $this->Record[strtolower($Field_Name)];
- }
-
- function p($Field_Name)
- {
- print $this->f($Field_Name);
}
--- 187,193 ----
Index: class.db_sybase.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.db_sybase.inc.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** class.db_sybase.inc.php 10 Feb 2002 12:04:10 -0000 1.7
--- class.db_sybase.inc.php 9 Oct 2003 03:31:32 -0000 1.8
***************
*** 15,46 ****
* any later version. *
\**************************************************************************/
-
/* $Id$ */
! class db
{
! var $Host = '';
! var $Database = '';
! var $User = '';
! var $Password = '';
!
! var $Link_ID = 0;
! var $Query_ID = 0;
! var $Record = array();
! 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);
}
}
--- 15,50 ----
* any later version. *
\**************************************************************************/
/* $Id$ */
! class db extends db_
{
! function connect($Database = '', $Host = '', $User = '',
$Password = '')
{
! /* Handle defaults */
! if ($Database == '')
! {
! $Database = $this->Database;
! }
! if ($Host == '')
! {
! $Host = $this->Host;
! }
! if ($User == '')
! {
! $User = $this->User;
! }
! if ($Password == '')
! {
! $Password = $this->Password;
! }
! if (! $this->Link_ID)
{
if($GLOBALS['phpgw_info']['server']['db_persistent'])
{
!
$this->Link_ID=sybase_pconnect($Host,$User,$Password);
}
else
{
!
$this->Link_ID=sybase_connect($Host,$User,$Password);
}
}
***************
*** 49,56 ****
$this->halt('Link-ID == false,
'.($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'')..'connect failed');
}
! if(!sybase_select_db($this->Database, $this->Link_ID))
{
! $this->halt('cannot use database
'.$this->Database);
}
}
--- 53,69 ----
$this->halt('Link-ID == false,
'.($GLOBALS['phpgw_info']['server']['db_persistent']?'p':'')..'connect failed');
}
! if(!sybase_select_db($Database, $this->Link_ID))
{
! $this->halt('cannot use database '.$Database);
! }
! }
!
! function db_addslashes($str)
! {
! if (!IsSet($str) || $str == '')
! {
! return '';
}
+ return str_replace("'", "''", $str);
}
***************
*** 137,158 ****
}
! function nf()
! {
! return $this->num_rows();
! }
!
! function np()
! {
! print $this->num_rows();
! }
!
! function f($Name)
! {
! return $this->Record[$Name];
! }
!
! function p($Name)
{
! print $this->Record[$Name];
}
--- 150,163 ----
}
! function f($Name, $strip_slashes = False)
{
! if ($strip_slashes || ($this->auto_stripslashes && !
$strip_slashes))
! {
! return str_replace("''", "'",
$this->Record[$Name]);
! }
! else
! {
! return $this->Record[$Name];
! }
}
Index: class.db_oracle.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.db_oracle.inc.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** class.db_oracle.inc.php 18 Apr 2002 19:14:25 -0000 1.8
--- class.db_oracle.inc.php 9 Oct 2003 03:31:32 -0000 1.9
***************
*** 18,42 ****
class db
{
- var $Debug = False;
- var $Home = '/u01/app/oracle/product/8.0.4';
var $Remote = 1;
- /* Due to a strange error with Oracle 8.0.5, Apache and PHP3.0.6
- you don't need to set the ENV - on my system Apache
- will change to a zombie, if I don't set this to FALSE!
- If unsure try it out, if it works. */
- /* Milosch - omg, you aren't using 3.0.6 are you? */
- var $OraPutEnv = true;
-
- var $Database = '';
- var $User = '';
- var $Password = '';
-
- var $Link_ID = 0;
- var $Query_ID = 0;
- var $Record = array();
- var $Row;
- var $Errno = 0;
- var $Error = '';
var $ora_no_next_fetch = False;
--- 18,23 ----
***************
*** 46,81 ****
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 */
function db($query = '')
{
! $this->query($query);
! }
!
! /* public: some trivial reporting */
! function link_id()
! {
! return $this->Link_ID;
! }
!
! function query_id()
! {
! return $this->Query_ID;
}
! 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)
{
! printf('<br>Connecting to ' .
$this->Database . "...<br>\n");
}
if($this->Remote)
--- 27,61 ----
var $revision = '1.2';
/* public: constructor */
function db($query = '')
{
! $this->db_($query);
}
! function connect($Database = '', $Host = '', $User = '',
$Password = '')
{
! /* Handle defaults */
! if ($Database == '')
{
! $Database = $this->Database;
}
! if ($Host == '')
! {
! $Host = $this->Host;
! }
! if ($User == '')
! {
! $User = $this->User;
! }
! if ($Password == '')
! {
! $Password = $this->Password;
! }
!
! if (! $this->Link_ID)
{
if($this->Debug)
{
! printf('<br>Connecting to ' . $Database
. "...<br>\n");
}
if($this->Remote)
***************
*** 83,102 ****
if($this->Debug)
{
! printf("<br>connect()
$this->User/address@hidden>Database.world<br>\n");
}
if($GLOBALS['phpgw_info']['server']['db_persistent'])
{
! $this->Link_ID =
ora_plogon("$this->User/$this->address@hidden>Database","");
/************** (comment by
SSilk)
this dosn't work on my system:
! $this->Link_ID =
ora_plogon("$this->address@hidden>Database.world","$this->Password");
***************/
}
else
{
! $this->Link_ID =
ora_logon("$this->User/$this->address@hidden>Database","");
/************** (comment by
SSilk)
this dosn't work on my system:
!
$this->Link_ID=ora_logon("$this->address@hidden>Database.world","$this->Password");
***************/
}
--- 63,82 ----
if($this->Debug)
{
! printf("<br>connect()
$User/address@hidden<br>\n");
}
if($GLOBALS['phpgw_info']['server']['db_persistent'])
{
! $this->Link_ID =
ora_plogon("$User/address@hidden","");
/************** (comment by
SSilk)
this dosn't work on my system:
! $this->Link_ID =
ora_plogon("address@hidden","$Password");
***************/
}
else
{
! $this->Link_ID =
ora_logon("$User/address@hidden","");
/************** (comment by
SSilk)
this dosn't work on my system:
!
$this->Link_ID=ora_logon("address@hidden","$Password");
***************/
}
***************
*** 106,119 ****
if($this->Debug)
{
! printf("<br>connect()
$this->User, $this->Password <br>\n");
}
if($GLOBALS['phpgw_info']['server']['db_persistent'])
{
!
$this->Link_ID=ora_plogon("$this->User","$this->Password");
/* (comment by SSilk: don't
know how this could work, but I leave this untouched!) */
}
else
{
!
$this->Link_ID=ora_logon("$this->User","$this->Password");
}
}
--- 86,99 ----
if($this->Debug)
{
! printf("<br>connect() $User,
$Password <br>\n");
}
if($GLOBALS['phpgw_info']['server']['db_persistent'])
{
!
$this->Link_ID=ora_plogon("$User","$Password");
/* (comment by SSilk: don't
know how this could work, but I leave this untouched!) */
}
else
{
!
$this->Link_ID=ora_logon("$User","$Password");
}
}
***************
*** 122,126 ****
printf("<br>connect() Link_ID:
$this->Link_ID<br>\n");
}
! if(!$this->Link_ID)
{
$this->halt('connect() Link-ID == false
'
--- 102,106 ----
printf("<br>connect() Link_ID:
$this->Link_ID<br>\n");
}
! if (!$this->Link_ID)
{
$this->halt('connect() Link-ID == false
'
***************
*** 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;
}
--- 119,141 ----
}
! ## 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;
}
***************
*** 165,169 ****
$this->lastQuery=$Query_String;
! if(!$this->Query_ID)
{
$this->Query_ID = ora_open($this->Link_ID);
--- 143,147 ----
$this->lastQuery=$Query_String;
! if (!$this->Query_ID)
{
$this->Query_ID = ora_open($this->Link_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);
--- 159,163 ----
$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);
***************
*** 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",
--- 178,185 ----
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",
***************
*** 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)
{
--- 190,203 ----
$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)
{
***************
*** 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)
--- 206,244 ----
$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)
***************
*** 274,280 ****
}
! function lock($table, $mode='write')
{
! if($mode == 'write')
{
$result = ora_do($this->Link_ID, "lock table
$table in row exclusive mode");
--- 249,255 ----
}
! function lock($table, $mode = 'write')
{
! if ($mode == 'write')
{
$result = ora_do($this->Link_ID, "lock table
$table in row exclusive mode");
***************
*** 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];
--- 307,326 ----
$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];
***************
*** 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 ';
--- 328,332 ----
$res[$i]['type'] = $this->Record[data_type];
$res[$i]['len'] = $this->Record[data_length];
! if ($this->Record[index_name])
{
$res[$i]['flags'] = 'INDEX ';
***************
*** 362,366 ****
$res[$i]['format']=
(int)$this->Record['data_precision'].','.
(int)$this->Record[data_scale];
! if('0,0'==$res[$i]['format'])
{
$res[$i]['format']='';
--- 335,339 ----
$res[$i]['format']=
(int)$this->Record['data_precision'].','.
(int)$this->Record[data_scale];
! if ('0,0'==$res[$i]['format'])
{
$res[$i]['format']='';
***************
*** 368,372 ****
$res[$i]['index'] = $this->Record[index_name];
$res[$i]['chars'] =
$this->Record[char_col_decl_length];
! if($full)
{
$j=$res[$i]['name'];
--- 341,345 ----
$res[$i]['index'] = $this->Record[index_name];
$res[$i]['chars'] =
$this->Record[char_col_decl_length];
! if ($full)
{
$j=$res[$i]['name'];
***************
*** 374,378 ****
$res['meta'][strtoupper($j)] = $i;
}
! if($full)
{
$res['meta'][$res[$i]['name']] = $i;
--- 347,351 ----
$res['meta'][strtoupper($j)] = $i;
}
! if ($full)
{
$res['meta'][$res[$i]['name']] = $i;
***************
*** 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>';
--- 353,368 ----
$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>';
***************
*** 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');
--- 371,389 ----
}
! ## 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');
***************
*** 422,426 ****
ORA_exec($curs);
ORA_fetch($curs);
! if($Debug)
{
echo '<BR>Debug: num_rows='.
ORA_getcolumn($curs,0).'<BR>';
--- 393,397 ----
ORA_exec($curs);
ORA_fetch($curs);
! if ($Debug)
{
echo '<BR>Debug: num_rows='.
ORA_getcolumn($curs,0).'<BR>';
***************
*** 443,466 ****
}
- function nf()
- {
- return $this->num_rows();
- }
-
- function np()
- {
- print $this->num_rows();
- }
-
- function f($Name)
- {
- return $this->Record[$Name];
- }
-
- function p($Name)
- {
- print $this->Record[$Name];
- }
-
/* public: sequence number */
function nextid($seq_name)
--- 414,417 ----
***************
*** 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))
--- 424,428 ----
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))
***************
*** 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);
--- 433,441 ----
@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);
***************
*** 494,498 ****
$next_id = 0;
}
! if($Query_ID > 0)
{
ora_close(Query_ID);
--- 445,449 ----
$next_id = 0;
}
! if ( Query_ID > 0 )
{
ora_close(Query_ID);
***************
*** 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;
}
--- 458,468 ----
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;
}
***************
*** 519,523 ****
function halt($msg)
{
! if($this->Halt_On_Error == 'no')
{
return;
--- 470,474 ----
function halt($msg)
{
! if ($this->Halt_On_Error == 'no')
{
return;
***************
*** 526,530 ****
$this->haltmsg($msg);
! if($this->Halt_On_Error != 'report')
{
die('Session halted.');
--- 477,481 ----
$this->haltmsg($msg);
! if ($this->Halt_On_Error != 'report')
{
die('Session halted.');
***************
*** 544,549 ****
$this->connect();
$this->query('SELECT table_name,tablespace_name FROM
user_tables');
! $i = 0;
! while($this->next_record())
{
$info[$i]['table_name'] =
strtolower($this->Record['table_name']);
--- 495,500 ----
$this->connect();
$this->query('SELECT table_name,tablespace_name FROM
user_tables');
! $i=0;
! while ($this->next_record())
{
$info[$i]['table_name'] =
strtolower($this->Record['table_name']);
Index: class.db_mysql.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.db_mysql.inc.php,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** class.db_mysql.inc.php 13 Aug 2003 10:56:01 -0000 1.38
--- class.db_mysql.inc.php 9 Oct 2003 03:31:32 -0000 1.39
***************
*** 1,64 ****
<?php
! /**************************************************************************\
! * phpGroupWare API - MySQL database support *
! * Copyright (c) 1998-2000 NetUSE AG Boris Erdmann, Kristian Koehntopp *
! * ------------------------------------------------------------------------ *
! * This is not part of phpGroupWare, but is used by phpGroupWare.
*
! * http://www.phpgroupware.org/
*
! * ------------------------------------------------------------------------ *
! * This program is free software; you can redistribute it and/or modify it *
! * under the terms of the GNU Lesser General Public License as published *
! * by the Free Software Foundation; either version 2.1 of the License, or *
! * any later version. *
! \**************************************************************************/
!
! /* $Id$ */
! class db
{
- /* public: connection parameters */
- var $Host = '';
- var $Database = '';
- var $User = '';
- var $Password = '';
-
- /* public: configuration parameters */
- var $auto_stripslashes = False;
- var $Auto_Free = 0; ## Set to 1 for automatic
mysql_free_result()
- var $Debug = 0; ## Set to 1 for debugging messages.
- var $Halt_On_Error = 'yes'; ## "yes" (halt with message), "no"
(ignore errors quietly), "report" (ignore errror, but spit a warning)
- var $Seq_Table = 'db_sequence';
-
- /* public: result array and current row number */
- var $Record = array();
- var $Row;
-
- /* public: current error number and error text */
- var $Errno = 0;
- var $Error = '';
-
/* public: this is an api revision, not a CVS revision. */
var $type = 'mysql';
var $revision = '1.2';
- /* private: link and query handles */
- var $Link_ID = 0;
- var $Query_ID = 0;
-
- /* public: constructor */
function db($query = '')
{
! $this->query($query);
! }
!
! /* public: some trivial reporting */
! function link_id()
! {
! return $this->Link_ID;
! }
!
! function query_id()
! {
! return $this->Query_ID;
}
--- 1,29 ----
<?php
! /**********************************************************************\
! * phpGroupWare - API - Database Abstraction *
! * http://www.phpgroupware.org
*
! * This program is part of the GNU project, see http://www.gnu.org/ *
! * *
! * Portions Copyright 2001, 2002, 2003 Free Software Foundation, Inc. *
! * Based on phplib - Copyright 1998-2000 NetUSE AG, *
! * Boris Erdmann, Kristian Koehntopp *
! * Contributions from Dan Kuykendall, Dave Hall and others *
! * --------------------------------------------
*
! * This program is Free Software; you can redistribute it and/or *
! * modify it under the terms of the GNU Lesser General Public License
*
! * as published by the Free Software Foundation; either version 2.1 of *
! * the License, or (at your option) any later version.
*
! \**********************************************************************/
! /* $Id$ */
! class db extends db_
{
/* public: this is an api revision, not a CVS revision. */
var $type = 'mysql';
var $revision = '1.2';
function db($query = '')
{
! $this->db_($query);
}
***************
*** 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);
--- 32,55 ----
{
/* 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 (! $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.");
--- 60,64 ----
}
! 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;
}
--- 66,72 ----
}
! if (address@hidden($Database,$this->Link_ID))
{
! $this->halt("cannot use database
".$this->Database);
return 0;
}
***************
*** 125,138 ****
}
- function db_addslashes($str)
- {
- if(!isset($str) || $str == '')
- {
- return '';
- }
-
- return addslashes($str);
- }
-
function to_timestamp($epoch)
{
--- 90,93 ----
***************
*** 147,165 ****
}
- function limit($start)
- {
- 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;
- }
-
/* public: discard the query result */
function free()
--- 102,105 ----
***************
*** 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. */
--- 118,126 ----
* 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);
--- 128,137 ----
# 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);
}
--- 142,148 ----
$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;
--- 154,163 ----
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);
--- 168,172 ----
}
! 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.');
--- 179,183 ----
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();
--- 191,195 ----
$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;
--- 202,206 ----
{
$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.
--- 208,213 ----
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.
***************
*** 280,298 ****
}
- function transaction_begin()
- {
- return True;
- }
-
- function transaction_commit()
- {
- return True;
- }
-
- function transaction_abort()
- {
- return True;
- }
-
function get_last_insert_id($table, $field)
{
--- 220,223 ----
***************
*** 303,307 ****
*/
! if(!isset($table) || $table == '' || !isset($field) ||
$field == '')
{
return -1;
--- 228,232 ----
*/
! 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, ";
--- 241,250 ----
$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.");
--- 262,266 ----
}
$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;
}
--- 274,281 ----
$this->connect();
! $res = @mysql_query("unlock tables");
! if (!$res)
{
! $this->halt("unlock() failed.");
return 0;
}
***************
*** 358,361 ****
--- 283,287 ----
}
+
/* public: evaluate the result (size, width) */
function affected_rows()
***************
*** 374,405 ****
}
- /* public: shorthand notation */
- function nf()
- {
- return $this->num_rows();
- }
-
- function np()
- {
- print $this->num_rows();
- }
-
- function f($Name, $strip_slashes='')
- {
- if($strip_slashes || ($this->auto_stripslashes && !
$strip_slashes))
- {
- return stripslashes($this->Record[$Name]);
- }
- else
- {
- return $this->Record[$Name];
- }
- }
-
- function p($Name)
- {
- print $this->Record[$Name];
- }
-
/* public: sequence numbers */
function nextid($seq_name)
--- 300,303 ----
***************
*** 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);
--- 305,312 ----
$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);
***************
*** 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,
--- 315,322 ----
/* No current value, make one */
! if (!is_array($res))
{
$currentid = 0;
! $q = sprintf("insert into %s
values('%s', %s)",
$this->Seq_Table,
$seq_name,
***************
*** 428,435 ****
else
{
! $currentid = $res['nextid'];
}
$nextid = $currentid + 1;
! $q = sprintf("UPDATE %s SET nextid = '%s' WHERE
seq_name = '%s'",
$this->Seq_Table,
$nextid,
--- 326,333 ----
else
{
! $currentid = $res["nextid"];
}
$nextid = $currentid + 1;
! $q = sprintf("update %s set nextid = '%s' where
seq_name = '%s'",
$this->Seq_Table,
$nextid,
***************
*** 440,444 ****
else
{
! $this->halt('cannot lock ' . $this->Seq_Table .
' - has it been created?');
return 0;
}
--- 338,342 ----
else
{
! $this->halt("cannot lock ".$this->Seq_Table." -
has it been created?");
return 0;
}
***************
*** 447,451 ****
/* public: return table metadata */
! function metadata($table='',$full=False)
{
$count = 0;
--- 345,349 ----
/* public: return table metadata */
! function metadata($table='',$full=false)
{
$count = 0;
***************
*** 453,491 ****
$res = array();
- /*
- * Due to compatibility problems with Table we changed
the behavior
- * of metadata();
- * depending on $full, metadata returns the following
values:
- *
- * - full is false (default):
- * $result[]:
- * [0]["table"] table name
- * [0]["name"] field name
- * [0]["type"] field type
- * [0]["len"] field length
- * [0]["flags"] field flags
- *
- * - full is true
- * $result[]:
- * ["num_fields"] number of metadata records
- * [0]["table"] table name
- * [0]["name"] field name
- * [0]["type"] field type
- * [0]["len"] field length
- * [0]["flags"] field flags
- * ["meta"][field name] index of field named "field
name"
- * The last one is used, if you have a field name,
but no index.
- * Test: if (isset($result['meta']['myfield'])) { ...
- */
-
/* 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.');
}
}
--- 351,363 ----
$res = array();
/* 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.");
}
}
***************
*** 493,499 ****
{
$id = $this->Query_ID;
! if(!$id)
{
! $this->halt('No query specified.');
}
}
--- 365,371 ----
{
$id = $this->Query_ID;
! if (!$id)
{
! $this->halt("No query specified.");
}
}
***************
*** 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);
--- 374,380 ----
/* 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);
***************
*** 516,522 ****
{
/* full */
! $res['num_fields']= $count;
! for($i=0; $i<$count; $i++)
{
$res[$i]['table'] = @mysql_field_table
($id, $i);
--- 388,394 ----
{
/* full */
! $res["num_fields"]= $count;
! for ($i=0; $i<$count; $i++)
{
$res[$i]['table'] = @mysql_field_table
($id, $i);
***************
*** 530,534 ****
/* free the result only if we were called on a table */
! if($table)
{
@mysql_free_result($id);
--- 402,406 ----
/* free the result only if we were called on a table */
! if ($table)
{
@mysql_free_result($id);
***************
*** 553,569 ****
$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>';
! exit;
}
}
--- 425,441 ----
$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);
}
}
***************
*** 572,576 ****
{
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);
--- 444,448 ----
{
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);
***************
*** 582,591 ****
if (!$this->Link_ID)
{
return array();
}
$return = Array();
! $this->query('SHOW TABLES',__LINE__,__FILE__);
$i=0;
! while($info=mysql_fetch_row($this->Query_ID))
{
$return[$i]['table_name'] = $info[0];
--- 454,467 ----
if (!$this->Link_ID)
{
+ $this->connect();
+ }
+ if (!$this->Link_ID)
+ {
return array();
}
$return = Array();
! $this->query("SHOW TABLES");
$i=0;
! while (address@hidden($this->Query_ID))
{
$return[$i]['table_name'] = $info[0];
***************
*** 597,607 ****
}
! function index_names()
! {
! $return = array();
! return $return;
! }
!
! function create_database($adminname='', $adminpasswd='')
{
$currentUser = $this->User;
--- 473,477 ----
}
! function create_database($adminname = '', $adminpasswd = '')
{
$currentUser = $this->User;
***************
*** 609,621 ****
$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();
--- 479,491 ----
$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();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] phpgwapi/inc class.db.inc.php, 1.6, 1.7 class.db_msql.inc.php, 1.6, 1.7 class.db_mssql.inc.php, 1.23, 1.24 class.db_mysql.inc.php, 1.38, 1.39 class.db_odbc.inc.php, 1.5, 1.6 class.db_oracle.inc.php, 1.8, 1.9 class.db_pgsql.inc.php, 1.34, 1.35 class.db_sybase.inc.php, 1.7, 1.8,
Dave Hall <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] phpgwapi/inc class.contact_org.inc.php, 1.1.2.4, 1.1.2.5 class.contact_org_person.inc.php, 1.1.2.5, 1.1.2.6 class.contact_person.inc.php, 1.1.2.6, 1.1.2.7 class.contacts_sql.inc.php, 1.17.2.2.2.18, 1.17.2.2.2.19 class.sql_builder.inc.php, 1.1.2.9, 1.1.2.10 class.sql_entity.inc.php, 1.1.2.8, 1.1.2.9
- Next by Date:
[Phpgroupware-cvs] phpgwapi/inc class.db_mssql.inc.php, 1.20.2.1.2.2, 1.20.2.1.2.3
- Previous by thread:
[Phpgroupware-cvs] phpgwapi/inc class.contact_org.inc.php, 1.1.2.4, 1.1.2.5 class.contact_org_person.inc.php, 1.1.2.5, 1.1.2.6 class.contact_person.inc.php, 1.1.2.6, 1.1.2.7 class.contacts_sql.inc.php, 1.17.2.2.2.18, 1.17.2.2.2.19 class.sql_builder.inc.php, 1.1.2.9, 1.1.2.10 class.sql_entity.inc.php, 1.1.2.8, 1.1.2.9
- Next by thread:
[Phpgroupware-cvs] phpgwapi/inc class.db_mssql.inc.php, 1.20.2.1.2.2, 1.20.2.1.2.3
- Index(es):