Upgraded to ADOdb 2.12

This commit is contained in:
martin 2002-06-13 12:31:58 +00:00
parent 22f4320bdb
commit b1a1b00aa6
58 changed files with 1259 additions and 369 deletions

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt. the BSD license will take precedence. See License.txt.
@ -18,13 +18,13 @@ V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reser
*/ */
/** /**
* convert a recordset into CSV format * convert a recordset into special format
* *
* @param rs the recordset * @param rs the recordset
* *
* @return the CSV formated data * @return the CSV formated data
*/ */
function &rs2csv(&$rs,$conn=false,$sql='') function _rs2serialize(&$rs,$conn=false,$sql='')
{ {
$max = ($rs) ? $rs->FieldCount() : 0; $max = ($rs) ? $rs->FieldCount() : 0;
@ -196,12 +196,13 @@ V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reser
// slurp in the data // slurp in the data
$MAXSIZE = 128000; $MAXSIZE = 128000;
$text = fread($fp,$MAXSIZE); $text = fread($fp,$MAXSIZE);
if (strlen($text) == $MAXSIZE) { $cnt = 1;
$text .= fread($fp,filesize($url)-$MAXSIZE); while (strlen($text) == $MAXSIZE*$cnt) {
$text .= fread($fp,$MAXSIZE);
$cnt += 1;
} }
fclose($fp); fclose($fp);
//$text = substr($text,0,44);
$arr = @unserialize($text); $arr = @unserialize($text);
//var_dump($arr); //var_dump($arr);

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* @version V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. * @version V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license. * Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* @version V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. * @version V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license. * Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt. the BSD license will take precedence. See License.txt.
@ -9,14 +9,6 @@ V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reser
Less commonly used functions are placed here to reduce size of adodb.inc.php. Less commonly used functions are placed here to reduce size of adodb.inc.php.
*/ */
function _adodb_totalpages(&$rs)
{
if ($rs->rowsPerPage) {
$rows = ($rs->RecordCount()+$rs->rowsPerPage-1) / $rs->rowsPerPage;
if ($rows < 0) return -1;
else return $rows;
} else return -1;
}
// Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM // Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM
function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false, function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false,
@ -31,24 +23,29 @@ function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=f
} else if ($size) $attr = " size=$size"; } else if ($size) $attr = " size=$size";
else $attr =''; else $attr ='';
$s = "<select name=\"$name\"$attr $selectAttr>"; $s = "<select name=\"$name\"$attr $selectAttr>";
if ($blank1stItem) $s .= "\n<option></option>"; if ($blank1stItem) $s .= "\n<option></option>";
if ($zthis->FieldCount() > 1) $hasvalue=true; if ($zthis->FieldCount() > 1) $hasvalue=true;
else $compareFields0 = true; else $compareFields0 = true;
$value = '';
while(!$zthis->EOF) { while(!$zthis->EOF) {
$zval = trim($zthis->fields[0]); $zval = trim(reset($zthis->fields));
$selected = trim($zthis->fields[$compareFields0 ? 0 : 1]); if (sizeof($zthis->fields) > 1) {
if (isset($zthis->fields[1]))
$zval2 = trim($zthis->fields[1]);
else
$zval2 = trim(next($zthis->fields));
}
$selected = ($compareFields0) ? $zval : $zval2;
if ($blank1stItem && $zval=="") { if ($blank1stItem && $zval=="") {
$zthis->MoveNext(); $zthis->MoveNext();
continue; continue;
} }
if ($hasvalue) if ($hasvalue)
$value = 'value="'.htmlspecialchars(trim($zthis->fields[1])).'"'; $value = ' value="'.htmlspecialchars($zval2).'"';
if (is_array($defstr)) { if (is_array($defstr)) {
@ -69,7 +66,106 @@ function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=f
return $s ."\n</select>\n"; return $s ."\n</select>\n";
} }
function &_adodb_pageexecute(&$zthis, $sql, $nrows, $page, $inputarr=false, $arg3=false, $secs2cache=0) /*
Code originally from "Cornel G" <conyg@fx.ro>
This code will not work with SQL that has UNION in it
Also if you are using CachePageExecute(), there is a strong possibility that
data will get out of synch. use CachePageExecute() only with tables that
rarely change.
*/
function &_adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page,
$inputarr=false, $arg3=false, $secs2cache=0)
{
$atfirstpage = false;
$atlastpage = false;
$lastpageno=1;
// If an invalid nrows is supplied,
// we assume a default value of 10 rows per page
if (!isset($nrows) || $nrows <= 0) $nrows = 10;
$qryRecs = false; //count records for no offset
// jlim - attempt query rewrite first
$rewritesql = preg_replace(
'/^\s*SELECT\s.*\sFROM\s/is','SELECT COUNT(*) FROM ',$sql);
if ($rewritesql != $sql){
// fix by alexander zhukov, alex#unipack.ru, because count(*) and 'order by' fails
// with mssql, access and postgresql
$rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$rewritesql);
if ($secs2cache) {
// we only use half the time of secs2cache because the count can quickly
// become inaccurate if new records are added
$rs = $zthis->CacheExecute($secs2cache/2,$rewritesql);
if ($rs) {
if (!$rs->EOF) $qryRecs = reset($rs->fields);
$rs->Close();
}
} else $qryRecs = $zthis->GetOne($rewritesql);
if ($qryRecs !== false)
$lastpageno = (int) ceil($qryRecs / $nrows);
}
// query rewrite failed - so try slower way...
if ($qryRecs === false) {
$rstest = &$zthis->Execute($sql);
if ($rstest) {
//save total records
$qryRecs = $rstest->RecordCount();
if ($qryRecs == -1)
if (!$rstest->EOF) {
$rstest->MoveLast();
$qryRecs = $zthis->_currentRow;
} else
$qryRecs = 0;
$lastpageno = (int) ceil($qryRecs / $nrows);
}
if ($rstest) $rstest->Close();
}
$zthis->_maxRecordCount = $qryRecs;
// If page number <= 1, then we are at the first page
if (!isset($page) || $page <= 1) {
$page = 1;
$atfirstpage = true;
}
// ***** Here we check whether $page is the last page or
// whether we are trying to retrieve
// a page number greater than the last page number.
if ($page >= $lastpageno) {
$page = $lastpageno;
$atlastpage = true;
}
// We get the data we want
$offset = $nrows * ($page-1);
if ($secs2cache > 0)
$rsreturn = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr, $arg3);
else
$rsreturn = &$zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $arg3, $secs2cache);
// Before returning the RecordSet, we set the pagination properties we need
if ($rsreturn) {
$rsreturn->rowsPerPage = $nrows;
$rsreturn->AbsolutePage($page);
$rsreturn->AtFirstPage($atfirstpage);
$rsreturn->AtLastPage($atlastpage);
$rsreturn->LastPageNo($lastpageno);
}
return $rsreturn;
}
// Iván Oliva version
function &_adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr=false, $arg3=false, $secs2cache=0)
{ {
$atfirstpage = false; $atfirstpage = false;

View file

@ -0,0 +1,239 @@
<?php
/*
V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
This class provides recordset pagination with
First/Prev/Next/Last links.
Feel free to modify this class for your own use as
it is very basic. To learn how to use it, see the
example in adodb/tests/testpaging.php.
Please note, this class is entirely unsupported,
and no free support requests except for bug reports
will be entertained by the author.
My company also sells a commercial pagination
object at http://phplens.com/ with much more
functionality, including search, create, edit,
delete records.
*/
class ADODB_Pager {
var $id; // unique id for pager (defaults to 'adodb')
var $db; // ADODB connection object
var $sql; // sql used
var $rs; // recordset generated
var $curr_page; // current page number before Render() called, calculated in constructor
var $rows; // number of rows per page
var $gridAttributes = 'width=100% border=1 bgcolor=white';
// Localize text strings here
var $first = '<code>|&lt;</code>';
var $prev = '<code>&lt;&lt;</code>';
var $next = '<code>>></code>';
var $last = '<code>>|</code>';
var $page = 'Page';
var $cache = 0; #secs to cache with CachePageExecute()
//----------------------------------------------
// constructor
//
// $db adodb connection object
// $sql sql statement
// $id optional id to identify which pager,
// if you have multiple on 1 page.
// $id should be only be [a-z0-9]*
//
function ADODB_Pager(&$db,$sql,$id = 'adodb')
{
global $HTTP_SERVER_VARS,$PHP_SELF,$HTTP_SESSION_VARS,$HTTP_GET_VARS;
$curr_page = $id.'_curr_page';
if (empty($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
$this->sql = $sql;
$this->id = $id;
$this->db = $db;
$next_page = $id.'_next_page';
if (isset($HTTP_GET_VARS[$next_page])) {
$HTTP_SESSION_VARS[$curr_page] = $HTTP_GET_VARS[$next_page];
}
if (empty($HTTP_SESSION_VARS[$curr_page])) $HTTP_SESSION_VARS[$curr_page] = 1; ## at first page
$this->curr_page = $HTTP_SESSION_VARS[$curr_page];
}
//---------------------------
// Display link to first page
function Render_First($anchor=true)
{
global $PHP_SELF;
if ($anchor) {
?>
<a href="<?php echo $PHP_SELF,'?',$this->id;?>_next_page=1"><?php echo $this->first;?></a> &nbsp;
<?php
} else {
print "$this->first &nbsp; ";
}
}
//--------------------------
// Display link to next page
function render_next($anchor=true)
{
global $PHP_SELF;
if ($anchor) {
?>
<a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() + 1 ?>"><?php echo $this->next;?></a> &nbsp;
<?php
} else {
print "$this->next &nbsp; ";
}
}
//------------------
// Link to last page
//
// for better performance with large recordsets, you can set
// $this->db->pageExecuteCountRows = false, which disables
// last page counting.
function render_last($anchor=true)
{
global $PHP_SELF;
if (!$this->db->pageExecuteCountRows) return;
if ($anchor) {
?>
<a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->LastPageNo() ?>"><?php echo $this->last;?></a> &nbsp;
<?php
} else {
print "$this->last &nbsp; ";
}
}
//----------------------
// Link to previous page
function render_prev($anchor=true)
{
global $PHP_SELF;
if ($anchor) {
?>
<a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() - 1 ?>"><?php echo $this->prev;?></a> &nbsp;
<?php
} else {
print "$this->prev &nbsp; ";
}
}
//--------------------------------------------------------
// Simply rendering of grid. You should override this for
// better control over the format of the grid
//
// We use output buffering to keep code clean and readable.
function RenderGrid()
{
global $gSQLBlockRows; // used by rs2html to indicate how many rows to display
include_once(ADODB_DIR.'/tohtml.inc.php');
ob_start();
$gSQLBlockRows = $this->rows;
rs2html($this->rs,$this->gridAttributes);
$s = ob_get_contents();
ob_end_clean();
return $s;
}
//-------------------------------------------------------
// Navigation bar
//
// we use output buffering to keep the code easy to read.
function RenderNav()
{
ob_start();
if (!$this->rs->AtFirstPage()) {
$this->Render_First();
$this->Render_Prev();
} else {
$this->Render_First(false);
$this->Render_Prev(false);
}
if (!$this->rs->AtLastPage()) {
$this->Render_Next();
$this->Render_Last();
} else {
$this->Render_Next(false);
$this->Render_Last(false);
}
$s = ob_get_contents();
ob_end_clean();
return $s;
}
//-------------------
// This is the footer
function RenderPageCount()
{
if (!$this->db->pageExecuteCountRows) return '';
return "<font size=-1>$this->page ".$this->curr_page."/".$this->rs->LastPageNo()."</font>";
}
//-----------------------------------
// Call this class to draw everything.
function Render($rows=10)
{
global $ADODB_COUNTRECS;
$this->rows = $rows;
$savec = $ADODB_COUNTRECS;
if ($this->db->pageExecuteCountRows) $ADODB_COUNTRECS = true;
if ($this->cache)
$rs = &$this->db->CachePageExecute($this->cache,$this->sql,$rows,$this->curr_page);
else
$rs = &$this->db->PageExecute($this->sql,$rows,$this->curr_page);
$ADODB_COUNTRECS = $savec;
$this->rs = &$rs;
if (!$rs) {
print "<h3>Query failed: $this->sql</h3>";
return;
}
if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage()))
$header = $this->RenderNav();
else
$header = "&nbsp;";
$grid = $this->RenderGrid();
$footer = $this->RenderPageCount();
$rs->Close();
$this->rs = false;
$this->RenderLayout($header,$grid,$footer);
}
//------------------------------------------------------
// override this to control overall layout and formating
function RenderLayout($header,$grid,$footer)
{
echo "<table border=1 bgcolor=beige><tr><td>",
$header,
"</td></tr><tr><td>",
$grid,
"</td></tr><tr><td>",
$footer,
"</td></tr></table>";
}
}
?>

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* @version V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. * @version V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license. * Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses, * Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence. * the BSD license will take precedence.

View file

@ -1,11 +1,9 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Made table name configurable - by David Johnson djohnson@inpro.net
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Latest version of ADODB is available at http://php.weblogs.com/adodb Latest version of ADODB is available at http://php.weblogs.com/adodb
@ -28,8 +26,7 @@ wrapper library.
Installation Installation
============ ============
1. Create a new database in MySQL or Access "sessions" like 1. Create this table in your database (syntax might vary depending on your db):
so:
create table sessions ( create table sessions (
SESSKEY char(32) not null, SESSKEY char(32) not null,
@ -38,6 +35,7 @@ so:
primary key (sesskey) primary key (sesskey)
); );
2. Then define the following parameters in this file: 2. Then define the following parameters in this file:
$ADODB_SESSION_DRIVER='database driver, eg. mysql or ibase'; $ADODB_SESSION_DRIVER='database driver, eg. mysql or ibase';
$ADODB_SESSION_CONNECT='server to connect to'; $ADODB_SESSION_CONNECT='server to connect to';
@ -46,22 +44,22 @@ so:
$ADODB_SESSION_DB ='database'; $ADODB_SESSION_DB ='database';
$ADODB_SESSION_TBL = 'sessions' $ADODB_SESSION_TBL = 'sessions'
3. Recommended is PHP 4.0.2 or later. There are documented 3. Recommended is PHP 4.0.6 or later. There are documented
session bugs in session bugs in earlier versions of PHP.
earlier versions of PHP.
*/ */
if (!defined('_ADODB_LAYER')) { if (!defined('_ADODB_LAYER')) {
include ('adodb.inc.php'); include (dirname(__FILE__).'/adodb.inc.php');
} }
if (!defined('ADODB_SESSION')) { if (!defined('ADODB_SESSION')) {
define('ADODB_SESSION',1); define('ADODB_SESSION',1);
/****************************************************************************************\
Global definitions
\****************************************************************************************/
GLOBAL $ADODB_SESSION_CONNECT, GLOBAL $ADODB_SESSION_CONNECT,
$ADODB_SESSION_DRIVER, $ADODB_SESSION_DRIVER,
$ADODB_SESSION_USER, $ADODB_SESSION_USER,
@ -70,21 +68,8 @@ GLOBAL $ADODB_SESSION_CONNECT,
$ADODB_SESS_CONN, $ADODB_SESS_CONN,
$ADODB_SESS_LIFE, $ADODB_SESS_LIFE,
$ADODB_SESS_DEBUG, $ADODB_SESS_DEBUG,
$ADODB_SESS_INSERT; $ADODB_SESS_INSERT,
$ADODB_SESSION_CRC;
//$ADODB_SESS_DEBUG = true;
/* SET THE FOLLOWING PARAMETERS */
if (empty($ADODB_SESSION_DRIVER)) {
$ADODB_SESSION_DRIVER='mysql';
$ADODB_SESSION_CONNECT='localhost';
$ADODB_SESSION_USER ='root';
$ADODB_SESSION_PWD ='';
$ADODB_SESSION_DB ='xphplens_2';
}
if (empty($ADODB_SESSION_TBL)){
$ADODB_SESSION_TBL = 'sessions';
}
$ADODB_SESS_LIFE = get_cfg_var('session.gc_maxlifetime'); $ADODB_SESS_LIFE = get_cfg_var('session.gc_maxlifetime');
if ($ADODB_SESS_LIFE <= 1) { if ($ADODB_SESS_LIFE <= 1) {
@ -92,7 +77,31 @@ if ($ADODB_SESS_LIFE <= 1) {
//print "<h3>Session Error: PHP.INI setting <i>session.gc_maxlifetime</i>not set: $ADODB_SESS_LIFE</h3>"; //print "<h3>Session Error: PHP.INI setting <i>session.gc_maxlifetime</i>not set: $ADODB_SESS_LIFE</h3>";
$ADODB_SESS_LIFE=1440; $ADODB_SESS_LIFE=1440;
} }
$ADODB_SESSION_CRC = false;
//$ADODB_SESS_DEBUG = true;
//////////////////////////////////
/* SET THE FOLLOWING PARAMETERS */
//////////////////////////////////
if (empty($ADODB_SESSION_DRIVER)) {
$ADODB_SESSION_DRIVER='mysql';
$ADODB_SESSION_CONNECT='localhost';
$ADODB_SESSION_USER ='root';
$ADODB_SESSION_PWD ='';
$ADODB_SESSION_DB ='xphplens_2';
}
// Made table name configurable - by David Johnson djohnson@inpro.net
if (empty($ADODB_SESSION_TBL)){
$ADODB_SESSION_TBL = 'sessions';
}
/****************************************************************************************\
Create the connection to the database.
If $ADODB_SESS_CONN already exists, reuse that connection
\****************************************************************************************/
function adodb_sess_open($save_path, $session_name,$persist=true) function adodb_sess_open($save_path, $session_name,$persist=true)
{ {
GLOBAL $ADODB_SESS_CONN; GLOBAL $ADODB_SESS_CONN;
@ -106,18 +115,23 @@ GLOBAL $ADODB_SESSION_CONNECT,
$ADODB_SESSION_DB, $ADODB_SESSION_DB,
$ADODB_SESS_DEBUG; $ADODB_SESS_DEBUG;
// cannot use & below - do not know why...
$ADODB_SESS_CONN = ADONewConnection($ADODB_SESSION_DRIVER); $ADODB_SESS_CONN = ADONewConnection($ADODB_SESSION_DRIVER);
if (!empty($ADODB_SESS_DEBUG)) { if (!empty($ADODB_SESS_DEBUG)) {
$ADODB_SESS_CONN->debug = true; $ADODB_SESS_CONN->debug = true;
print " conn=$ADODB_SESSION_CONNECT user=$ADODB_SESSION_USER pwd=$ADODB_SESSION_PWD db=$ADODB_SESSION_DB "; print " conn=$ADODB_SESSION_CONNECT user=$ADODB_SESSION_USER pwd=$ADODB_SESSION_PWD db=$ADODB_SESSION_DB ";
} }
if ($persist) $ADODB_SESS_CONN->PConnect($ADODB_SESSION_CONNECT, if ($persist) $ok = $ADODB_SESS_CONN->PConnect($ADODB_SESSION_CONNECT,
$ADODB_SESSION_USER,$ADODB_SESSION_PWD,$ADODB_SESSION_DB); $ADODB_SESSION_USER,$ADODB_SESSION_PWD,$ADODB_SESSION_DB);
else $ADODB_SESS_CONN->Connect($ADODB_SESSION_CONNECT, else $ok = $ADODB_SESS_CONN->Connect($ADODB_SESSION_CONNECT,
$ADODB_SESSION_USER,$ADODB_SESSION_PWD,$ADODB_SESSION_DB); $ADODB_SESSION_USER,$ADODB_SESSION_PWD,$ADODB_SESSION_DB);
if (!$ok) print "<p>Session: connection failed</p>";
} }
/****************************************************************************************\
Close the connection
\****************************************************************************************/
function adodb_sess_close() function adodb_sess_close()
{ {
global $ADODB_SESS_CONN; global $ADODB_SESS_CONN;
@ -126,9 +140,13 @@ global $ADODB_SESS_CONN;
return true; return true;
} }
/****************************************************************************************\
Slurp in the session variables and return the serialized string
\****************************************************************************************/
function adodb_sess_read($key) function adodb_sess_read($key)
{ {
global $ADODB_SESS_CONN,$ADODB_SESS_INSERT,$ADODB_SESSION_TBL; global $ADODB_SESS_CONN,$ADODB_SESS_INSERT,$ADODB_SESSION_TBL,$ADODB_SESSION_CRC;
$ADODB_SESS_INSERT = false; $ADODB_SESS_INSERT = false;
$rs = $ADODB_SESS_CONN->Execute("SELECT data FROM $ADODB_SESSION_TBL WHERE sesskey = '$key' AND expiry >= " . time()); $rs = $ADODB_SESS_CONN->Execute("SELECT data FROM $ADODB_SESSION_TBL WHERE sesskey = '$key' AND expiry >= " . time());
if ($rs) { if ($rs) {
@ -139,19 +157,38 @@ global $ADODB_SESS_CONN,$ADODB_SESS_INSERT,$ADODB_SESSION_TBL;
$v = rawurldecode(reset($rs->fields)); $v = rawurldecode(reset($rs->fields));
$rs->Close(); $rs->Close();
// new optimization adodb 2.1
$ADODB_SESSION_CRC = crc32($v);
return $v; return $v;
} }
else $ADODB_SESS_INSERT = true; else $ADODB_SESS_INSERT = true;
return false; return ''; // thx to Jorma Tuomainen, webmaster#wizactive.com
} }
/****************************************************************************************\
Write the serialized data to a database.
If the data has not been modified since adodb_sess_read(), we do not write.
\****************************************************************************************/
function adodb_sess_write($key, $val) function adodb_sess_write($key, $val)
{ {
global $ADODB_SESS_INSERT,$ADODB_SESS_CONN, $ADODB_SESS_LIFE, $ADODB_SESSION_TBL; global $ADODB_SESS_INSERT,
$ADODB_SESS_CONN,
$ADODB_SESS_LIFE,
$ADODB_SESSION_TBL,
$ADODB_SESS_DEBUG,
$ADODB_SESSION_CRC;
$expiry = time() + $ADODB_SESS_LIFE; $expiry = time() + $ADODB_SESS_LIFE;
// new optimization adodb 2.1
if ($ADODB_SESSION_CRC !== false && $ADODB_SESSION_CRC == crc32($val)) {
if ($ADODB_SESS_DEBUG) echo "<p>Session: No need to update - crc32 not changed</p>";
return true;
}
$val = rawurlencode($val); $val = rawurlencode($val);
$qry = "UPDATE $ADODB_SESSION_TBL SET expiry=$expiry,data='$val' WHERE sesskey='$key'"; $qry = "UPDATE $ADODB_SESSION_TBL SET expiry=$expiry,data='$val' WHERE sesskey='$key'";
$rs = $ADODB_SESS_CONN->Execute($qry); $rs = $ADODB_SESS_CONN->Execute($qry);
@ -180,7 +217,8 @@ function adodb_sess_destroy($key)
return $rs ? true : false; return $rs ? true : false;
} }
function adodb_sess_gc($maxlifetime) { function adodb_sess_gc($maxlifetime)
{
global $ADODB_SESS_CONN, $ADODB_SESSION_TBL,$ADODB_SESSION_DRIVER; global $ADODB_SESS_CONN, $ADODB_SESSION_TBL,$ADODB_SESSION_DRIVER;
$qry = "DELETE FROM $ADODB_SESSION_TBL WHERE expiry < " . time(); $qry = "DELETE FROM $ADODB_SESSION_TBL WHERE expiry < " . time();

View file

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @version V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. * @version V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license. * Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses, * Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence. * the BSD license will take precedence.
@ -43,6 +43,12 @@
*/ */
if (!defined('ADODB_DIR')) define('ADODB_DIR',dirname(__FILE__)); if (!defined('ADODB_DIR')) define('ADODB_DIR',dirname(__FILE__));
if (strpos(strtoupper(PHP_OS),'WIN') !== false) {
// windows, negative timestamps are illegal as of php 4.2.0
define('TIMESTAMP_FIRST_YEAR',1970);
} else
define('TIMESTAMP_FIRST_YEAR',1904);
//============================================================================================== //==============================================================================================
// GLOBAL VARIABLES // GLOBAL VARIABLES
//============================================================================================== //==============================================================================================
@ -84,7 +90,7 @@
/** /**
* ADODB version as a string. * ADODB version as a string.
*/ */
$ADODB_vers = 'V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. Released BSD & LGPL.'; $ADODB_vers = 'V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. Released BSD & LGPL.';
/** /**
* Determines whether recordset->RecordCount() is used. * Determines whether recordset->RecordCount() is used.
@ -134,7 +140,7 @@
var $user = ''; // The username which is used to connect to the database server. var $user = ''; // The username which is used to connect to the database server.
var $password = ''; // Password for the username var $password = ''; // Password for the username
var $debug = false; // if set to true will output sql statements var $debug = false; // if set to true will output sql statements
var $maxblobsize = 8000; // maximum size of blobs or large text fields -- some databases die otherwise like foxpro var $maxblobsize = 64000; // maximum size of blobs or large text fields -- some databases die otherwise like foxpro
var $concat_operator = '+'; // default concat operator -- change to || for Oracle/Interbase var $concat_operator = '+'; // default concat operator -- change to || for Oracle/Interbase
var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database
var $fmtTimeStamp = "'Y-m-d, h:i:s A'"; // used by DBTimeStamp as the default timestamp fmt. var $fmtTimeStamp = "'Y-m-d, h:i:s A'"; // used by DBTimeStamp as the default timestamp fmt.
@ -160,6 +166,10 @@
var $arrayClass = 'ADORecordSet_array'; var $arrayClass = 'ADORecordSet_array';
// oracle specific stuff // oracle specific stuff
var $noNullStrings = false; var $noNullStrings = false;
var $numCacheHits = 0;
var $numCacheMisses = 0;
var $pageExecuteCountRows = true;
var $uniqueSort = false; // indicates that all fields in order by must be unique
/* /*
* PRIVATE VARS * PRIVATE VARS
@ -212,7 +222,7 @@
} else } else
if ($this->_connect($this->host, $this->user, $this->password, $this->database)) return true; if ($this->_connect($this->host, $this->user, $this->password, $this->database)) return true;
if ($this->debug) print $this->host.': '.$this->ErrorMsg()."<br>\n"; if ($this->debug) print $this->host.': '.$this->ErrorMsg()."<br />\n";
return false; return false;
} }
@ -245,7 +255,7 @@
} else } else
if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true;
if ($this->debug) print $this->host.': '.$this->ErrorMsg()."<br>\n"; if ($this->debug) print $this->host.': '.$this->ErrorMsg()."<br />\n";
return false; return false;
} }
@ -295,11 +305,11 @@
} }
/** /**
* PEAR DB Compat - do not use internally. * PEAR DB Compat - Quote with auto-checking of magic-quotes-gpc.
*/ */
function Quote($s) function Quote($s)
{ {
return $this->qstr($s); return $this->qstr($s,get_magic_quotes_gpc());
} }
@ -458,26 +468,30 @@
$inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']); $inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']);
if ($inBrowser) if ($inBrowser)
print "<hr>\n($this->databaseType): ".htmlspecialchars($sqlTxt)." &nbsp; <code>$ss</code>\n<hr>\n"; print "<hr />\n($this->databaseType): ".htmlspecialchars($sqlTxt)." &nbsp; <code>$ss</code>\n<hr />\n";
else else
print "=----\n($this->databaseType): ".($sqlTxt)." \n-----\n"; print "=----\n($this->databaseType): ".($sqlTxt)." \n-----\n";
flush(); flush();
$this->_queryID = $this->_query($sql,$inputarr,$arg3); $this->_queryID = $this->_query($sql,$inputarr,$arg3);
/*
Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql
because ErrorNo() calls Execute('SELECT @ERROR'), causing recure
*/
if ($this->databaseType == 'mssql') { if ($this->databaseType == 'mssql') {
// ErrorNo is a slow function call in mssql, and not reliable // ErrorNo is a slow function call in mssql, and not reliable
// in PHP 4.0.6 // in PHP 4.0.6
if($this->ErrorMsg()) { if($emsg = $this->ErrorMsg()) {
$err = $this->ErrorNo(); $err = $this->ErrorNo();
if ($err) { if ($err) {
print $err.': '.$this->ErrorMsg().(($inBrowser) ? "<br>\n" : "\n"); print $err.': '.$emsg.(($inBrowser) ? "<br />\n" : "\n");
flush(); flush();
} }
} }
} else } else
if (!$this->_queryID) { if (!$this->_queryID) {
print $this->ErrorNo().': '.$this->ErrorMsg().(($inBrowser) ? "<br>\n" : "\n"); print $this->ErrorNo().': '.$this->ErrorMsg() .(($inBrowser) ? "<br />\n" : "\n");
flush(); flush();
} }
} else } else
@ -699,6 +713,7 @@
*/ */
function &_rs2rs(&$rs,$nrows=-1,$offset=-1) function &_rs2rs(&$rs,$nrows=-1,$offset=-1)
{ {
if (! $rs) return false;
$arr = &$rs->GetArrayLimit($nrows,$offset); $arr = &$rs->GetArrayLimit($nrows,$offset);
$flds = array(); $flds = array();
for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++)
@ -768,7 +783,76 @@
} }
return false; return false;
} }
/**
* Insert or replace a single record
*
* $this->Replace('products', array('prodname' =>"'Nails'","price" => 3.99), 'prodname');
*
* $table table name
* $fieldArray associative array of data (you must quote strings yourself).
* $keyCol the primary key field name or if compound key, array of field names
* autoQuote set to true to use a hueristic to quote strings. Works with nulls and numbers
* but does not work with dates nor SQL functions.
*
* Currently blob replace not supported
*
* returns 0 = fail, 1 = update, 2 = insert
*/
function Replace($table, $fieldArray, $keyCol,$autoQuote=false)
{
if (count($fieldArray) == 0) return 0;
$first = true;
$uSet = '';
if (!is_array($keyCol)) {
$keyCol = array($keyCol);
}
foreach($fieldArray as $k => $v) {
if ($autoQuote && !is_numeric($v) and $v[0] != "'" and strcasecmp($v,'null')!=0) {
$v = $this->qstr($v);
$fieldArray[$k] = $v;
}
if (in_array($k,$keyCol)) continue; // skip UPDATE if is key
if ($first) {
$first = false;
$uSet = "$k=$v";
} else
$uSet .= ",$k=$v";
}
$first = true;
foreach ($keyCol as $v) {
if ($first) {
$first = false;
$where = "$v=$fieldArray[$v]";
} else {
$where .= " and $v=$fieldArray[$v]";
}
}
if ($uSet) {
$update = "UPDATE $table SET $uSet WHERE $where";
$rs = $this->Execute($update);
if ($rs and $this->Affected_Rows()>0) return 1;
}
$first = true;
foreach($fieldArray as $k => $v) {
if ($first) {
$first = false;
$iCols = "$k";
$iVals = "$v";
} else {
$iCols .= ",$k";
$iVals .= ",$v";
}
}
$insert = "INSERT INTO $table ($iCols) VALUES ($iVals)";
$rs = $this->Execute($insert);
return ($rs) ? 2 : 0;
}
/** /**
@ -798,7 +882,7 @@
// sql, nrows, offset,inputarr,arg3 // sql, nrows, offset,inputarr,arg3
return $this->SelectLimit($secs2cache,$sql,$nrows,$offset,$inputarr,$this->cacheSecs); return $this->SelectLimit($secs2cache,$sql,$nrows,$offset,$inputarr,$this->cacheSecs);
} }
if ($sql === false) echo "Warning: \$sql missing from CacheSelectLimit()<br>\n"; if ($sql === false) echo "Warning: \$sql missing from CacheSelectLimit()<br />\n";
return $this->SelectLimit($sql,$nrows,$offset,$inputarr,$arg3,$secs2cache); return $this->SelectLimit($sql,$nrows,$offset,$inputarr,$arg3,$secs2cache);
} }
@ -849,10 +933,13 @@
$md5file = $this->_gencachename($sql,true); $md5file = $this->_gencachename($sql,true);
$err = ''; $err = '';
if ($secs2cache > 0)$rs = &csv2rs($md5file,$err,$secs2cache); if ($secs2cache > 0){
else { $rs = &csv2rs($md5file,$err,$secs2cache);
$this->numCacheHits += 1;
} else {
$err='Timeout 1'; $err='Timeout 1';
$rs = false; $rs = false;
$this->numCacheMisses += 1;
} }
if (!$rs) { if (!$rs) {
@ -862,7 +949,7 @@
if ($rs) { if ($rs) {
$eof = $rs->EOF; $eof = $rs->EOF;
$rs = &$this->_rs2rs($rs); // read entire recordset into memory immediately $rs = &$this->_rs2rs($rs); // read entire recordset into memory immediately
$txt = &rs2csv($rs,false,$sql); // serialize $txt = _rs2serialize($rs,false,$sql); // serialize
if (!adodb_write_file($md5file,$txt,$this->debug)) { if (!adodb_write_file($md5file,$txt,$this->debug)) {
if ($fn = $this->raiseErrorFn) { if ($fn = $this->raiseErrorFn) {
@ -871,7 +958,8 @@
if ($this->debug) print " Cache write error<br>\n"; if ($this->debug) print " Cache write error<br>\n";
} }
if ($rs->EOF && !$eof) { if ($rs->EOF && !$eof) {
$rs = &csv2rs($md5file,$err); $rs->MoveFirst();
//$rs = &csv2rs($md5file,$err);
$rs->connection = &$this; // Pablo suggestion $rs->connection = &$this; // Pablo suggestion
} }
@ -1182,7 +1270,6 @@
function DBDate($d) function DBDate($d)
{ {
// note that we are limited to 1970 to 2038
if (empty($d) && $d !== 0) return 'null'; if (empty($d) && $d !== 0) return 'null';
if (is_string($d) && !is_numeric($d)) if (is_string($d) && !is_numeric($d))
@ -1214,14 +1301,14 @@
* Also in ADORecordSet. * Also in ADORecordSet.
* @param $v is a date string in YYYY-MM-DD format * @param $v is a date string in YYYY-MM-DD format
* *
* @return date in unix timestamp format, or 0 if before 1970, or false if invalid date format * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
*/ */
function UnixDate($v) function UnixDate($v)
{ {
if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})$|", if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|",
($v), $rr)) return false; ($v), $rr)) return false;
if ($rr[1] <= 1970) return 0; if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0;
// h-m-s-MM-DD-YY // h-m-s-MM-DD-YY
return mktime(0,0,0,$rr[2],$rr[3],$rr[1]); return mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
} }
@ -1231,21 +1318,22 @@
* Also in ADORecordSet. * Also in ADORecordSet.
* @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format
* *
* @return date in unix timestamp format, or 0 if before 1970, or false if invalid date format * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
*/ */
function UnixTimeStamp($v) function UnixTimeStamp($v)
{ {
if (!preg_match( if (!preg_match(
"|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9]{1,2}))?$|", "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9]{1,2}))?$|",
($v), $rr)) return false; ($v), $rr)) return false;
if ($rr[1] <= 1970 && $rr[2]<= 1) return 0; if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0;
// h-m-s-MM-DD-YY // h-m-s-MM-DD-YY
return @mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]); return @mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
} }
/** /**
* Converts a timestamp "ts" to a string that the database can understand. * Correctly quotes a string so that all strings are escaped. We prefix and append
* to the string single-quotes.
* An example is $db->qstr("Don't bother",magic_quotes_runtime()); * An example is $db->qstr("Don't bother",magic_quotes_runtime());
* *
* @param s the string to quote * @param s the string to quote
@ -1298,7 +1386,8 @@
function &PageExecute($sql, $nrows, $page, $inputarr=false, $arg3=false, $secs2cache=0) function &PageExecute($sql, $nrows, $page, $inputarr=false, $arg3=false, $secs2cache=0)
{ {
include_once(ADODB_DIR.'/adodb-lib.inc.php'); include_once(ADODB_DIR.'/adodb-lib.inc.php');
return _adodb_pageexecute($this, $sql, $nrows, $page, $inputarr, $arg3, $secs2cache); if ($this->pageExecuteCountRows) return _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $arg3, $secs2cache);
return _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $arg3, $secs2cache);
} }
@ -1317,8 +1406,7 @@
* @return the recordset ($rs->databaseType == 'array') * @return the recordset ($rs->databaseType == 'array')
*/ */
function &CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false, $arg3=false) { function &CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false, $arg3=false) {
include_once(ADODB_DIR.'/adodb-lib.inc.php'); return $this->PageExecute($sql,$nrows,$page,$inputarr,$arg3,$secs2cache);
return _adodb_pageexecute($this, $sql, $nrows, $page, $inputarr, $arg3,$secs2cache);
} }
} // end class ADOConnection } // end class ADOConnection
@ -1402,8 +1490,8 @@
var $_currentPage = -1; /* Added by Iván Oliva to implement recordset pagination */ var $_currentPage = -1; /* Added by Iván Oliva to implement recordset pagination */
var $_atFirstPage = false; /* Added by Iván Oliva to implement recordset pagination */ var $_atFirstPage = false; /* Added by Iván Oliva to implement recordset pagination */
var $_atLastPage = false; /* Added by Iván Oliva to implement recordset pagination */ var $_atLastPage = false; /* Added by Iván Oliva to implement recordset pagination */
var $_lastPageNo = -1;
var $_maxRecordCount = 0;
/** /**
* Constructor * Constructor
* *
@ -1416,6 +1504,7 @@
} }
function Init() function Init()
{ {
if ($this->_inited) return; if ($this->_inited) return;
@ -1606,7 +1695,7 @@
function UserTimeStamp($v,$fmt='Y-m-d H:i:s') function UserTimeStamp($v,$fmt='Y-m-d H:i:s')
{ {
$tt = $this->UnixTimeStamp($v); $tt = $this->UnixTimeStamp($v);
// $tt == -1 if pre 1970 // $tt == -1 if pre TIMESTAMP_FIRST_YEAR
if (($tt === false || $tt == -1) && $v != false) return $v; if (($tt === false || $tt == -1) && $v != false) return $v;
if ($tt == 0) return $this->emptyTimeStamp; if ($tt == 0) return $this->emptyTimeStamp;
@ -1623,10 +1712,10 @@
function UserDate($v,$fmt='Y-m-d') function UserDate($v,$fmt='Y-m-d')
{ {
$tt = $this->UnixDate($v); $tt = $this->UnixDate($v);
// $tt == -1 if pre 1970 // $tt == -1 if pre TIMESTAMP_FIRST_YEAR
if (($tt === false || $tt == -1) && $v != false) return $v; if (($tt === false || $tt == -1) && $v != false) return $v;
else if ($tt == 0) return $this->emptyDate; else if ($tt == 0) return $this->emptyDate;
else if ($tt == -1) { // pre-1970 else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR
} }
return date($fmt,$tt); return date($fmt,$tt);
@ -1636,14 +1725,14 @@
/** /**
* @param $v is a date string in YYYY-MM-DD format * @param $v is a date string in YYYY-MM-DD format
* *
* @return date in unix timestamp format, or 0 if before 1970, or false if invalid date format * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
*/ */
function UnixDate($v) function UnixDate($v)
{ {
if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})$|", if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|",
($v), $rr)) return false; ($v), $rr)) return false;
if ($rr[1] <= 1970) return 0; if ($rr[1] <= 1903) return 0;
// h-m-s-MM-DD-YY // h-m-s-MM-DD-YY
return mktime(0,0,0,$rr[2],$rr[3],$rr[1]); return mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
} }
@ -1652,14 +1741,14 @@
/** /**
* @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format
* *
* @return date in unix timestamp format, or 0 if before 1970, or false if invalid date format * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
*/ */
function UnixTimeStamp($v) function UnixTimeStamp($v)
{ {
if (!preg_match( if (!preg_match(
"|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9]{1,2}))?$|", "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9]{1,2}))?$|",
($v), $rr)) return false; ($v), $rr)) return false;
if ($rr[1] <= 1970 && $rr[2]<= 1) return 0; if ($rr[1] <= 1903 && $rr[2]<= 1) return 0;
// h-m-s-MM-DD-YY // h-m-s-MM-DD-YY
return @mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]); return @mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
@ -1875,6 +1964,15 @@
function RecordCount() {return $this->_numOfRows;} function RecordCount() {return $this->_numOfRows;}
/*
* If we are using PageExecute(), this will return the maximum possible rows
* that can be returned when paging a recordset.
*/
function MaxRecordCount()
{
return ($this->_maxRecordCount) ? $this->_maxRecordCount : $this->RecordCount();
}
/** /**
* synonyms RecordCount and RowCount * synonyms RecordCount and RowCount
* *
@ -1936,6 +2034,18 @@
// must be defined by child class // must be defined by child class
} }
/**
* Get the ADOFieldObjects of all columns in an array.
*
*/
function FieldTypesArray()
{
$arr = array();
for ($i=0, $max=$this->_numOfFields; $i < $max; $i++)
$arr[] = $this->FetchField($i);
return $arr;
}
/** /**
* Return the fields array of the current row as an object for convenience. * Return the fields array of the current row as an object for convenience.
* *
@ -2022,6 +2132,7 @@
case 'NVARCHAR': case 'NVARCHAR':
case 'VARYING': case 'VARYING':
case 'BPCHAR': case 'BPCHAR':
case 'CHARACTER':
if (!empty($this)) if ($len <= $this->blobSize) return 'C'; if (!empty($this)) if ($len <= $this->blobSize) return 'C';
else if ($len <= 250) return 'C'; else if ($len <= 250) return 'C';
@ -2096,6 +2207,12 @@
return $this->_atFirstPage; return $this->_atFirstPage;
} }
function LastPageNo($page = false)
{
if ($page != false) $this->_lastPageNo = $page;
return $this->_lastPageNo;
}
/** /**
* set/returns the status of the atLastPage flag when paginating * set/returns the status of the atLastPage flag when paginating
*/ */
@ -2347,7 +2464,7 @@
$ok = false; $ok = false;
} }
if (!$ok) { if (!$ok) {
if ($debug) print " Rename $tmpname ".($ok? 'ok' : 'failed')." <br>\n"; if ($debug) print " Rename $tmpname ".($ok? 'ok' : 'failed')." <br />\n";
} }
return $ok; return $ok;
} }

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt. the BSD license will take precedence. See License.txt.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@ -25,6 +25,12 @@ class ADODB_ado extends ADOConnection {
var $adoParameterType = 201; // 201 = long varchar, 203=long wide varchar, 205 = long varbinary var $adoParameterType = 201; // 201 = long varchar, 203=long wide varchar, 205 = long varbinary
var $_affectedRows = false; var $_affectedRows = false;
var $_thisTransactions; var $_thisTransactions;
var $_inTransaction = 0;
var $_cursor_type = 3; // 3=adOpenStatic,0=adOpenForwardOnly,1=adOpenKeyset,2=adOpenDynamic
var $_cursor_location = 3; // 2=adUseServer, 3 = adUseClient;
var $_lock_type = -1;
var $_execute_option = -1;
function ADODB_ado() function ADODB_ado()
{ {
@ -36,6 +42,9 @@ class ADODB_ado extends ADOConnection {
return $this->_affectedRows; return $this->_affectedRows;
} }
// you can also pass a connection string like this:
//
// $DB->Connect('USER ID=sa;PASSWORD=pwd;SERVER=mangrove;DATABASE=ai',false,false,'SQLOLEDB');
function _connect($argHostname, $argUsername, $argPassword, $argProvider= 'MSDASQL') function _connect($argHostname, $argUsername, $argPassword, $argProvider= 'MSDASQL')
{ {
$u = 'UID'; $u = 'UID';
@ -43,13 +52,22 @@ class ADODB_ado extends ADOConnection {
$dbc = new COM('ADODB.Connection'); $dbc = new COM('ADODB.Connection');
if (! $dbc) return false; if (! $dbc) return false;
/* // handle SQL server provider specially ? no need
if ($argProvider) { /* special support if provider is mssql or access */
if ($argProvider == "SQLOLEDB") { // SQL Server Provider if ($argProvider=='mssql') {
} $u = 'User Id'; //User parameter name for OLEDB
}*/ $p = 'Password';
$argProvider = "SQLOLEDB"; // SQL Server Provider
// not yet
//if ($argDatabasename) $argHostname .= ";Initial Catalog=$argDatabasename";
//use trusted conection for SQL if username not specified
if (!$argUsername) $argHostname .= ";Trusted_Connection=Yes";
} else if ($argProvider=='access')
$argProvider = "Microsoft.Jet.OLEDB.4.0"; // Microsoft Jet Provider
if ($argProvider) $dbc->Provider = $argProvider; if ($argProvider) $dbc->Provider = $argProvider;
else $dbc->Provider ='MSDASQL';
if ($argUsername) $argHostname .= ";$u=$argUsername"; if ($argUsername) $argHostname .= ";$u=$argUsername";
if ($argPassword)$argHostname .= ";$p=$argPassword"; if ($argPassword)$argHostname .= ";$p=$argPassword";
@ -59,26 +77,15 @@ class ADODB_ado extends ADOConnection {
@$dbc->Open((string) $argHostname); @$dbc->Open((string) $argHostname);
$this->_connectionID = $dbc; $this->_connectionID = $dbc;
return $dbc != false;
$dbc->CursorLocation = $this->_cursor_location;
return $dbc->State > 0;
} }
// returns true or false // returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argProvider='MSDASQL') function _pconnect($argHostname, $argUsername, $argPassword, $argProvider='MSDASQL')
{ {
$dbc = new COM("ADODB.Connection"); return $this->_connect($argHostname,$argUsername,$argPassword,$argProvider);
if (! $dbc) return false;
if ($argProvider) $dbc->Provider = $argProvider;
else $dbc->Provider ='MSDASQL';
if ($argUsername) $argHostname .= ";UID=$argUsername";
if ($argPassword)$argHostname .= ";PWD=$argPassword";
if ($this->debug) print "<p>Host=".$argHostname."<BR>version=$dbc->version</p>";
$dbc->Open((string) $argHostname);
$this->_connectionID = $dbc;
return $dbc != false;
} }
/* /*
@ -202,8 +209,14 @@ class ADODB_ado extends ADOConnection {
if ($dbc->Errors->Count > 0) return false; if ($dbc->Errors->Count > 0) return false;
return $rs; return $rs;
} }
$rs = @$dbc->Execute($sql,&$this->_affectedRows);
$rs = @$dbc->Execute($sql,&$this->_affectedRows, $this->_execute_option);
/*
$rs = new COM('ADODB.Recordset');
if ($rs) {
$rs->Open ($sql, $dbc, $this->_cursor_type,$this->_lock_type, $this->_execute_option);
}
*/
if ($dbc->Errors->Count > 0) return false; if ($dbc->Errors->Count > 0) return false;
if (! $rs) return false; if (! $rs) return false;
@ -222,16 +235,19 @@ class ADODB_ado extends ADOConnection {
if (!$o) return false; if (!$o) return false;
} }
@$this->_connectionID->BeginTrans(); @$this->_connectionID->BeginTrans();
$this->_inTransaction += 1;
return true; return true;
} }
function CommitTrans($ok=true) function CommitTrans($ok=true)
{ {
if (!$ok) return $this->RollbackTrans(); if (!$ok) return $this->RollbackTrans();
@$this->_connectionID->CommitTrans(); @$this->_connectionID->CommitTrans();
if ($this->_inTransaction) @$this->_inTransaction -= 1;
return true; return true;
} }
function RollbackTrans() { function RollbackTrans() {
@$this->_connectionID->RollbackTrans(); @$this->_connectionID->RollbackTrans();
if ($this->_inTransaction) @$this->_inTransaction -= 1;
return true; return true;
} }
@ -295,8 +311,10 @@ class ADORecordSet_ado extends ADORecordSet {
$rs = $this->_queryID; $rs = $this->_queryID;
$f = $rs->Fields($fieldOffset); $f = $rs->Fields($fieldOffset);
$o->name = $f->Name; $o->name = $f->Name;
$o->type = $this->MetaType($f->Type); $t = $f->Type;
$o->type = $this->MetaType($t);
$o->max_length = $f->DefinedSize; $o->max_length = $f->DefinedSize;
$o->ado_type = $t;
//print "off=$off name=$o->name type=$o->type len=$o->max_length<br>"; //print "off=$off name=$o->name type=$o->type len=$o->max_length<br>";
@ -472,7 +490,7 @@ class ADORecordSet_ado extends ADORecordSet {
function _fetch() function _fetch()
{ {
$rs = $this->_queryID; $rs = $this->_queryID;
if ($rs->EOF) return false; if (!$rs or $rs->EOF) return false;
$this->fields = array(); $this->fields = array();
if (!$this->_tarr) { if (!$this->_tarr) {
@ -494,6 +512,9 @@ class ADORecordSet_ado extends ADORecordSet {
for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) { for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) {
switch($t) { switch($t) {
case 135: // timestamp
$this->fields[] = date('Y-m-d H:i:s',(integer)$f->value);
break;
case 133:// A date value (yyyymmdd) case 133:// A date value (yyyymmdd)
$val = $f->value; $val = $f->value;

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt. the BSD license will take precedence. See License.txt.
@ -20,6 +20,8 @@ class ADODB_ado_access extends ADODB_ado {
var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
var $fmtDate = "#Y-m-d#"; var $fmtDate = "#Y-m-d#";
var $fmtTimeStamp = "#Y-m-d h:i:sA#";// note no comma var $fmtTimeStamp = "#Y-m-d h:i:sA#";// note no comma
var $sysDate = "FORMAT(NOW,'yyyy-mm-dd')";
var $sysTimeStamp = 'NOW';
function ADODB_ado_access() function ADODB_ado_access()
{ {

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@ -24,10 +24,22 @@ var $databaseType = 'ado_mssql';
var $hasTop = 'top'; var $hasTop = 'top';
var $sysDate = 'GetDate()'; var $sysDate = 'GetDate()';
var $sysTimeStamp = 'GetDate()'; var $sysTimeStamp = 'GetDate()';
//var $_inTransaction = 1; // always open recordsets, so no transaction problems.
function ADODB_ado_mssql() function ADODB_ado_mssql()
{ {
} }
function _insertid()
{
return $this->GetOne('select @@identity');
}
function _affectedrows()
{
return $this->GetOne('select @@rowcount');
}
} }
class ADORecordSet_ado_mssql extends ADORecordSet_ado { class ADORecordSet_ado_mssql extends ADORecordSet_ado {

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
@version V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. @version V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@ -85,6 +85,12 @@ class ADODB_ibase extends ADOConnection {
return 1; return 1;
} }
function Replace($table, $fieldArray, $keyCol,$autoQuote=false)
{
print "<p>ADOdb: Replace not supported because affected_rows does not work with Interbase</p>";
return 0;
}
function GenID($seqname='adodbseq',$startID=1) function GenID($seqname='adodbseq',$startID=1)
{ {
$getnext = ("SELECT Gen_ID($seqname,1) FROM RDB\$DATABASE"); $getnext = ("SELECT Gen_ID($seqname,1) FROM RDB\$DATABASE");
@ -316,8 +322,9 @@ class ADORecordset_ibase extends ADORecordSet
{ {
$fld = new ADOFieldObject; $fld = new ADOFieldObject;
$ibf = ibase_field_info($this->_queryID,$fieldOffset); $ibf = ibase_field_info($this->_queryID,$fieldOffset);
$fld->name = strtolower($ibf['name']);
if (empty($fld->name)) $fld->name = $ibf['alias']; $fld->name = strtolower($ibf['alias']);
if (empty($fld->name)) $fld->name = strtolower($ibf['name']);
$fld->type = $ibf['type']; $fld->type = $ibf['type'];
$fld->max_length = $ibf['length']; $fld->max_length = $ibf['length'];
if ($this->debug) print_r($fld); if ($this->debug) print_r($fld);

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* @version V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). * @version V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my).
All rights reserved. All rights reserved.
* Released under both BSD license and Lesser GPL library license. * Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses, * Whenever there is any discrepancy between the two licenses,

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim. All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim. All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@ -123,10 +123,20 @@ class ADODB_informix72 extends ADOConnection {
#if ($argDatabasename) return $this->SelectDB($argDatabasename); #if ($argDatabasename) return $this->SelectDB($argDatabasename);
return true; return true;
} }
/*
// ifx_do does not accept bind parameters - wierd ???
function Prepare($sql)
{
$stmt = ifx_prepare($sql);
if (!$stmt) return $sql;
else return array($sql,$stmt);
}
*/
// returns query ID if successful, otherwise false // returns query ID if successful, otherwise false
function _query($sql,$inputarr) function _query($sql,$inputarr)
{ {
global $ADODB_COUNTRECS;
// String parameters have to be converted using ifx_create_char // String parameters have to be converted using ifx_create_char
if ($inputarr) { if ($inputarr) {
foreach($inputarr as $v) { foreach($inputarr as $v) {
@ -141,7 +151,7 @@ class ADODB_informix72 extends ADOConnection {
// In case of select statement, we use a scroll cursor in order // In case of select statement, we use a scroll cursor in order
// to be able to call "move", or "movefirst" statements // to be able to call "move", or "movefirst" statements
if (preg_match("/^[\\t\\n ]*select/i", $sql)) { if ($ADODB_COUNTRECS && preg_match("/^[\\t\\n ]*select/i", $sql)) {
if ($inputarr) { if ($inputarr) {
$this->lastQuery = ifx_query($sql,$this->_connectionID, IFX_SCROLL, $tab); $this->lastQuery = ifx_query($sql,$this->_connectionID, IFX_SCROLL, $tab);
} }

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@ -33,13 +33,19 @@ Set tabs to 4 for best viewing.
//---------------------------------------------------------------- //----------------------------------------------------------------
global $ADODB_mssql_date_order; // 'dmy' and 'mdy' supported global $ADODB_mssql_date_order; // 'dmy' and 'mdy' supported
$ADODB_mssql_has_datetimeconvert = (strnatcmp(PHP_VERSION,'4.2.0')>=0);
if ($ADODB_mssql_has_datetimeconvert) {
ini_set('mssql.datetimeconvert',0);
} else {
global $ADODB_mssql_mths; // array, months must be upper-case global $ADODB_mssql_mths; // array, months must be upper-case
global $ADODB_mssql_has_datetimeconvert;
$ADODB_mssql_date_order = 'mdy'; $ADODB_mssql_date_order = 'mdy';
$ADODB_mssql_mths = array( $ADODB_mssql_mths = array(
'JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6, 'JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,
'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12); 'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12);
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Call this to autoset $ADODB_mssql_date_order at the beginning of your code, // Call this to autoset $ADODB_mssql_date_order at the beginning of your code,
// just after you connect to the database. Supports mdy and dmy only // just after you connect to the database. Supports mdy and dmy only
@ -78,11 +84,11 @@ class ADODB_mssql extends ADOConnection {
var $_has_mssql_init; var $_has_mssql_init;
var $maxParameterLen = 4000; var $maxParameterLen = 4000;
var $arrayClass = 'ADORecordSet_array_mssql'; var $arrayClass = 'ADORecordSet_array_mssql';
var $uniqueSort = true;
function ADODB_mssql() function ADODB_mssql()
{ {
$this->_has_mssql_init = (strnatcmp(PHP_VERSION,'4.1.0')>=0); $this->_has_mssql_init = (strnatcmp(PHP_VERSION,'4.1.0')>=0);
} }
// might require begintrans -- committrans // might require begintrans -- committrans
@ -194,12 +200,17 @@ class ADODB_mssql extends ADOConnection {
Note: This function is NOT available for Microsoft SQL Server. */ Note: This function is NOT available for Microsoft SQL Server. */
function ErrorMsg() function ErrorMsg()
{ {
if (empty($this->_errorMsg)){
$this->_errorMsg = mssql_get_last_message(); $this->_errorMsg = mssql_get_last_message();
}
return $this->_errorMsg; return $this->_errorMsg;
} }
function ErrorNo() function ErrorNo()
{ {
if (empty($this->_errorMsg)) {
$this->_errorMsg = mssql_get_last_message(); print " D E F $this->_errorMsg";
}
$id = @mssql_query("select @@ERROR",$this->_connectionID); $id = @mssql_query("select @@ERROR",$this->_connectionID);
if (!$id) return false; if (!$id) return false;
$arr = mssql_fetch_array($id); $arr = mssql_fetch_array($id);
@ -306,6 +317,7 @@ class ADODB_mssql extends ADOConnection {
// returns query ID if successful, otherwise false // returns query ID if successful, otherwise false
function _query($sql,$inputarr) function _query($sql,$inputarr)
{ {
$this->_errorMsg = false;
if (is_array($sql)) return mssql_execute($sql[1]); if (is_array($sql)) return mssql_execute($sql[1]);
return mssql_query($sql,$this->_connectionID); return mssql_query($sql,$this->_connectionID);
} }
@ -458,6 +470,9 @@ class ADORecordSet_array_mssql extends ADORecordSet_array {
// mssql uses a default date like Dec 30 2000 12:00AM // mssql uses a default date like Dec 30 2000 12:00AM
function UnixDate($v) function UnixDate($v)
{ {
global $ADODB_mssql_has_datetimeconvert;
if ($ADODB_mssql_has_datetimeconvert) return parent::UnixDate($v);
global $ADODB_mssql_mths,$ADODB_mssql_date_order; global $ADODB_mssql_mths,$ADODB_mssql_date_order;
//Dec 30 2000 12:00AM //Dec 30 2000 12:00AM
@ -465,7 +480,7 @@ class ADORecordSet_array_mssql extends ADORecordSet_array {
if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4})|" ,$v, $rr)) { if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4})|" ,$v, $rr)) {
return parent::UnixDate($v); return parent::UnixDate($v);
} }
if ($rr[3] <= 1970) return 0; if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
$theday = $rr[1]; $theday = $rr[1];
$themth = substr(strtoupper($rr[2]),0,3); $themth = substr(strtoupper($rr[2]),0,3);
@ -473,7 +488,7 @@ class ADORecordSet_array_mssql extends ADORecordSet_array {
if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})|" ,$v, $rr)) { if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})|" ,$v, $rr)) {
return parent::UnixDate($v); return parent::UnixDate($v);
} }
if ($rr[3] <= 1970) return 0; if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
$theday = $rr[2]; $theday = $rr[2];
$themth = substr(strtoupper($rr[1]),0,3); $themth = substr(strtoupper($rr[1]),0,3);
@ -486,20 +501,23 @@ class ADORecordSet_array_mssql extends ADORecordSet_array {
function UnixTimeStamp($v) function UnixTimeStamp($v)
{ {
global $ADODB_mssql_has_datetimeconvert;
if ($ADODB_mssql_has_datetimeconvert) return parent::UnixTimeStamp($v);
global $ADODB_mssql_mths,$ADODB_mssql_date_order; global $ADODB_mssql_mths,$ADODB_mssql_date_order;
//Dec 30 2000 12:00AM //Dec 30 2000 12:00AM
if ($ADODB_mssql_date_order == 'dmy') { if ($ADODB_mssql_date_order == 'dmy') {
if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|" if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
,$v, $rr)) return parent::UnixTimeStamp($v); ,$v, $rr)) return parent::UnixTimeStamp($v);
if ($rr[3] <= 1970) return 0; if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
$theday = $rr[1]; $theday = $rr[1];
$themth = substr(strtoupper($rr[2]),0,3); $themth = substr(strtoupper($rr[2]),0,3);
} else { } else {
if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|" if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
,$v, $rr)) return parent::UnixTimeStamp($v); ,$v, $rr)) return parent::UnixTimeStamp($v);
if ($rr[3] <= 1970) return 0; if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
$theday = $rr[2]; $theday = $rr[2];
$themth = substr(strtoupper($rr[1]),0,3); $themth = substr(strtoupper($rr[1]),0,3);
@ -522,4 +540,5 @@ class ADORecordSet_array_mssql extends ADORecordSet_array {
return mktime($rr[4],$rr[5],0,$themth,$theday,$rr[3]); return mktime($rr[4],$rr[5],0,$themth,$theday,$rr[3]);
} }
} }
?> ?>

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@ -29,6 +29,7 @@ class ADODB_mysql extends ADOConnection {
var $isoDates = true; // accepts dates in ISO format var $isoDates = true; // accepts dates in ISO format
var $sysDate = 'CURDATE()'; var $sysDate = 'CURDATE()';
var $sysTimeStamp = 'NOW()'; var $sysTimeStamp = 'NOW()';
var $forceNewConnect = false;
function ADODB_mysql() function ADODB_mysql()
{ {
@ -104,6 +105,9 @@ class ADODB_mysql extends ADOConnection {
// returns true or false // returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{ {
if ($this->forceNewConnect && (strnatcmp(PHP_VERSION,'4.2.0')>=0))
$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword,true);
else
$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword); $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword);
if ($this->_connectionID === false) return false; if ($this->_connectionID === false) return false;
if ($argDatabasename) return $this->SelectDB($argDatabasename); if ($argDatabasename) return $this->SelectDB($argDatabasename);
@ -295,9 +299,11 @@ class ADORecordSet_mysql extends ADORecordSet{
$this->_numOfFields = @mysql_num_fields($this->_queryID); $this->_numOfFields = @mysql_num_fields($this->_queryID);
} }
function &FetchField($fieldOffset = -1) { function &FetchField($fieldOffset = -1)
{
if ($fieldOffset != -1) { if ($fieldOffset != -1) {
$o = @mysql_fetch_field($this->_queryID, $fieldOffset); $o = mysql_fetch_field($this->_queryID, $fieldOffset);
$f = @mysql_field_flags($this->_queryID,$fieldOffset); $f = @mysql_field_flags($this->_queryID,$fieldOffset);
$o->max_length = @mysql_field_len($this->_queryID,$fieldOffset); // suggested by: Jim Nicholson (jnich@att.com) $o->max_length = @mysql_field_len($this->_queryID,$fieldOffset); // suggested by: Jim Nicholson (jnich@att.com)
//$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim. All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim. All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@ -37,7 +37,7 @@ class ADODB_oci8 extends ADOConnection {
var $dataProvider = 'oci8'; var $dataProvider = 'oci8';
var $replaceQuote = "''"; // string to use to replace quotes var $replaceQuote = "''"; // string to use to replace quotes
var $concat_operator='||'; var $concat_operator='||';
var $sysDate = "TO_DATE(TO_CHAR(SYSDATE,'YYYY-MM-DD'),'YYYY-MM-DD')"; var $sysDate = "TRUNC(SYSDATE)";
var $sysTimeStamp = 'SYSDATE'; var $sysTimeStamp = 'SYSDATE';
var $_stmt; var $_stmt;
@ -594,6 +594,7 @@ NATSOFT.DOMAIN =
return "'".str_replace("\\'",$this->replaceQuote,$s)."'"; return "'".str_replace("\\'",$this->replaceQuote,$s)."'";
} }
} }
} }
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
@ -631,23 +632,13 @@ class ADORecordset_oci8 extends ADORecordSet {
$this->fields = array(); $this->fields = array();
if ($this->_queryID) { if ($this->_queryID) {
/*
if ($this->connection->_getarray) {
if ($this->connection->_hasOCIFetchStatement) {
$arr = array();
if (OCIFetchStatement($this->_queryID,$arr,0,(integer)-1,OCI_FETCHSTATEMENT_BY_ROW|$this->fetchMode)) {
$this->_arr = $arr;
}
$this->EOF = false;
}
} else */
{
$this->EOF = !$this->_fetch();
$this->_currentRow = 0; $this->_currentRow = 0;
}
@$this->_initrs(); @$this->_initrs();
$this->EOF = !$this->_fetch();
} else { } else {
$this->_numOfRows = 0; $this->_numOfRows = 0;
$this->_numOfFields = 0; $this->_numOfFields = 0;

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* @version V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. * @version V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license. * Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses, * Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence. * the BSD license will take precedence.
@ -18,6 +18,11 @@ class ADODB_oci805 extends ADODB_oci8 {
var $databaseType = "oci805"; var $databaseType = "oci805";
var $connectSID = true; var $connectSID = true;
function ADODB_oci805()
{
$this->ADODB_oci8();
}
function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$arg3=false,$secs2cache=0) function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$arg3=false,$secs2cache=0)
{ {
// seems that oracle only supports 1 hint comment in 8i // seems that oracle only supports 1 hint comment in 8i

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim. All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim. All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
version V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights version V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights
reserved. reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim. All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim. All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@ -236,7 +236,7 @@ class ADORecordSet_array_sybase extends ADORecordSet_array {
if (!ereg( "([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})" if (!ereg( "([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})"
,$v, $rr)) return parent::UnixDate($v); ,$v, $rr)) return parent::UnixDate($v);
if ($rr[3] <= 1970) return 0; if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
$themth = substr(strtoupper($rr[1]),0,3); $themth = substr(strtoupper($rr[1]),0,3);
$themth = $ADODB_sybase_mths[$themth]; $themth = $ADODB_sybase_mths[$themth];
@ -252,7 +252,7 @@ class ADORecordSet_array_sybase extends ADORecordSet_array {
//Changed [0-9] to [0-9 ] in day conversion //Changed [0-9] to [0-9 ] in day conversion
if (!ereg( "([A-Za-z]{3})[-/\. ]([0-9 ]{1,2})[-/\. ]([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})" if (!ereg( "([A-Za-z]{3})[-/\. ]([0-9 ]{1,2})[-/\. ]([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})"
,$v, $rr)) return parent::UnixTimeStamp($v); ,$v, $rr)) return parent::UnixTimeStamp($v);
if ($rr[3] <= 1970) return 0; if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
$themth = substr(strtoupper($rr[1]),0,3); $themth = substr(strtoupper($rr[1]),0,3);
$themth = $ADODB_sybase_mths[$themth]; $themth = $ADODB_sybase_mths[$themth];

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@ -43,6 +43,7 @@ class ADODB_vfp extends ADODB_odbc {
return "'".$s."'"; return "'".$s."'";
} }
// TOP requires ORDER BY for VFP // TOP requires ORDER BY for VFP
function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$arg3=false,$secs2cache=0) function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$arg3=false,$secs2cache=0)
{ {

View file

@ -12,7 +12,7 @@
<body bgcolor="#FFFFFF"> <body bgcolor="#FFFFFF">
<h2>ADOdb Library for PHP</h2> <h2>ADOdb Library for PHP</h2>
<p>V2.00 13 May 2002 (c) 2000-2002 John Lim (<a href="mailto:jlim@natsoft.com.my">jlim@natsoft.com.my</a>)</p> <p>V2.12 12 June 2002 (c) 2000-2002 John Lim (<a href="mailto:jlim@natsoft.com.my">jlim@natsoft.com.my</a>)</p>
<p>This software is dual licensed using BSD-Style and LGPL. <p>This software is dual licensed using BSD-Style and LGPL.
Where there is any discrepancy, the BSD-Style license will take precedence. Where there is any discrepancy, the BSD-Style license will take precedence.
This means you can use it in proprietary and commercial products.</p> This means you can use it in proprietary and commercial products.</p>
@ -20,7 +20,7 @@ This means you can use it in proprietary and commercial products.</p>
<a href="#features">Unique Features</a><br> <a href="#features">Unique Features</a><br>
<a href="#users">How People are using ADOdb</a><br> <a href="#users">How People are using ADOdb</a><br>
<a href="#bugs">Feature Requests and Bug Reports</a><br> <a href="#bugs">Feature Requests and Bug Reports</a><br>
</b><b><a href="#install">Installation<br> </b><b><a href="#install">Installation<br>R
</a><a href="#coding">Initializing Code</a></b> </a><a href="#coding">Initializing Code</a></b>
<font size="2"><a href=#adonewconnection>ADONewConnection</a></font> <font size="2"><a href=#adonewconnection>ADONewConnection</a></font>
<font size="2"><a href=#adonewconnection>NewADOConnection</a></font><br> <font size="2"><a href=#adonewconnection>NewADOConnection</a></font><br>
@ -45,8 +45,8 @@ This means you can use it in proprietary and commercial products.</p>
Executing SQL: <a href="#execute">Execute</a> <a href="#cacheexecute">CacheExecute</a> Executing SQL: <a href="#execute">Execute</a> <a href="#cacheexecute">CacheExecute</a>
<a href="#SelectLimit">SelectLimit</a> <a href="#cacheSelectLimit">CacheSelectLimit</a> <a href="#SelectLimit">SelectLimit</a> <a href="#cacheSelectLimit">CacheSelectLimit</a>
<a href="#prepare">Prepare</a> <a href=#preparesp>PrepareSP</a> <a href="#parameter">Parameter</a> <a href="#prepare">Prepare</a> <a href=#preparesp>PrepareSP</a> <a href="#parameter">Parameter</a>
<a href="#getone">GetOne</a> <a href="#getrow">GetRow</a><br> <a href="#getone">GetOne</a> <a href="#getrow">GetRow</a> <a href="#replace">Replace</a> <br>
Generate Updates/Inserts: <a href="#getupdatesql">GetUpdateSQL</a> <a href="#getinsertsql">GetInsertSQL</a></font><font size="2"><br> Generates SQL: <a href="#getupdatesql">GetUpdateSQL</a> <a href="#getinsertsql">GetInsertSQL</a></font><font size="2"><br>
Blobs: <a href="#updateblob">UpdateBlob</a> <a href="#updateclob">UpdateClob</a> Blobs: <a href="#updateblob">UpdateBlob</a> <a href="#updateclob">UpdateClob</a>
<a href="#updateblobfile">UpdateBlobFile</a> <br> <a href="#updateblobfile">UpdateBlobFile</a> <br>
Paging/Scrolling: <a href="#pageexecute">PageExecute</a> <a href="#cachepageexecute">CachePageExecute</a><br> Paging/Scrolling: <a href="#pageexecute">PageExecute</a> <a href="#cachepageexecute">CachePageExecute</a><br>
@ -54,7 +54,7 @@ This means you can use it in proprietary and commercial products.</p>
Transactions: <a href="#begintrans">BeginTrans</a> <a href="#committrans">CommitTrans</a> Transactions: <a href="#begintrans">BeginTrans</a> <a href="#committrans">CommitTrans</a>
<a href="#rollbacktrans">RollbackTrans</a> <br> <a href="#rollbacktrans">RollbackTrans</a> <br>
Fetching Data: <a href="#adodb_fetch_mode">$ADODB_FETCH_MODE</a></font> <br> Fetching Data: <a href="#adodb_fetch_mode">$ADODB_FETCH_MODE</a></font> <br>
Strings: <a href="#concat">Concat</a> <a href="#qstr">qstr</a> <br> Strings: <a href="#concat">concat</a> <a href="#qstr">qstr</a> <a href="#quote">quote</a><br>
Dates: <a href="#dbdate">DBDate</a> <a href="#dbtimestamp">DBTimeStamp</a> <a href="#unixdate">UnixDate</a> Dates: <a href="#dbdate">DBDate</a> <a href="#dbtimestamp">DBTimeStamp</a> <a href="#unixdate">UnixDate</a>
<a href="#unixtimestamp">UnixTimeStamp</a><br> <a href="#unixtimestamp">UnixTimeStamp</a><br>
Rows Management: <a href="#affected_rows">Affected_Rows</a> <a href="#inserted_id">Insert_ID</a> Rows Management: <a href="#affected_rows">Affected_Rows</a> <a href="#inserted_id">Insert_ID</a>
@ -733,50 +733,85 @@ $conn->Close();
?> ?>
</pre> </pre>
<h3>Example 8: Implementing Scrolling with Next and Previous<a name="ex8"></a></h3> <h3>Example 8: Implementing Scrolling with Next and Previous<a name="ex8"></a></h3>
<p> <p> The following code creates a very simple recordset pager, where you can scroll
Code and idea by Iv&aacute;n Oliva ivan.oliva#amena.com. <p> from page to page of a recordset.</p>
We use the HTTP Get variable $next_page to keep track of what page to go next and
store the current page in the session variable $curr_page.
<p>
We call the connection object's PageExecute() function to generate the appropriate recordset,
then use the recordset's AtFirstPage() and AtLastPage() functions to determine
whether to display the next and previous buttons. <p>
<pre> <pre>
&lt;?php include_once('../adodb.inc.php');
include_once('adodb.inc.php'); include_once('../adodb-pager.inc.php');
include_once('tohtml.inc.php'); session_start();
<b>session_register('curr_page');</b>
$db = NewADOConnection('mysql'); $db = NewADOConnection('mysql');
$db->Connect('localhost','root','','xphplens'); $db->Connect('localhost','root','','xphplens');
<b>$num_of_rows_per_page = 10;
$sql = 'select * from products';
if (isset($HTTP_GET_VARS['next_page'])) $sql = "select * from adoxyz ";
$curr_page = $HTTP_GET_VARS['next_page'];
if (empty($curr_page)) $curr_page = 1; ## at first page</b><b>
$rs = $db->PageExecute($sql, $num_of_rows_per_page, $curr_page);</b> $pager = new ADODB_Pager($db,$sql);
if (!$rs) die('Query Failed'); $pager->Render($rows_per_page=5);</pre>
<p>This will create a basic record pager that looks like this: <a name=scr></a>
<p>
<table border=1 bgcolor=beige><tr>
<td> <a href="#scr"><code>|&lt;</code></a> &nbsp; <a href="#scr"><code>&lt;&lt;</code></a>
&nbsp; <a href="#scr"><code>>></code></a> &nbsp; <a href="#scr"><code>>|</code></a>
&nbsp; </td>
</tr><tr><td><TABLE COLS=4 width=100% border=1 bgcolor=white>
if (!$rs->EOF && (!$rs-><b>AtFirstPage</b>() || !$rs-><b>AtLastPage</b>())) &#123; <TH>ID</TH><TH>First Name</TH><TH>Last Name</TH><TH>Date Created</TH>
if (!$rs-><b>AtFirstPage</b>()) &#123;
?> <TR>
&lt;a href="&lt;?php echo $PHPSELF,'?next_page=',$rs-><b>AbsolutePage</b>() - 1 ?>">Previous page&lt;/a> <TD align=right>36&nbsp;</TD>
&lt;?php <TD>Alan&nbsp;</TD>
&#125; <TD>Turing&nbsp;</TD>
if (!$rs-><b>AtLastPage</b>()) &#123; <TD>Sat 06, Oct 2001&nbsp;</TD>
?> </TR>
&lt;a href="&lt;?php echo $PHPSELF,'?next_page=',$rs-><b>AbsolutePage</b>() + 1 ?>">Next page&lt;/a>
&lt;?php <TR>
&#125; <TD align=right>37&nbsp;</TD>
rs2html($rs); <TD>Serena&nbsp;</TD>
&#125; <TD>Williams&nbsp;</TD>
?> <TD>Sat 06, Oct 2001&nbsp;</TD>
</pre> </TR>
The above code can be found in the <i>testpaging.php</i> example included with
this release. <TR>
<TD align=right>38&nbsp;</TD>
<TD>Yat Sun&nbsp;</TD>
<TD>Sun&nbsp;</TD>
<TD>Sat 06, Oct 2001&nbsp;</TD>
</TR>
<TR>
<TD align=right>39&nbsp;</TD>
<TD>Wai Hun&nbsp;</TD>
<TD>See&nbsp;</TD>
<TD>Sat 06, Oct 2001&nbsp;</TD>
</TR>
<TR>
<TD align=right>40&nbsp;</TD>
<TD>Steven&nbsp;</TD>
<TD>Oey&nbsp;</TD>
<TD>Sat 06, Oct 2001&nbsp;</TD>
</TR>
</TABLE>
</td></tr><tr><td><font size=-1>Page 8/10</font></td></tr></table>
<p>The number of rows to display at one time is controled by the Render($rows)
method. If you do not pass any value to Render(), ADODB_Pager will default to
10 records per page.
<p>You can control the column titles by modifying your SQL (supported by most
databases):
<pre>$sql = 'select id as &quot;ID&quot;, firstname as &quot;First Name&quot;,
lastname as &quot;Last Name&quot;, created as &quot;Date Created&quot; <br> from adoxyz';</pre>
<p>The above code can be found in the <i>adodb/tests/testpaging.php</i> example
included with this release, and the class ADODB_Pager in <i>adodb/adodb-pager.inc.php</i>.
The ADODB_Pager code can be adapted by a programmer so that the text links can
be replaced by images, and the dull white background be replaced with more interesting
colors.
<p>Some of the code used here was contributed by Iv&aacute;n Oliva and Cornel
G. </p>
<p>
<h2><a name="errorhandling"></a>Using Custom Error Handlers and PEAR_Error</h2> <h2><a name="errorhandling"></a>Using Custom Error Handlers and PEAR_Error</h2>
Apart from the old $con->debug = true; way of debugging, ADOdb 1.50 onwards provides Apart from the old $con->debug = true; way of debugging, ADOdb 1.50 onwards provides
another way of handling errors using ADOdb's custom error handlers. another way of handling errors using ADOdb's custom error handlers.
@ -915,7 +950,7 @@ CacheExecute(). If you leave it out, it will use the $connection->cacheSecs para
to 60 minutes. to 60 minutes.
<pre> <pre>
$conn->Connect(...); $conn->Connect(...);
$conn->cacheSecs = 3600*24; // cache 24 hours $conn->cacheSecs = 3600*24; # cache 24 hours
$rs = $conn->CacheExecute('select * from table'); $rs = $conn->CacheExecute('select * from table');
</pre> </pre>
<font color="#000000"> <font color="#000000">
@ -1007,13 +1042,15 @@ to 60 minutes.
true.</p> true.</p>
<p><b>charSet</b>: set the default charset to use. Currently only interbase supports <p><b>charSet</b>: set the default charset to use. Currently only interbase supports
this.</p> this.</p>
<p><b>dialect</b>: set the default sql dialect to use. Currently only interbase supports
this.</p>
<p><b>metaTablesSQL</b>: SQL statement to return a list of available tables. Eg. <p><b>metaTablesSQL</b>: SQL statement to return a list of available tables. Eg.
<i>SHOW TABLES</i> in MySQL.</p> <i>SHOW TABLES</i> in MySQL.</p>
<p><b>genID</b>: The latest id generated by GenID() if supported by the database.</p> <p><b>genID</b>: The latest id generated by GenID() if supported by the database.</p>
<p><b>cacheSecs</b>: The number of seconds to cache recordsets if CacheExecute() <p><b>cacheSecs</b>: The number of seconds to cache recordsets if CacheExecute()
or CacheSelectLimit() do not define the $secs2cache parameter.</p> or CacheSelectLimit() do not define the $secs2cache parameter.</p>
<p><b>sysDate</b>: The database function to call to get the current date and time <p><b>sysDate</b>: String that holds the name of the database function to call to get the current date. Useful for inserts and updates.</p>
using the native date/timestamp type.</p> <p><b>sysTimeStamp</b>: String that holds the name of the database function to call to get the current timestamp/datetime value.</p>
<hr> <hr>
<h3>ADOConnection Main Functions</h3> <h3>ADOConnection Main Functions</h3>
<p><b>ADOConnection( )</b></p> <p><b>ADOConnection( )</b></p>
@ -1244,6 +1281,40 @@ Similar to UpdateBlob (see above), but for Character Large OBjects.
<p>Similar to UpdateBlob, except that we pass in a file path to where the blob <p>Similar to UpdateBlob, except that we pass in a file path to where the blob
resides. resides.
<p>returns true if successful, false otherwise. <p>returns true if successful, false otherwise.
<p><b>Replace<a name="replace"></a>($table, $arrFields, $keyCols,$autoQuote=false)</b></p>
<p>Try to update a record, and if the record is not found,
an insert statement is generated and executed.
Returns 0 on failure, 1 if update statement worked, 2 if no record
was found and the insert was executed successfully. This differs from the MySQL replace which deletes
the record and inserts a new record. This also means you cannot update the primary key.
<p>The parameters are $table which is the table name, the $keyCols which is an associative array where
the keys are the field names, and keyCols is the name of the primary key, or an array of field names if
it is a compound key. If $autoQuote is set to true, then Replace() will quote all values that are non-numeric;
auto-quoting will not quote nulls. Note that auto-quoting will not work if you use SQL functions or operators.
<p>Examples:
<pre>
# single field primary key
$ret = $db->Replace('atable',
array('id'=>1000,'firstname'=>'Harun','lastname'=>'Al-Rashid'),
'id',
'firstname',$autoquote = true);
# generates UPDATE atable SET firstname='Harun',lastname='Al-Rashid' WHERE id=1000
# or INSERT INTO atable (id,firstname,lastname) VALUES (1000,'Harun','Al-Rashid')
# compound key
$ret = $db->Replace('atable2',
array('firstname'=>'Harun','lastname'=>'Al-Rashid', 'age' => 33, 'birthday' => 'null'),
array('lastname','firstname'),
'firstname',$autoquote = true);
# no auto-quoting
$ret = $db->Replace('atable2',
array('firstname'=>"'Harun'",'lastname'=>"'Al-Rashid'", 'age' => 'null'),
array('lastname','firstname'),
'firstname');
</pre>
<p><b>GetUpdateSQL<a name="getupdatesql"></a>(&$rs, $arrFields, $forceUpdate=false,$magicq=false)</b></p> <p><b>GetUpdateSQL<a name="getupdatesql"></a>(&$rs, $arrFields, $forceUpdate=false,$magicq=false)</b></p>
<p>Generate SQL to update a table given a recordset $rs, and the modified fields <p>Generate SQL to update a table given a recordset $rs, and the modified fields
of the array $arrFields (which must be an associative array holding the column of the array $arrFields (which must be an associative array holding the column
@ -1447,6 +1518,9 @@ for ($i = 0; $i &lt; $max; $i++) {
and once by the <i>magic_quotes_gpc</i>.</p> and once by the <i>magic_quotes_gpc</i>.</p>
<p>Eg.<font face="Courier New, Courier, mono"> $s = $db-&gt;qstr(HTTP_GET_VARS['name'],get_magic_quotes_gpc());</font></p> <p>Eg.<font face="Courier New, Courier, mono"> $s = $db-&gt;qstr(HTTP_GET_VARS['name'],get_magic_quotes_gpc());</font></p>
<p>Returns the quoted string.</p> <p>Returns the quoted string.</p>
<p><b>Quote<a name="quote"></a>($s)</b></p>
<p>Quotes the string, automatically checking get_magic_quotes_gpc() first.
If get_magic_quotes_gpc() is set, then we do not quote the string.
<p><b>Affected_Rows<a name="Affected_Rows"></a>( )</b></p> <p><b>Affected_Rows<a name="Affected_Rows"></a>( )</b></p>
<p>Returns the number of rows affected by a update or delete statement. Returns <p>Returns the number of rows affected by a update or delete statement. Returns
false if function not supported.</p> false if function not supported.</p>
@ -1829,9 +1903,42 @@ $<font color="#663300">rs</font> = $<font color="#663300">conn</font>->Execute
<h2>ToDo:</h2> <h2>ToDo:</h2>
<p>See the <a href=http://php.weblogs.com/adodb-todo-roadmap>RoadMap</a> article.</p> <p>See the <a href=http://php.weblogs.com/adodb-todo-roadmap>RoadMap</a> article.</p>
<p>Also see the ADOdb <a href=http://php.weblogs.com/adodb_csv>proxy</a> article <p>Also see the ADOdb <a href=http://php.weblogs.com/adodb_csv>proxy</a> article
for bridging Windows and Unix databases using http remote procedure calls.</p> for bridging Windows and Unix databases using http remote procedure calls. For
your education, visit <a href=http://palslib.com/>palslib.com</a> for database info,
and read this article
on <a href=http://phplens.com/lens/php-book/optimizing-debugging-php.php>Optimizing PHP</a>.
</p>
</font> </font>
<h2>Change Log<a name="Changes"></a><a name=ChangeLog></a></h2> <h2>Change Log<a name="Changes"></a><a name=ChangeLog></a></h2>
<p><b>2.12 12 June 2002</b></p>
<p>Added toexport.inc.php to export recordsets in CSV and tab-delimited format.
<p>CachePageExecute() does not work - fixed - thx John Huong.
<p>Interbase aliases not set properly in FetchField() - fixed. Thx Stefan Goethals.
<p>Added cache property to adodb pager class. The number of secs to cache recordsets.
<p>SQL rewriting bug in pageexecute() due to skipping of newlines due to missing /s modifier. Fixed.
<p>Max size of cached recordset due to a bug was 256000 bytes. Fixed.
<p>Speedup of 1st invocation of CacheExecute() by tuning code.
<p>We compare $rewritesql with $sql in pageexecute code in case of rewrite failure.
<p><b>2.11 7 June 2002</b></p>
<p>Fixed PageExecute() rewrite sql problem - COUNT(*) and ORDER BY don't go together with
mssql, access and postgres. Thx to Alexander Zhukov alex#unipack.ru
<p>DB2 support for CHARACTER type added - thx John Huong huongch#bigfoot.com
<p>For ado, $argProvider not properly checked. Fixed - kalimero#ngi.it
<p>Added $conn->Replace() function for update with automatic insert if the record does not exist.
Supported by all databases except interbase.
<p><b>2.10 4 June 2002</b></p>
<p>Added uniqueSort property to indicate mssql ORDER BY cols must be unique.
<p>Optimized session handler by crc32 the data. We only write if session data has changed.
<p>adodb_sess_read in adodb-session.php now returns ''correctly - thanks to Jorma Tuomainen, webmaster#wizactive.com
<p>Mssql driver did not throw EXECUTE errors correctly because ErrorMsg() and ErrorNo() called in wrong order.
Pointed out by Alexios Fakos. Fixed.
<p>Changed ado to use client cursors. This fixes BeginTran() problems with ado.
<p>Added handling of timestamp type in ado.
<p>Added to ado_mssql support for insert_id() and affected_rows().
<p>Added support for mssql.datetimeconvert=0, available since php 4.2.0.
<p>Made UnixDate() less strict, so that the time is ignored if present.
<p>Changed quote() so that it checks for magic_quotes_gpc.
<p>Changed maxblobsize for odbc to default to 64000.
<p><b>2.00 13 May 2002</b></p> <p><b>2.00 13 May 2002</b></p>
<p>Added drivers <i>informix72</i> for pre-7.3 versions, and <i>oci805</i> for <p>Added drivers <i>informix72</i> for pre-7.3 versions, and <i>oci805</i> for
oracle 8.0.5, and postgres64 for postgresql 6.4 and earlier. The postgres and postgres7 drivers oracle 8.0.5, and postgres64 for postgresql 6.4 and earlier. The postgres and postgres7 drivers

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* @version V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. * @version V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license. * Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@ -88,7 +88,7 @@ if (isset($HTTP_GET_VARS['nrows'])) {
$rs = $conn->Execute($sql); $rs = $conn->Execute($sql);
if ($rs){ if ($rs){
//$rs->timeToLive = 1; //$rs->timeToLive = 1;
echo rs2csv($rs,$conn,$sql); echo _rs2serialize($rs,$conn,$sql);
$rs->Close(); $rs->Close();
} else } else
err($conn->ErrorNo(). $sep .$conn->ErrorMsg()); err($conn->ErrorNo(). $sep .$conn->ErrorMsg());

View file

@ -8,7 +8,7 @@
<body> <body>
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -2,7 +2,7 @@
<body bgcolor=white> <body bgcolor=white>
<?php <?php
/** /**
* (c)2001,2002 John Lim (jlim@natsoft.com.my). All rights reserved. * V2.12 12 June 2002 (c) 2001-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license. * Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@ -86,8 +86,8 @@ GLOBAL $ADODB_vers,$ADODB_CACHE_DIR,$ADODB_FETCH_MODE, $HTTP_GET_VARS,$ADODB_COU
print "<h3>ADODB Version: $ADODB_vers Host: <i>$db->host</i> &nbsp; Database: <i>$db->database</i> &nbsp; PHP: $phpv</h3>"; print "<h3>ADODB Version: $ADODB_vers Host: <i>$db->host</i> &nbsp; Database: <i>$db->database</i> &nbsp; PHP: $phpv</h3>";
$e = error_reporting(E_ALL-E_WARNING); $e = error_reporting(E_ALL-E_WARNING);
print "<i>date1</i> (1969-02-20) = ".$db->DBDate('1969-2-20');
print "<i>date1</i> (1999-02-20) = ".$db->DBDate('1999-2-20'); print "<br><i>date1</i> (1999-02-20) = ".$db->DBDate('1999-2-20');
print "<br><i>date2</i> (1970-1-2) = ".$db->DBDate(24*3600)."<p>"; print "<br><i>date2</i> (1970-1-2) = ".$db->DBDate(24*3600)."<p>";
print "<i>ts1</i> (1999-02-20 3:40:50) = ".$db->DBTimeStamp('1999-2-20 3:40:50'); print "<i>ts1</i> (1999-02-20 3:40:50) = ".$db->DBTimeStamp('1999-2-20 3:40:50');
print "<br><i>ts2</i> (1999-02-20) = ".$db->DBTimeStamp('1999-2-20'); print "<br><i>ts2</i> (1999-02-20) = ".$db->DBTimeStamp('1999-2-20');
@ -140,12 +140,13 @@ GLOBAL $ADODB_vers,$ADODB_CACHE_DIR,$ADODB_FETCH_MODE, $HTTP_GET_VARS,$ADODB_COU
if ($rs) $rs->Close(); if ($rs) $rs->Close();
$db->debug=false; //$db->debug=true;
print "<p>Testing Commit: "; print "<p>Testing Commit: ";
$time = $db->DBDate(time()); $time = $db->DBDate(time());
if (!$db->BeginTrans()) print '<b>Transactions not supported</b></p>'; if (!$db->BeginTrans()) print '<b>Transactions not supported</b></p>';
else { /* COMMIT */ else { /* COMMIT */
$rs = $db->Execute("insert into ADOXYZ values (99,'Should Not','Exist (Commit)',$time)");
$rs = $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values (99,'Should Not','Exist (Commit)',$time)");
if ($rs && $db->CommitTrans()) { if ($rs && $db->CommitTrans()) {
$rs->Close(); $rs->Close();
$rs = &$db->Execute("select * from ADOXYZ where id=99"); $rs = &$db->Execute("select * from ADOXYZ where id=99");
@ -156,13 +157,16 @@ GLOBAL $ADODB_vers,$ADODB_CACHE_DIR,$ADODB_FETCH_MODE, $HTTP_GET_VARS,$ADODB_COU
die(); die();
} else print 'OK</p>'; } else print 'OK</p>';
if ($rs) $rs->Close(); if ($rs) $rs->Close();
} else } else {
print "<b>Commit failed</b></p>"; if (!$rs) {
print "<b>Insert failed</b></p>";
$db->RollbackTrans();
} else print "<b>Commit failed</b></p>";
}
/* ROLLBACK */ /* ROLLBACK */
if (!$db->BeginTrans()) print "<p><b>Error in BeginTrans</b>()</p>"; if (!$db->BeginTrans()) print "<p><b>Error in BeginTrans</b>()</p>";
print "<p>Testing Rollback: "; print "<p>Testing Rollback: ";
$db->Execute("insert into ADOXYZ values (100,'Should Not','Exist (Rollback)',$time)"); $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values (100,'Should Not','Exist (Rollback)',$time)");
if ($db->RollbackTrans()) { if ($db->RollbackTrans()) {
$rs = $db->Execute("select * from ADOXYZ where id=100"); $rs = $db->Execute("select * from ADOXYZ where id=100");
if ($rs && !$rs->EOF) print '<b>Fail: Data should rollback</b></p>'; if ($rs && !$rs->EOF) print '<b>Fail: Data should rollback</b></p>';
@ -307,11 +311,10 @@ GO
$db->debug = false; $db->debug = false;
$ADODB_FETCH_MODE = ADODB_FETCH_BOTH; $ADODB_FETCH_MODE = ADODB_FETCH_BOTH;
/////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
$rs = &$db->Execute("select * from ADOXYZ order by id"); $rs = &$db->Execute("select id,firstname as TheFirstName,lastname,created from ADOXYZ order by id");
if ($rs) { if ($rs) {
// print_r($rs);
if ($rs->RecordCount() != 50) { if ($rs->RecordCount() != 50) {
print "<p><b>RecordCount returns -1</b></p>"; print "<p><b>RecordCount returns -1</b></p>";
if ($rs->PO_RecordCount('ADOXYZ') == 50) print "<p> &nbsp; &nbsp; PO_RecordCount passed</p>"; if ($rs->PO_RecordCount('ADOXYZ') == 50) print "<p> &nbsp; &nbsp; PO_RecordCount passed</p>";
@ -586,7 +589,7 @@ GO
if ($val == 0) echo " <p><b>GenID not supported</b>"; if ($val == 0) echo " <p><b>GenID not supported</b>";
echo "<p>"; echo "<p>";
if (substr($db->dataProvider,0,3) != 'ado') { // crashes ado if (substr($db->dataProvider,0,3) != 'notused') { // used to crash ado
$sql = "select firstnames from adoxyz"; $sql = "select firstnames from adoxyz";
print "<p>Testing execution of illegal statement: <i>$sql</i></p>"; print "<p>Testing execution of illegal statement: <i>$sql</i></p>";
if ($db->Execute($sql) === false) { if ($db->Execute($sql) === false) {
@ -656,6 +659,8 @@ GO
} else } else
print "<p>Passed \$sysDate test ({$rs->fields[0]})</p>"; print "<p>Passed \$sysDate test ({$rs->fields[0]})</p>";
print_r($rs->FetchField(0));
print time();
$db->debug=$saved; $db->debug=$saved;
} else { } else {
print "<p><b>\$db->sysDate not defined</b></p>"; print "<p><b>\$db->sysDate not defined</b></p>";
@ -679,9 +684,43 @@ GO
$rs->Close(); $rs->Close();
} }
print "<p>Test CSV</p>";
include_once('../toexport.inc.php');
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$rs = $db->SelectLimit('select id,firstname,lastname,created,\'The "young man", he said\' from adoxyz',10);
print "<pre>";
print rs2csv($rs);
print "</pre>";
$rs = $db->SelectLimit('select id,firstname,lastname,created,\'The "young man", he said\' from adoxyz',10);
print "<pre>";
tab2csvout($rs);
print "</pre>";
$db->debug=1;
print "<p>Test Replace</p>";
$ret = $db->Replace('adoxyz',
array('id'=>1000,'firstname'=>'Harun','lastname'=>'Al-Rashid'),
array('id','firstname'),
$autoq = true);
if ($ret != 2) print "<b>Replace failed: </b>";
print "test A return value=$ret (2 expected) <p>";
$ret = $db->Replace('adoxyz',
array('id'=>1000,'firstname'=>'Sherazade','lastname'=>'Al-Rashid'),
'id',
$autoq = true);
if ($ret != 1) print "<b>Replace failed: </b>";
print "test B return value=$ret (1 expected) <p>";
/////////////////////////////////////////////////////////////
include_once "PEAR.php"; include_once "PEAR.php";
$db->debug =true;
if ($i != 50) { if ($i != 50) {
print "<p><b>PEAR DB emulation error 1.1 EOF ($i)</b></p>"; print "<p><b>PEAR DB emulation error 1.1 EOF ($i)</b></p>";
$pear = false; $pear = false;
@ -713,14 +752,21 @@ GO
global $TESTERRS; global $TESTERRS;
$debugerr = true;
$db->debug = false; $db->debug = false;
$TESTERRS = 0; $TESTERRS = 0;
$db->raiseErrorFn = 'adodb_test_err'; $db->raiseErrorFn = 'adodb_test_err';
$db->Execute('select * from nowhere'); $db->Execute('select * from nowhere');
if ($TESTERRS != 1) print "<b>raiseErrorFn select nowhere failed</b><br>";
$rs = $db->Execute('select * from adoxyz'); $rs = $db->Execute('select * from adoxyz');
if ($debugerr) print " Move";
$rs->Move(100); $rs->Move(100);
$rs->_queryID = false; $rs->_queryID = false;
if ($debugerr) print " MoveNext";
$rs->MoveNext(); $rs->MoveNext();
if ($debugerr) print " $rs=false";
$rs = false; $rs = false;
$conn = NewADOConnection($db->databaseType); $conn = NewADOConnection($db->databaseType);
$conn->raiseErrorFn = 'adodb_test_err'; $conn->raiseErrorFn = 'adodb_test_err';

View file

@ -8,7 +8,7 @@
<body> <body>
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@ -23,30 +23,15 @@ include("../adodb.inc.php");
ADOLoadCode('mysql'); ADOLoadCode('mysql');
$c1 = ADONewConnection('mysql'); $c1 = ADONewConnection('oci8');
$c2 = ADONewConnection('mysql');
if (!$c1->PConnect('flipper','','',"test")) if (!$c1->PConnect('','scott','tiger'))
die("Cannot connect to flipper"); die("Cannot connect to server");
if (!$c2->PConnect('mangrove','root','',"northwind")) $c1->debug=1;
die("Cannot connect to mangrove");
print "<h3>Flipper</h3>";
$t = $c1->MetaTables(); # list all tables in DB
print_r($t);
# select * from last table in DB
rs2html($c1->Execute("select * from ".$t[sizeof($t)-1]));
print "<h3>Mangrove</h3>";
$t = $c2->MetaTables();
print_r($t);
rs2html($c2->Execute("select * from ".$t[sizeof($t)-1] ));
print "<h3>Flipper</h3>";
$t = $c1->MetaTables();
print_r($t);
rs2html($c1->Execute("select * from ".$t[sizeof($t)-1]));
$rs = $c1->CacheExecute(1200,'select rownum, p1.firstname,p2.lastname,p2.firstname,p1.lastname from adoxyz p1, adoxyz p2');
print "Records=".$rs->RecordCount()."<br>";
rs2html($rs);
?> ?>

View file

@ -1,7 +1,7 @@
<code> <code>
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @version V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. * @version V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license. * Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses, * Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence. * the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -2,7 +2,7 @@
<body> <body>
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@ -106,7 +106,7 @@ ADOLoadCode('oci805');
ADOLoadCode("oci8po"); ADOLoadCode("oci8po");
if (!empty($testoracle)) { if (!empty($testoracle)) {
$db = ADONewConnection(); $db = ADONewConnection('oci8po');
print "<h1>Connecting $db->databaseType...</h1>"; print "<h1>Connecting $db->databaseType...</h1>";
if ($db->Connect('', "scott", "tiger",'natsoft.ecosystem.natsoft.com.my')) if ($db->Connect('', "scott", "tiger",'natsoft.ecosystem.natsoft.com.my'))
//if ($db->PConnect("", "scott", "tiger", "juris.ecosystem.natsoft.com.my")) //if ($db->PConnect("", "scott", "tiger", "juris.ecosystem.natsoft.com.my"))
@ -127,7 +127,7 @@ if (false && !empty($testoracle)) {
ADOLoadCode("odbc_mssql"); ADOLoadCode("odbc_mssql");
if (!empty($testmssql) and false) { // MS SQL Server via ODBC if (!empty($testmssql) && false) { // MS SQL Server via ODBC
$db = ADONewConnection(); $db = ADONewConnection();
@ -143,10 +143,11 @@ ADOLoadCode("ado_mssql");
if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC -- DSN-less if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC -- DSN-less
$db = &ADONewConnection("ado_mssql"); $db = &ADONewConnection("ado_mssql");
$db->debug=1;
print "<h1>Connecting DSN-less $db->databaseType...</h1>"; print "<h1>Connecting DSN-less $db->databaseType...</h1>";
$myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};" $myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};"
. "SERVER=(local);DATABASE=NorthWind;UID=sa;PWD=natsoft;" ; . "SERVER=mangrove;DATABASE=NorthWind;UID=sa;PWD=natsoft;" ;
if (@$db->PConnect($myDSN, "", "", "")) if (@$db->PConnect($myDSN, "", "", ""))
@ -159,6 +160,7 @@ if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC
ADOLoadCode("mssql"); ADOLoadCode("mssql");
if (!empty($testmssql)) { // MS SQL Server -- the extension is buggy -- probably better to use ODBC if (!empty($testmssql)) { // MS SQL Server -- the extension is buggy -- probably better to use ODBC
$db = ADONewConnection(); $db = ADONewConnection();
$db->debug=1;
print "<h1>Connecting $db->databaseType...</h1>"; print "<h1>Connecting $db->databaseType...</h1>";
$db->Connect('(local)\NetSDK','','','northwind'); $db->Connect('(local)\NetSDK','','','northwind');
@ -174,7 +176,7 @@ if (!empty($testmssql) && !empty($testado)) { // ADO ACCESS MSSQL with OLEDB pro
$db = &ADONewConnection("ado_mssql"); $db = &ADONewConnection("ado_mssql");
print "<h1>Connecting DSN-less OLEDB Provider $db->databaseType...</h1>"; print "<h1>Connecting DSN-less OLEDB Provider $db->databaseType...</h1>";
$db->debug=1;
$myDSN="SERVER=mangrove;DATABASE=ai;"; $myDSN="SERVER=mangrove;DATABASE=ai;";
//$myDSN='SERVER=(local)\NetSDK;DATABASE=northwind;'; //$myDSN='SERVER=(local)\NetSDK;DATABASE=northwind;';
if ($db->PConnect($myDSN, "sa", "natsoft", 'SQLOLEDB')) if ($db->PConnect($myDSN, "sa", "natsoft", 'SQLOLEDB'))

View file

@ -1,5 +1,7 @@
<?php <?php
/* /*
V2.12 12 June 2002
Run multiple copies of this php script at the same time Run multiple copies of this php script at the same time
to test unique generation of id's in multiuser mode to test unique generation of id's in multiuser mode
*/ */

View file

@ -0,0 +1,50 @@
<?php
/**
* @version V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
*
* Set tabs to 4 for best viewing.
*
* Latest version is available at http://php.weblogs.com
*
* Test GetUpdateSQL and GetInsertSQL.
*/
error_reporting(E_ALL);
include('../adodb.inc.php');
include('../tohtml.inc.php');
//==========================
// This code tests an insert
$conn = &ADONewConnection("odbc_mssql"); // create a connection
$conn->Connect('sqlserver','sa','natsoft');
//$conn = &ADONewConnection("mssql");
//$conn->Connect('mangrove','sa','natsoft','ai');
//$conn->Connect('mangrove','sa','natsoft','ai');
$conn->debug=1;
$conn->Execute('delete from blobtest');
$conn->Execute('insert into blobtest (id) values(1)');
$conn->UpdateBlobFile('blobtest','b1','../cute_icons_for_site/adodb.gif','id=1');
$rs = $conn->Execute('select b1 from blobtest where id=1');
$output = "c:\\temp\\test_out-".date('H-i-s').".gif";
print "Saving file <b>$output</b>, size=".strlen($rs->fields[0])."<p>";
$fd = fopen($output, "wb");
fwrite($fd, $rs->fields[0]);
fclose($fd);
print " <a href=file://$output>View Image</a>";
//$rs = $conn->Execute('SELECT id,SUBSTRING(b1, 1, 10) FROM blobtest');
//rs2html($rs);
?>

View file

@ -2,7 +2,7 @@
<body> <body>
<?php <?php
/* /*
V1.81 22 March 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@ -11,44 +11,47 @@ V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reser
error_reporting(E_ALL); error_reporting(E_ALL);
$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
include_once('../adodb-pear.inc.php'); include_once('../adodb.inc.php');
include_once('../tohtml.inc.php'); include_once('../adodb-pager.inc.php');
session_register('curr_page');
$driver = 'mysql';
$sql = 'select ID, firstname as "First Name", lastname as "Last Name", created as "Date Created" from adoxyz order by id';
if ($driver == 'access') {
$db = NewADOConnection('access');
$db->PConnect("nwind", "", "", "");
}
if ($driver == 'ibase') {
$db = NewADOConnection('ibase');
$db->PConnect("localhost:e:\\interbase\\examples\\database\\employee.gdb", "sysdba", "masterkey", "");
$sql = 'select ID, firstname , lastname , created from adoxyz order by id';
}
if ($driver == 'mssql') {
$db = NewADOConnection('mssql');
$db->Connect('(local)\NetSDK','','','northwind');
}
if ($driver == 'oci8') {
$db = NewADOConnection('oci8');
$db->Connect('','scott','tiger');
}
if ($driver == 'access') {
$db = NewADOConnection('access');
$db->Connect('nwind');
}
if (empty($driver) or $driver == 'mysql') {
$db = NewADOConnection('mysql'); $db = NewADOConnection('mysql');
$db->debug = true;
//$db->Connect('localhost:4321','scott','tiger','natsoft.domain');
$db->Connect('localhost','root','','xphplens'); $db->Connect('localhost','root','','xphplens');
$num_of_rows_per_page = 7;
$sql = "select * from adoxyz ";
if (isset($HTTP_GET_VARS['next_page']))
$curr_page = $HTTP_GET_VARS['next_page'];
if (empty($curr_page)) $curr_page = 1; ## at first page
$rs = $db->PageExecute($sql, $num_of_rows_per_page, $curr_page);
if (!$rs) die('Query Failed');
if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage())) {
if (!$rs->AtFirstPage()) {
?>
<a href="<?php echo $PHP_SELF;?>?next_page=1">First page</a> &nbsp;
<a href="<?php echo $PHP_SELF,'?next_page=',$rs->AbsolutePage() - 1 ?>">Previous page</a> &nbsp;
<?php
} else {
echo " First Page &nbsp; Previous Page &nbsp; ";
}
if (!$rs->AtLastPage()) {
?>
<a href="<?php echo $PHP_SELF,'?next_page=',$rs->AbsolutePage() + 1 ?>">Next Page</a>
<?php
} else
print "Next Page";
rs2html($rs);
} }
//$db->pageExecuteCountRows = false;
$db->debug = true;
$pager = new ADODB_Pager($db,$sql);
//$pager->cache = 60;
$pager->Render($rows=7);
?> ?>

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@ -11,14 +11,14 @@ V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reser
GLOBAL $HTTP_SESSION_VARS; GLOBAL $HTTP_SESSION_VARS;
$ADODB_SESS_DEBUG = true; error_reporting(E_ALL);
include('adodb.inc.php');
include('adodb-session.php');
session_start();
session_register('AVAR');
$HTTP_SESSION_VARS['AVAR'] += 1;
$AVAR += 1;
print "<p>\$HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']}</p>"; $ADODB_SESS_DEBUG = true;
include('../adodb-session.php');
session_start();
if (!isset($HTTP_GET_VARS['nochange'])) $HTTP_SESSION_VARS['AVAR'] += 1;
print "<p><b>\$HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']}</b></p>";
?> ?>

View file

@ -257,7 +257,8 @@ $rs = $db-&gt;Execute(sprintf($sqlSearchKeyWord,$db-&gt;qstr($word)));</pre>
sound principles. Learn the theory of normalization and entity-relationship diagrams and model sound principles. Learn the theory of normalization and entity-relationship diagrams and model
your data carefully. Understand how joins and indexes work and how they are used to tune performance. your data carefully. Understand how joins and indexes work and how they are used to tune performance.
<p> Visit the following page for more references on database theory and vendors: <p> Visit the following page for more references on database theory and vendors:
<a href="http://php.weblogs.com/sql_tutorial">http://php.weblogs.com/sql_tutorial</a> <a href="http://php.weblogs.com/sql_tutorial">http://php.weblogs.com/sql_tutorial</a>.
Also read this article on <a href=http://phplens.com/lens/php-book/optimizing-debugging-php.php>Optimizing PHP</a>.
<p> <p>
<font size=1>(c) 2002 John Lim.</font> <font size=1>(c) 2002 John Lim.</font>

130
lib/adodb/toexport.inc.php Normal file
View file

@ -0,0 +1,130 @@
<?php
/**
* @version V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
*
* Code to export recordsets in several formats:
*
* AS VARIABLE
* $s = rs2csv($rs); # comma-separated values
* $s = rs2tab($rs); # tab delimited
*
* TO A FILE
* $f = fopen($path,'w');
* rs2csvfile($rs,$f);
* fclose($f);
*
* TO STDOUT
* rscsvout($rs);
*/
// returns a recordset as a csv string
function rs2csv(&$rs,$addtitles=true)
{
return _adodb_export($rs,',',',',false,$addtitles);
}
// writes recordset to csv file
function rs2csvfile(&$rs,$fp,$addtitles=true)
{
_adodb_export($rs,',',',',$fp,$addtitles);
}
// write recordset as csv string to stdout
function rs2csvout(&$rs,$addtitles=true)
{
$fp = fopen('php://stdout','wb');
_adodb_export($rs,',',',',true,$addtitles);
fclose($fp);
}
function tab2csv(&$rs,$addtitles=true)
{
return _adodb_export($rs,"\t",',',false,$addtitles);
}
// to file pointer
function tab2csvfile(&$rs,$fp,$addtitles=true)
{
_adodb_export($rs,"\t",',',$fp,$addtitles);
}
// to stdout
function tab2csvout(&$rs,$addtitles=true)
{
$fp = fopen('php://stdout','wb');
_adodb_export($rs,"\t",' ',true,$addtitles);
fclose($fp);
}
function _adodb_export(&$rs,$sep,$sepreplace,$fp=false,$addtitles=true,$quote = '"',$escquote = '"',$replaceNewLine = ' ')
{
if (!$rs) return '';
//----------
// CONSTANTS
$NEWLINE = "\r\n";
$BUFLINES = 100;
$escquotequote = $escquote.$quote;
$s = '';
if ($addtitles) {
$fieldTypes = $rs->FieldTypesArray();
foreach($fieldTypes as $o) {
$v = $o->name;
if ($escquote) $v = str_replace($quote,$escquotequote,$v);
$v = strip_tags(str_replace("\n",$replaceNewLine,str_replace($sep,$sepreplace,$v)));
$elements[] = $v;
}
$s .= implode($sep, $elements).$NEWLINE;
}
$hasNumIndex = isset($rs->fields[0]);
$line = 0;
$max = $rs->FieldCount();
while (!$rs->EOF) {
$elements = array();
$i = 0;
if ($hasNumIndex) {
for ($j=0; $j < $max; $j++) {
$v = $rs->fields[$j];
if ($escquote) $v = str_replace($quote,$escquotequote,$v);
$v = strip_tags(str_replace("\n",$replaceNewLine,str_replace($sep,$sepreplace,$v)));
if (strpos($v,$sep) || strpos($v,$quote))$elements[] = "$quote$v$quote";
else $elements[] = $v;
}
} else { // ASSOCIATIVE ARRAY
foreach($rs->fields as $v) {
if ($escquote) $v = str_replace($quote,$escquotequote,$v);
$v = strip_tags(str_replace("\n",$replaceNewLine,str_replace($sep,$sepreplace,$v)));
if (strpos($v,$sep) || strpos($v,$quote))$elements[] = "$quote$v$quote";
else $elements[] = $v;
}
}
$s .= implode($sep, $elements).$NEWLINE;
$rs->MoveNext();
$line += 1;
if ($fp && ($line % $BUFLINES) == 0) {
if ($fp === true) echo $s;
else fwrite($fp,$s);
$s = '';
}
}
if ($fp) {
if ($fp === true) echo $s;
else fwrite($fp,$s);
$s = '';
}
return $s;
}
?>

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved. V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@ -50,7 +50,6 @@ GLOBAL $gSQLMaxRows,$gSQLBlockRows;
$typearr = array(); $typearr = array();
$ncols = $rs->FieldCount(); $ncols = $rs->FieldCount();
$hdr = "<TABLE COLS=$ncols $ztabhtml>\n\n"; $hdr = "<TABLE COLS=$ncols $ztabhtml>\n\n";
for ($i=0; $i < $ncols; $i++) { for ($i=0; $i < $ncols; $i++) {
$field = $rs->FetchField($i); $field = $rs->FetchField($i);
if ($zheaderarray) $fname = $zheaderarray[$i]; if ($zheaderarray) $fname = $zheaderarray[$i];