mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 08:23:12 +01:00
Formatting
This commit is contained in:
parent
5d6721af18
commit
6ad604a565
@ -27,11 +27,11 @@
|
|||||||
|
|
||||||
var $Error = '';
|
var $Error = '';
|
||||||
|
|
||||||
var $Auto_Free = 0; ## Set this to 1 for automatic msql_free_result()
|
var $Auto_Free = 0; /* Set this to 1 for automatic msql_free_result() */
|
||||||
|
|
||||||
function connect()
|
function connect()
|
||||||
{
|
{
|
||||||
// Not connected? Then connect?
|
/* Not connected? Then connect? */
|
||||||
if ( 0 == $this->Link_ID )
|
if ( 0 == $this->Link_ID )
|
||||||
{
|
{
|
||||||
// Check for local connect
|
// Check for local connect
|
||||||
@ -40,7 +40,7 @@
|
|||||||
$this->Link_ID=msql_pconnect($this->Host);
|
$this->Link_ID=msql_pconnect($this->Host);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Still not connected? Raise error.
|
/* Still not connected? Raise error. */
|
||||||
if(0 == $this->Link_ID)
|
if(0 == $this->Link_ID)
|
||||||
{
|
{
|
||||||
$this->halt('Link-ID == false, pconnect failed');
|
$this->halt('Link-ID == false, pconnect failed');
|
||||||
@ -57,7 +57,7 @@
|
|||||||
{
|
{
|
||||||
$this->connect();
|
$this->connect();
|
||||||
|
|
||||||
# printf("Debug: query = %s<br>\n", $Query_String);
|
/* printf("Debug: query = %s<br>\n", $Query_String); */
|
||||||
|
|
||||||
$this->Query_ID = msql_query($Query_String,$this->Link_ID);
|
$this->Query_ID = msql_query($Query_String,$this->Link_ID);
|
||||||
$this->Row = 0;
|
$this->Row = 0;
|
||||||
|
@ -16,8 +16,9 @@
|
|||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/* echo "<BR>This is using the MSSQL class<BR>"; */
|
/* echo '<BR>This is using the MSSQL class<BR>'; */
|
||||||
// ^^ really ?! :)
|
/* ^^ really ?! :) */
|
||||||
|
/* mdean, put your info in the banner, mkay? */
|
||||||
|
|
||||||
class db
|
class db
|
||||||
{
|
{
|
||||||
@ -67,7 +68,7 @@
|
|||||||
|
|
||||||
function db_addslashes($str)
|
function db_addslashes($str)
|
||||||
{
|
{
|
||||||
if (!IsSet($str) || $str == '')
|
if(!isset($str) || $str == '')
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -298,7 +299,7 @@
|
|||||||
|
|
||||||
function lock($table, $mode="write")
|
function lock($table, $mode="write")
|
||||||
{
|
{
|
||||||
// /me really, really, really hates locks - transactions serve just fine
|
/* /me really, really, really hates locks - transactions serve just fine */
|
||||||
return $this->transaction_begin();
|
return $this->transaction_begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@
|
|||||||
|
|
||||||
if(!@mysql_select_db($Database,$this->Link_ID))
|
if(!@mysql_select_db($Database,$this->Link_ID))
|
||||||
{
|
{
|
||||||
$this->halt("cannot use database ".$this->Database);
|
$this->halt('cannot use database ' . $this->Database);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,11 +152,11 @@
|
|||||||
|
|
||||||
if($start == 0)
|
if($start == 0)
|
||||||
{
|
{
|
||||||
$s = 'limit ' . $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
|
$s = 'LIMIT ' . $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$s = "limit $start," . $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
|
$s = "LIMIT $start," . $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
|
||||||
}
|
}
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@
|
|||||||
$this->Error = mysql_error();
|
$this->Error = mysql_error();
|
||||||
if(!$this->Query_ID)
|
if(!$this->Query_ID)
|
||||||
{
|
{
|
||||||
$this->halt("Invalid SQL: ".$Query_String, $line, $file);
|
$this->halt('Invalid SQL: ' . $Query_String, $line, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Will return nada if it fails. That's fine.
|
# Will return nada if it fails. That's fine.
|
||||||
@ -267,7 +267,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->halt("seek($pos) failed: result has ".$this->num_rows()." rows");
|
$this->halt("seek($pos) failed: result has " . $this->num_rows() . ' rows');
|
||||||
/* half assed attempt to save the day,
|
/* half assed attempt to save the day,
|
||||||
* but do not consider this documented or even
|
* but do not consider this documented or even
|
||||||
* desireable behaviour.
|
* desireable behaviour.
|
||||||
@ -315,12 +315,12 @@
|
|||||||
{
|
{
|
||||||
$this->connect();
|
$this->connect();
|
||||||
|
|
||||||
$query = "lock tables ";
|
$query = 'LOCK TABLES ';
|
||||||
if(is_array($table))
|
if(is_array($table))
|
||||||
{
|
{
|
||||||
while(list($key,$value)=each($table))
|
while(list($key,$value)=each($table))
|
||||||
{
|
{
|
||||||
if ($key == "read" && $key!=0)
|
if($key == 'read' && $key!=0)
|
||||||
{
|
{
|
||||||
$query .= "$value read, ";
|
$query .= "$value read, ";
|
||||||
}
|
}
|
||||||
@ -348,16 +348,15 @@
|
|||||||
{
|
{
|
||||||
$this->connect();
|
$this->connect();
|
||||||
|
|
||||||
$res = @mysql_query("unlock tables");
|
$res = @mysql_query('UNLOCK TABLES');
|
||||||
if(!$res)
|
if(!$res)
|
||||||
{
|
{
|
||||||
$this->halt("unlock() failed.");
|
$this->halt('unlock() failed.');
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* public: evaluate the result (size, width) */
|
/* public: evaluate the result (size, width) */
|
||||||
function affected_rows()
|
function affected_rows()
|
||||||
{
|
{
|
||||||
@ -385,7 +384,7 @@
|
|||||||
print $this->num_rows();
|
print $this->num_rows();
|
||||||
}
|
}
|
||||||
|
|
||||||
function f($Name, $strip_slashes = "")
|
function f($Name, $strip_slashes='')
|
||||||
{
|
{
|
||||||
if($strip_slashes || ($this->auto_stripslashes && ! $strip_slashes))
|
if($strip_slashes || ($this->auto_stripslashes && ! $strip_slashes))
|
||||||
{
|
{
|
||||||
@ -410,7 +409,7 @@
|
|||||||
if($this->lock($this->Seq_Table))
|
if($this->lock($this->Seq_Table))
|
||||||
{
|
{
|
||||||
/* get sequence number (locked) and increment */
|
/* get sequence number (locked) and increment */
|
||||||
$q = sprintf("select nextid from %s where seq_name = '%s'",
|
$q = sprintf("SELECT nextid FROM %s WHERE seq_name = '%s'",
|
||||||
$this->Seq_Table,
|
$this->Seq_Table,
|
||||||
$seq_name);
|
$seq_name);
|
||||||
$id = @mysql_query($q, $this->Link_ID);
|
$id = @mysql_query($q, $this->Link_ID);
|
||||||
@ -420,7 +419,7 @@
|
|||||||
if(!is_array($res))
|
if(!is_array($res))
|
||||||
{
|
{
|
||||||
$currentid = 0;
|
$currentid = 0;
|
||||||
$q = sprintf("insert into %s values('%s', %s)",
|
$q = sprintf("INSERT INTO %s VALUES('%s', %s)",
|
||||||
$this->Seq_Table,
|
$this->Seq_Table,
|
||||||
$seq_name,
|
$seq_name,
|
||||||
$currentid);
|
$currentid);
|
||||||
@ -428,10 +427,10 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$currentid = $res["nextid"];
|
$currentid = $res['nextid'];
|
||||||
}
|
}
|
||||||
$nextid = $currentid + 1;
|
$nextid = $currentid + 1;
|
||||||
$q = sprintf("update %s set nextid = '%s' where seq_name = '%s'",
|
$q = sprintf("UPDATE %s SET nextid = '%s' WHERE seq_name = '%s'",
|
||||||
$this->Seq_Table,
|
$this->Seq_Table,
|
||||||
$nextid,
|
$nextid,
|
||||||
$seq_name);
|
$seq_name);
|
||||||
@ -440,14 +439,14 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->halt("cannot lock ".$this->Seq_Table." - has it been created?");
|
$this->halt('cannot lock ' . $this->Seq_Table . ' - has it been created?');
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return $nextid;
|
return $nextid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public: return table metadata */
|
/* public: return table metadata */
|
||||||
function metadata($table='',$full=false)
|
function metadata($table='',$full=False)
|
||||||
{
|
{
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$id = 0;
|
$id = 0;
|
||||||
@ -487,7 +486,7 @@
|
|||||||
$id = @mysql_list_fields($this->Database, $table);
|
$id = @mysql_list_fields($this->Database, $table);
|
||||||
if(!$id)
|
if(!$id)
|
||||||
{
|
{
|
||||||
$this->halt("Metadata query failed.");
|
$this->halt('Metadata query failed.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -495,7 +494,7 @@
|
|||||||
$id = $this->Query_ID;
|
$id = $this->Query_ID;
|
||||||
if(!$id)
|
if(!$id)
|
||||||
{
|
{
|
||||||
$this->halt("No query specified.");
|
$this->halt('No query specified.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -516,7 +515,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* full */
|
/* full */
|
||||||
$res["num_fields"]= $count;
|
$res['num_fields']= $count;
|
||||||
|
|
||||||
for($i=0; $i<$count; $i++)
|
for($i=0; $i<$count; $i++)
|
||||||
{
|
{
|
||||||
@ -544,7 +543,7 @@
|
|||||||
|
|
||||||
$this->Error = @mysql_error($this->Link_ID);
|
$this->Error = @mysql_error($this->Link_ID);
|
||||||
$this->Errno = @mysql_errno($this->Link_ID);
|
$this->Errno = @mysql_errno($this->Link_ID);
|
||||||
if ($this->Halt_On_Error == "no")
|
if($this->Halt_On_Error == 'no')
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -552,16 +551,16 @@
|
|||||||
|
|
||||||
if($file)
|
if($file)
|
||||||
{
|
{
|
||||||
printf("<br><b>File:</b> %s",$file);
|
printf('<br><b>File:</b> %s',$file);
|
||||||
}
|
}
|
||||||
if($line)
|
if($line)
|
||||||
{
|
{
|
||||||
printf("<br><b>Line:</b> %s",$line);
|
printf('<br><b>Line:</b> %s',$line);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->Halt_On_Error != "report")
|
if($this->Halt_On_Error != 'report')
|
||||||
{
|
{
|
||||||
echo "<p><b>Session halted.</b>";
|
echo '<p><b>Session halted.</b>';
|
||||||
$GLOBALS['phpgw']->common->phpgw_exit(True);
|
$GLOBALS['phpgw']->common->phpgw_exit(True);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -569,7 +568,7 @@
|
|||||||
function haltmsg($msg)
|
function haltmsg($msg)
|
||||||
{
|
{
|
||||||
printf("<b>Database error:</b> %s<br>\n", $msg);
|
printf("<b>Database error:</b> %s<br>\n", $msg);
|
||||||
if ($this->Errno != "0" && $this->Error != "()")
|
if($this->Errno != '0' && $this->Error != '()')
|
||||||
{
|
{
|
||||||
printf("<b>MySQL Error</b>: %s (%s)<br>\n",$this->Errno,$this->Error);
|
printf("<b>MySQL Error</b>: %s (%s)<br>\n",$this->Errno,$this->Error);
|
||||||
}
|
}
|
||||||
@ -577,7 +576,7 @@
|
|||||||
|
|
||||||
function table_names()
|
function table_names()
|
||||||
{
|
{
|
||||||
$this->query("SHOW TABLES");
|
$this->query('SHOW TABLES');
|
||||||
$i=0;
|
$i=0;
|
||||||
while($info=mysql_fetch_row($this->Query_ID))
|
while($info=mysql_fetch_row($this->Query_ID))
|
||||||
{
|
{
|
||||||
@ -605,11 +604,11 @@
|
|||||||
{
|
{
|
||||||
$this->User = $adminname;
|
$this->User = $adminname;
|
||||||
$this->Password = $adminpasswd;
|
$this->Password = $adminpasswd;
|
||||||
$this->Database = "mysql";
|
$this->Database = 'mysql';
|
||||||
}
|
}
|
||||||
$this->disconnect();
|
$this->disconnect();
|
||||||
$this->query("CREATE DATABASE $currentDatabase");
|
$this->query('CREATE DATABASE ' . $currentDatabase);
|
||||||
$this->query("grant all on $currentDatabase.* to $currentUser@localhost identified by '$currentPassword'");
|
$this->query("GRANT all on $currentDatabase.* to $currentUser@localhost IDENTIFIED BY '$currentPassword'");
|
||||||
$this->disconnect();
|
$this->disconnect();
|
||||||
|
|
||||||
$this->User = $currentUser;
|
$this->User = $currentUser;
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
var $type = 'oracle';
|
var $type = 'oracle';
|
||||||
var $revision = '1.2';
|
var $revision = '1.2';
|
||||||
|
|
||||||
var $Halt_On_Error = 'yes'; ## 'yes' (halt with message), 'no' (ignore errors quietly), 'report' (ignore errror, but spit a warning)
|
var $Halt_On_Error = 'yes'; /* 'yes' (halt with message), 'no' (ignore errors quietly), 'report' (ignore errror, but spit a warning) */
|
||||||
|
|
||||||
/* public: constructor */
|
/* public: constructor */
|
||||||
function db($query = '')
|
function db($query = '')
|
||||||
@ -66,7 +66,7 @@
|
|||||||
|
|
||||||
function connect()
|
function connect()
|
||||||
{
|
{
|
||||||
## see above why we do this
|
/* see above for why we do this */
|
||||||
if($this->OraPutEnv)
|
if($this->OraPutEnv)
|
||||||
{
|
{
|
||||||
PutEnv("ORACLE_SID=$this->Database");
|
PutEnv("ORACLE_SID=$this->Database");
|
||||||
@ -138,15 +138,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
## 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
|
* In order to increase the # of cursors per system/user go edit the
|
||||||
## the default value, 100 per user.
|
* init.ora file and increase the max_open_cursors parameter. Yours is on
|
||||||
## We tried to change the behaviour of query() in a way, that it tries
|
* the default value, 100 per user.
|
||||||
## to safe cursors, but on the other side be carefull with this, that you
|
* We tried to change the behaviour of query() in a way, that it tries
|
||||||
## don't use an old result.
|
* 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.
|
* You can also make extensive use of ->disconnect()!
|
||||||
|
* The unused QueryIDs will be recycled sometimes.
|
||||||
|
*/
|
||||||
|
|
||||||
function query($Query_String)
|
function query($Query_String)
|
||||||
{
|
{
|
||||||
@ -209,7 +211,8 @@
|
|||||||
|
|
||||||
$errno=ora_errorcode($this->Query_ID);
|
$errno=ora_errorcode($this->Query_ID);
|
||||||
if(1403 == $errno)
|
if(1403 == $errno)
|
||||||
{ # 1043 means no more records found
|
{
|
||||||
|
/* 1043 means no more records found */
|
||||||
$this->Errno = 0;
|
$this->Errno = 0;
|
||||||
$this->Error = '';
|
$this->Error = '';
|
||||||
$this->disconnect();
|
$this->disconnect();
|
||||||
@ -230,36 +233,38 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->no_next_fetch=false;
|
$this->no_next_fetch = False;
|
||||||
for($ix=0;$ix<ora_numcols($this->Query_ID);$ix++)
|
for($ix=0;$ix<ora_numcols($this->Query_ID);$ix++)
|
||||||
{
|
{
|
||||||
$col=strtolower(ora_columnname($this->Query_ID,$ix));
|
$col=strtolower(ora_columnname($this->Query_ID,$ix));
|
||||||
$value=ora_getcolumn($this->Query_ID,$ix);
|
$value=ora_getcolumn($this->Query_ID,$ix);
|
||||||
$this->Record["$col"] = $value;
|
$this->Record["$col"] = $value;
|
||||||
# echo"<b>[$col]</b>: $value <br>\n";
|
/* echo"<b>[$col]</b>: $value <br>\n"; */
|
||||||
}
|
}
|
||||||
$stat = 1;
|
$stat = 1;
|
||||||
}
|
}
|
||||||
return $stat;
|
return $stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
## seek() works only for $pos - 1 and $pos
|
/*
|
||||||
## Perhaps I make a own implementation, but my
|
* seek() works only for $pos - 1 and $pos
|
||||||
## opinion is, that this should be done by PHP3
|
* Perhaps I make a own implementation, but my
|
||||||
|
* opinion is, that this should be done by PHP3
|
||||||
|
*/
|
||||||
function seek($pos)
|
function seek($pos)
|
||||||
{
|
{
|
||||||
if($this->Row - 1 == $pos)
|
if($this->Row - 1 == $pos)
|
||||||
{
|
{
|
||||||
$this->no_next_fetch=true;
|
$this->no_next_fetch = True;
|
||||||
}
|
}
|
||||||
elseif($this->Row == $pos)
|
elseif($this->Row == $pos)
|
||||||
{
|
{
|
||||||
## do nothing
|
/* do nothing */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->halt("Invalid seek(): Position is cannot be handled by API.<BR>".
|
$this->halt('Invalid seek(): Position cannot be handled by API.<BR>'
|
||||||
"Difference too big. Wanted: $pos Current pos: $this->Row");
|
. "Difference too big. Wanted: $pos Current pos: $this->Row");
|
||||||
}
|
}
|
||||||
if($Debug)
|
if($Debug)
|
||||||
{
|
{
|
||||||
@ -326,19 +331,21 @@
|
|||||||
|
|
||||||
$this->connect();
|
$this->connect();
|
||||||
|
|
||||||
## This is a RIGHT OUTER JOIN: '(+)', if you want to see, what
|
/*
|
||||||
## this query results try the following:
|
* This is a RIGHT OUTER JOIN: '(+)', if you want to see, what
|
||||||
## $table = new Table; $db = new my_DB_Sql; # you have to make
|
* this query results try the following:
|
||||||
## # your own class
|
* $table = new Table; $db = new my_DB_Sql;
|
||||||
## $table->show_results($db->query(see query vvvvvv))
|
* 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".
|
$this->query("SELECT T.table_name,T.column_name,T.data_type,"
|
||||||
" FROM ALL_TAB_COLUMNS T,ALL_IND_COLUMNS I".
|
. "T.data_length,T.data_precision,T.data_scale,T.nullable,"
|
||||||
" WHERE T.column_name=I.column_name (+)".
|
. "T.char_col_decl_length,I.index_name"
|
||||||
" AND T.table_name=I.table_name (+)".
|
. " FROM ALL_TAB_COLUMNS T,ALL_IND_COLUMNS I"
|
||||||
" AND T.table_name=UPPER('$table') ORDER BY T.column_id");
|
. " 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;
|
$i=0;
|
||||||
while($this->next_record())
|
while($this->next_record())
|
||||||
@ -376,11 +383,11 @@
|
|||||||
{
|
{
|
||||||
$res['num_fields']=$i;
|
$res['num_fields']=$i;
|
||||||
}
|
}
|
||||||
# $this->disconnect();
|
/* $this->disconnect(); */
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
## THIS FUNCTION IS UNSTESTED!
|
/* THIS FUNCTION IS UNSTESTED! */
|
||||||
function affected_rows()
|
function affected_rows()
|
||||||
{
|
{
|
||||||
if($Debug)
|
if($Debug)
|
||||||
@ -390,20 +397,22 @@
|
|||||||
return ora_numrows($this->Query_ID);
|
return ora_numrows($this->Query_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
## Known bugs: It will not work for SELECT DISTINCT and any
|
/*
|
||||||
## other constructs which are depending on the resulting rows.
|
* Known bugs: It will not work for SELECT DISTINCT and any
|
||||||
## So you *really need* to check every query you make, if it
|
* other constructs which are depending on the resulting rows.
|
||||||
## will work with it.
|
* 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 ...').
|
* Also, for a qualified replacement you need to parse the
|
||||||
## 'FROM' is - as far as I know a keyword in Oracle, so it can
|
* selection, cause this will fail: 'SELECT id, from FROM ...').
|
||||||
## only be used in this way. But you have been warned.
|
* '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()
|
function num_rows()
|
||||||
{
|
{
|
||||||
$curs=ora_open($this->Link_ID);
|
$curs=ora_open($this->Link_ID);
|
||||||
|
|
||||||
## this is the important part and it is also the HACK!
|
/* this is the important part and it is also the HACK! */
|
||||||
if(eregi("^[[:space:]]*SELECT[[:space:]]",$this->lastQuery) )
|
if(eregi("^[[:space:]]*SELECT[[:space:]]",$this->lastQuery) )
|
||||||
{
|
{
|
||||||
$from_pos = strpos(strtoupper($this->lastQuery),'FROM');
|
$from_pos = strpos(strtoupper($this->lastQuery),'FROM');
|
||||||
@ -463,7 +472,7 @@
|
|||||||
|
|
||||||
if(!@ora_parse($Query_ID,"SELECT $seq_name.NEXTVAL FROM DUAL"))
|
if(!@ora_parse($Query_ID,"SELECT $seq_name.NEXTVAL FROM DUAL"))
|
||||||
{
|
{
|
||||||
// There is no such sequence yet, then create it
|
/* There is no such sequence yet, then create it */
|
||||||
if(!@ora_parse($Query_ID,"CREATE SEQUENCE $seq_name") ||
|
if(!@ora_parse($Query_ID,"CREATE SEQUENCE $seq_name") ||
|
||||||
!@ora_exec($Query_ID))
|
!@ora_exec($Query_ID))
|
||||||
{
|
{
|
||||||
@ -484,7 +493,7 @@
|
|||||||
{
|
{
|
||||||
$next_id = 0;
|
$next_id = 0;
|
||||||
}
|
}
|
||||||
if ( Query_ID > 0 )
|
if($Query_ID > 0)
|
||||||
{
|
{
|
||||||
ora_close(Query_ID);
|
ora_close(Query_ID);
|
||||||
}
|
}
|
||||||
@ -500,7 +509,7 @@
|
|||||||
if($this->Query_ID < 1)
|
if($this->Query_ID < 1)
|
||||||
{
|
{
|
||||||
echo "<B>Warning</B>: disconnect(): Cannot free ID $this->Query_ID\n";
|
echo "<B>Warning</B>: disconnect(): Cannot free ID $this->Query_ID\n";
|
||||||
# return();
|
/* return(); */
|
||||||
}
|
}
|
||||||
ora_close($this->Query_ID);
|
ora_close($this->Query_ID);
|
||||||
$this->Query_ID = 0;
|
$this->Query_ID = 0;
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
var $auto_stripslashes = False;
|
var $auto_stripslashes = False;
|
||||||
|
|
||||||
/* "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning) */
|
/* 'yes' (halt with message), 'no' (ignore errors quietly), 'report' (ignore errror, but spit a warning) */
|
||||||
var $Halt_On_Error = 'yes';
|
var $Halt_On_Error = 'yes';
|
||||||
|
|
||||||
var $Link_ID = 0;
|
var $Link_ID = 0;
|
||||||
@ -40,10 +40,10 @@
|
|||||||
/* Set this to 1 for automatic pg_freeresult on last record. */
|
/* Set this to 1 for automatic pg_freeresult on last record. */
|
||||||
var $Auto_Free = 0;
|
var $Auto_Free = 0;
|
||||||
|
|
||||||
// PostgreSQL changed somethings from 6.x -> 7.x
|
/* PostgreSQL changed some things from 6.x -> 7.x */
|
||||||
var $db_version;
|
var $db_version;
|
||||||
|
|
||||||
// For our error handling
|
/* For our error handling */
|
||||||
var $xmlrpc = False;
|
var $xmlrpc = False;
|
||||||
var $soap = False;
|
var $soap = False;
|
||||||
|
|
||||||
@ -95,7 +95,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->query("select version()",__LINE__,__FILE__);
|
$this->query('SELECT version()',__LINE__,__FILE__);
|
||||||
$this->next_record();
|
$this->next_record();
|
||||||
|
|
||||||
$version = $this->f('version');
|
$version = $this->f('version');
|
||||||
@ -130,26 +130,26 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For PostgreSQL 6.x
|
/* For PostgreSQL 6.x */
|
||||||
function to_timestamp_6($epoch)
|
function to_timestamp_6($epoch)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For PostgreSQL 6.x
|
/* For PostgreSQL 6.x */
|
||||||
function from_timestamp_6($timestamp)
|
function from_timestamp_6($timestamp)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For PostgreSQL 7.x
|
/* For PostgreSQL 7.x */
|
||||||
function to_timestamp_7($epoch)
|
function to_timestamp_7($epoch)
|
||||||
{
|
{
|
||||||
// This needs the GMT offset!
|
/* This needs the GMT offset! */
|
||||||
return date('Y-m-d H:i:s-00',$epoch);
|
return date('Y-m-d H:i:s-00',$epoch);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For PostgreSQL 7.x
|
/* For PostgreSQL 7.x */
|
||||||
function from_timestamp_7($timestamp)
|
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);
|
ereg('([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})',$timestamp,$parts);
|
||||||
@ -157,19 +157,17 @@
|
|||||||
return mktime($parts[4],$parts[5],$parts[6],$parts[2],$parts[3],$parts[1]);
|
return mktime($parts[4],$parts[5],$parts[6],$parts[2],$parts[3],$parts[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function limit($start)
|
function limit($start)
|
||||||
{
|
{
|
||||||
echo '<b>Warning: limit() is no longer used, use limit_query()</b>';
|
echo '<b>Warning: limit() is no longer used, use limit_query()</b>';
|
||||||
|
|
||||||
if ($start == 0)
|
if ($start == 0)
|
||||||
{
|
{
|
||||||
$s = 'limit ' . $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
|
$s = 'LIMIT ' . $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$s = 'limit ' . $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] . ',' . $start;
|
$s = 'LIMIT ' . $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] . ',' . $start;
|
||||||
}
|
}
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
@ -182,7 +180,7 @@
|
|||||||
|
|
||||||
function db_addslashes($str)
|
function db_addslashes($str)
|
||||||
{
|
{
|
||||||
if (!IsSet($str) || $str == '')
|
if(!isset($str) || $str == '')
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -245,7 +243,7 @@
|
|||||||
return $this->query($Query_String, $line, $file);
|
return $this->query($Query_String, $line, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public: discard the query result
|
/* public: discard the query result */
|
||||||
function free()
|
function free()
|
||||||
{
|
{
|
||||||
@pg_freeresult($this->Query_ID);
|
@pg_freeresult($this->Query_ID);
|
||||||
@ -314,7 +312,7 @@
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = @pg_Exec($this->Link_ID, "select $field from $table where oid=$oid");
|
$result = @pg_Exec($this->Link_ID, "SELECT $field FROM $table WHERE oid=$oid");
|
||||||
if(!$result)
|
if(!$result)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
@ -370,7 +368,7 @@
|
|||||||
if($this->lock($this->Seq_Table))
|
if($this->lock($this->Seq_Table))
|
||||||
{
|
{
|
||||||
/* get sequence number (locked) and increment */
|
/* get sequence number (locked) and increment */
|
||||||
$q = sprintf("select nextid from %s where seq_name = '%s'",
|
$q = sprintf("SELECT nextid FROM %s WHERE seq_name = '%s'",
|
||||||
$this->Seq_Table,
|
$this->Seq_Table,
|
||||||
$seq_name);
|
$seq_name);
|
||||||
$id = @pg_Exec($this->Link_ID, $q);
|
$id = @pg_Exec($this->Link_ID, $q);
|
||||||
@ -380,7 +378,7 @@
|
|||||||
if(!is_array($res))
|
if(!is_array($res))
|
||||||
{
|
{
|
||||||
$currentid = 0;
|
$currentid = 0;
|
||||||
$q = sprintf("insert into %s values('%s', %s)",
|
$q = sprintf("INSERT INTO %s VALUES('%s', %s)",
|
||||||
$this->Seq_Table,
|
$this->Seq_Table,
|
||||||
$seq_name,
|
$seq_name,
|
||||||
$currentid);
|
$currentid);
|
||||||
@ -391,7 +389,7 @@
|
|||||||
$currentid = $res['nextid'];
|
$currentid = $res['nextid'];
|
||||||
}
|
}
|
||||||
$nextid = $currentid + 1;
|
$nextid = $currentid + 1;
|
||||||
$q = sprintf("update %s set nextid = '%s' where seq_name = '%s'",
|
$q = sprintf("UPDATE %s SET nextid = '%s' WHERE seq_name = '%s'",
|
||||||
$this->Seq_Table,
|
$this->Seq_Table,
|
||||||
$nextid,
|
$nextid,
|
||||||
$seq_name);
|
$seq_name);
|
||||||
@ -413,7 +411,7 @@
|
|||||||
$res = array();
|
$res = array();
|
||||||
|
|
||||||
$this->connect();
|
$this->connect();
|
||||||
$id = pg_exec($this->Link_ID, "select * from $table");
|
$id = pg_exec($this->Link_ID, "SELECT * FROM $table");
|
||||||
if($id < 0)
|
if($id < 0)
|
||||||
{
|
{
|
||||||
$this->Error = pg_ErrorMessage($id);
|
$this->Error = pg_ErrorMessage($id);
|
||||||
@ -507,7 +505,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$s .= sprintf("<br><b>File:</b> %s",$file);
|
$s .= sprintf('<br><b>File:</b> %s',$file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -548,7 +546,7 @@
|
|||||||
|
|
||||||
function table_names()
|
function table_names()
|
||||||
{
|
{
|
||||||
$this->query("select relname from pg_class where relkind = 'r' and not relname like 'pg_%'");
|
$this->query("SELECT relname FROM pg_class WHERE relkind = 'r' AND NOT relname LIKE 'pg_%'");
|
||||||
$i=0;
|
$i=0;
|
||||||
while($this->next_record())
|
while($this->next_record())
|
||||||
{
|
{
|
||||||
@ -580,7 +578,7 @@
|
|||||||
$currentPassword = $this->Password;
|
$currentPassword = $this->Password;
|
||||||
$currentDatabase = $this->Database;
|
$currentDatabase = $this->Database;
|
||||||
|
|
||||||
if ($adminname != "")
|
if($adminname != '')
|
||||||
{
|
{
|
||||||
$this->User = $adminname;
|
$this->User = $adminname;
|
||||||
$this->Password = $adminpasswd;
|
$this->Password = $adminpasswd;
|
||||||
@ -598,8 +596,8 @@
|
|||||||
if($outval != 0)
|
if($outval != 0)
|
||||||
{
|
{
|
||||||
/* either the rights r not available or the postmaster is not running .... */
|
/* either the rights r not available or the postmaster is not running .... */
|
||||||
echo 'database creation failure <BR>';
|
echo 'Database creation failure <BR>';
|
||||||
echo 'please setup the postreSQL database manually<BR>';
|
echo 'Please setup the postreSQL database manually<BR>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->User = $currentUser;
|
$this->User = $currentUser;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
var $Record = array();
|
var $Record = array();
|
||||||
var $Row;
|
var $Row;
|
||||||
|
|
||||||
var $Auto_Free = 0; ## Set this to 1 for automatic sybase_free_result()
|
var $Auto_Free = 0; /* Set this to 1 for automatic sybase_free_result() */
|
||||||
|
|
||||||
function connect()
|
function connect()
|
||||||
{
|
{
|
||||||
@ -58,7 +58,7 @@
|
|||||||
{
|
{
|
||||||
$this->connect();
|
$this->connect();
|
||||||
|
|
||||||
# printf("Debug: query = %s<br>\n", $Query_String);
|
/* printf("Debug: query = %s<br>\n", $Query_String); */
|
||||||
|
|
||||||
$this->Query_ID = sybase_query($Query_String,$this->Link_ID);
|
$this->Query_ID = sybase_query($Query_String,$this->Link_ID);
|
||||||
$this->Row = 0;
|
$this->Row = 0;
|
||||||
@ -118,7 +118,6 @@
|
|||||||
$res[$i]['len'] = sybase_result ($result, $i, 'LENGTH');
|
$res[$i]['len'] = sybase_result ($result, $i, 'LENGTH');
|
||||||
$res[$i]['position'] = sybase_result ($result, $i, 'ORDINAL_POSITION');
|
$res[$i]['position'] = sybase_result ($result, $i, 'ORDINAL_POSITION');
|
||||||
$res[$i]['flags'] = sybase_result ($result, $i, 'REMARKS');
|
$res[$i]['flags'] = sybase_result ($result, $i, 'REMARKS');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user