From b1a1b00aa69041c70e1ae529f6643538cc7df591 Mon Sep 17 00:00:00 2001
From: martin Session: connection failed Session: No need to update - crc32 not changed Host=".$argHostname." Host=".$argHostname."<<
';
+ var $next = '>>
';
+ var $last = '>|
';
+ 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) {
+ ?>
+ first;?>
+ first ";
+ }
+ }
+
+ //--------------------------
+ // Display link to next page
+ function render_next($anchor=true)
+ {
+ global $PHP_SELF;
+
+ if ($anchor) {
+ ?>
+ next;?>
+ next ";
+ }
+ }
+
+ //------------------
+ // 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) {
+ ?>
+ last;?>
+ last ";
+ }
+ }
+
+ //----------------------
+ // Link to previous page
+ function render_prev($anchor=true)
+ {
+ global $PHP_SELF;
+ if ($anchor) {
+ ?>
+ prev;?>
+ prev ";
+ }
+ }
+
+ //--------------------------------------------------------
+ // 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 "$this->page ".$this->curr_page."/".$this->rs->LastPageNo()."";
+ }
+
+ //-----------------------------------
+ // 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 "Query failed: $this->sql
";
+ return;
+ }
+
+ if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage()))
+ $header = $this->RenderNav();
+ else
+ $header = " ";
+
+ $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 "
";
+ }
+}
+
+
+?>
\ No newline at end of file
diff --git a/lib/adodb/adodb-pear.inc.php b/lib/adodb/adodb-pear.inc.php
index 474c30124d..df2714a60d 100644
--- a/lib/adodb/adodb-pear.inc.php
+++ b/lib/adodb/adodb-pear.inc.php
@@ -1,6 +1,6 @@
Session Error: PHP.INI setting session.gc_maxlifetimenot set: $ADODB_SESS_LIFE";
+ $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';
-}
-if (empty($ADODB_SESSION_TBL)){
- $ADODB_SESSION_TBL = 'sessions';
-}
-
-$ADODB_SESS_LIFE = get_cfg_var('session.gc_maxlifetime');
-if ($ADODB_SESS_LIFE <= 1) {
- // bug in PHP 4.0.3 pl 1 -- how about other versions?
- //print "",
+ $header,
+ " ",
+ $grid,
+ " ",
+ $footer,
+ " Session Error: PHP.INI setting session.gc_maxlifetimenot set: $ADODB_SESS_LIFE
";
- $ADODB_SESS_LIFE=1440;
-}
+ //////////////////////////////////
+
+ 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)
{
GLOBAL $ADODB_SESS_CONN;
@@ -106,18 +115,23 @@ GLOBAL $ADODB_SESSION_CONNECT,
$ADODB_SESSION_DB,
$ADODB_SESS_DEBUG;
+ // cannot use & below - do not know why...
$ADODB_SESS_CONN = ADONewConnection($ADODB_SESSION_DRIVER);
if (!empty($ADODB_SESS_DEBUG)) {
$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);
- 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);
+ if (!$ok) print "
\n";
+ if ($this->debug) print $this->host.': '.$this->ErrorMsg()."
\n";
return false;
}
@@ -245,7 +255,7 @@
} else
if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true;
- if ($this->debug) print $this->host.': '.$this->ErrorMsg()."
\n";
+ if ($this->debug) print $this->host.': '.$this->ErrorMsg()."
\n";
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)
{
- return $this->qstr($s);
+ return $this->qstr($s,get_magic_quotes_gpc());
}
@@ -458,26 +468,30 @@
$inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']);
if ($inBrowser)
- print "
\n($this->databaseType): ".htmlspecialchars($sqlTxt)." $ss
\n
\n";
+ print "
\n($this->databaseType): ".htmlspecialchars($sqlTxt)." $ss
\n
\n";
else
print "=----\n($this->databaseType): ".($sqlTxt)." \n-----\n";
flush();
$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') {
// ErrorNo is a slow function call in mssql, and not reliable
// in PHP 4.0.6
- if($this->ErrorMsg()) {
+ if($emsg = $this->ErrorMsg()) {
$err = $this->ErrorNo();
if ($err) {
- print $err.': '.$this->ErrorMsg().(($inBrowser) ? "
\n" : "\n");
+ print $err.': '.$emsg.(($inBrowser) ? "
\n" : "\n");
flush();
}
}
} else
if (!$this->_queryID) {
- print $this->ErrorNo().': '.$this->ErrorMsg().(($inBrowser) ? "
\n" : "\n");
+ print $this->ErrorNo().': '.$this->ErrorMsg() .(($inBrowser) ? "
\n" : "\n");
flush();
}
} else
@@ -506,14 +520,14 @@
else $rs->sql = $sql;
global $ADODB_COUNTRECS;
- if ($rs->_numOfRows <= 0 && !$rs->EOF && $ADODB_COUNTRECS) {
+ if ($rs->_numOfRows <= 0 && !$rs->EOF && $ADODB_COUNTRECS) {
$rs = &$this->_rs2rs($rs);
$rs->_queryID = $this->_queryID;
}
return $rs;
}
-
+
/**
* Generates a sequence id and stores it in $this->genID;
* GenID is only available if $this->hasGenID = true;
@@ -522,7 +536,7 @@
* @startID if sequence does not exist, start at this ID
* @return 0 if not supported, otherwise a sequence id
*/
-
+
function GenID($seqname='adodbseq',$startID=1)
{
if (!$this->hasGenID) {
@@ -538,12 +552,12 @@
}
if ($rs && !$rs->EOF) $this->genID = (integer) reset($rs->fields);
else $this->genID = 0; // false
-
+
if ($rs) $rs->Close();
-
+
return $this->genID;
}
-
+
/**
* @return the last inserted ID. Not all databases support this.
*/
@@ -699,6 +713,7 @@
*/
function &_rs2rs(&$rs,$nrows=-1,$offset=-1)
{
+ if (! $rs) return false;
$arr = &$rs->GetArrayLimit($nrows,$offset);
$flds = array();
for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++)
@@ -768,7 +783,76 @@
}
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
return $this->SelectLimit($secs2cache,$sql,$nrows,$offset,$inputarr,$this->cacheSecs);
}
- if ($sql === false) echo "Warning: \$sql missing from CacheSelectLimit()
\n";
+ if ($sql === false) echo "Warning: \$sql missing from CacheSelectLimit()
\n";
return $this->SelectLimit($sql,$nrows,$offset,$inputarr,$arg3,$secs2cache);
}
@@ -849,10 +933,13 @@
$md5file = $this->_gencachename($sql,true);
$err = '';
- if ($secs2cache > 0)$rs = &csv2rs($md5file,$err,$secs2cache);
- else {
+ if ($secs2cache > 0){
+ $rs = &csv2rs($md5file,$err,$secs2cache);
+ $this->numCacheHits += 1;
+ } else {
$err='Timeout 1';
$rs = false;
+ $this->numCacheMisses += 1;
}
if (!$rs) {
@@ -862,8 +949,8 @@
if ($rs) {
$eof = $rs->EOF;
$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 ($fn = $this->raiseErrorFn) {
$fn($this->databaseType,'CacheExecute',-32000,"Cache write error",$md5file,$sql);
@@ -871,7 +958,8 @@
if ($this->debug) print " Cache write error
\n";
}
if ($rs->EOF && !$eof) {
- $rs = &csv2rs($md5file,$err);
+ $rs->MoveFirst();
+ //$rs = &csv2rs($md5file,$err);
$rs->connection = &$this; // Pablo suggestion
}
@@ -1182,7 +1270,6 @@
function DBDate($d)
{
- // note that we are limited to 1970 to 2038
if (empty($d) && $d !== 0) return 'null';
if (is_string($d) && !is_numeric($d))
@@ -1214,14 +1301,14 @@
* Also in ADORecordSet.
* @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)
{
- 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;
-
- if ($rr[1] <= 1970) return 0;
+
+ if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0;
// h-m-s-MM-DD-YY
return mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
}
@@ -1231,21 +1318,22 @@
* Also in ADORecordSet.
* @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)
{
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}))?$|",
($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
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());
*
* @param s the string to quote
@@ -1275,7 +1363,7 @@
return "'".str_replace("\\'",$this->replaceQuote,$s)."'";
}
}
-
+
/**
* Will select the supplied $page number from a recordset, given that it is paginated in pages of
@@ -1298,7 +1386,8 @@
function &PageExecute($sql, $nrows, $page, $inputarr=false, $arg3=false, $secs2cache=0)
{
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')
*/
function &CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false, $arg3=false) {
- include_once(ADODB_DIR.'/adodb-lib.inc.php');
- return _adodb_pageexecute($this, $sql, $nrows, $page, $inputarr, $arg3,$secs2cache);
+ return $this->PageExecute($sql,$nrows,$page,$inputarr,$arg3,$secs2cache);
}
} // end class ADOConnection
@@ -1402,8 +1490,8 @@
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 $_atLastPage = false; /* Added by Iván Oliva to implement recordset pagination */
-
-
+ var $_lastPageNo = -1;
+ var $_maxRecordCount = 0;
/**
* Constructor
*
@@ -1416,6 +1504,7 @@
}
+
function Init()
{
if ($this->_inited) return;
@@ -1606,7 +1695,7 @@
function UserTimeStamp($v,$fmt='Y-m-d H:i:s')
{
$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 == 0) return $this->emptyTimeStamp;
@@ -1623,10 +1712,10 @@
function UserDate($v,$fmt='Y-m-d')
{
$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;
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);
@@ -1636,14 +1725,14 @@
/**
* @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)
{
- 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;
- if ($rr[1] <= 1970) return 0;
+ if ($rr[1] <= 1903) return 0;
// h-m-s-MM-DD-YY
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
*
- * @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)
{
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}))?$|",
($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
return @mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
@@ -1875,6 +1964,15 @@
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
*
@@ -1936,6 +2034,18 @@
// 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.
*
@@ -2022,6 +2132,7 @@
case 'NVARCHAR':
case 'VARYING':
case 'BPCHAR':
+ case 'CHARACTER':
if (!empty($this)) if ($len <= $this->blobSize) return 'C';
else if ($len <= 250) return 'C';
@@ -2096,6 +2207,12 @@
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
*/
@@ -2347,7 +2464,7 @@
$ok = false;
}
if (!$ok) {
- if ($debug) print " Rename $tmpname ".($ok? 'ok' : 'failed')."
\n";
+ if ($debug) print " Rename $tmpname ".($ok? 'ok' : 'failed')."
\n";
}
return $ok;
}
diff --git a/lib/adodb/drivers/adodb-access.inc.php b/lib/adodb/drivers/adodb-access.inc.php
index 7556cdf3e3..7203fbc778 100644
--- a/lib/adodb/drivers/adodb-access.inc.php
+++ b/lib/adodb/drivers/adodb-access.inc.php
@@ -1,6 +1,6 @@
_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')
{
$u = 'UID';
@@ -43,13 +52,22 @@ class ADODB_ado extends ADOConnection {
$dbc = new COM('ADODB.Connection');
if (! $dbc) return false;
- /* // handle SQL server provider specially ? no need
- if ($argProvider) {
- if ($argProvider == "SQLOLEDB") { // SQL Server Provider
- }
- }*/
- if ($argProvider) $dbc->Provider = $argProvider;
- else $dbc->Provider ='MSDASQL';
+
+ /* special support if provider is mssql or access */
+ 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 ($argUsername) $argHostname .= ";$u=$argUsername";
if ($argPassword)$argHostname .= ";$p=$argPassword";
@@ -57,28 +75,17 @@ class ADODB_ado extends ADOConnection {
if ($this->debug) print "
version=$dbc->version
version=$dbc->version
";
@@ -472,7 +490,7 @@ class ADORecordSet_ado extends ADORecordSet {
function _fetch()
{
$rs = $this->_queryID;
- if ($rs->EOF) return false;
+ if (!$rs or $rs->EOF) return false;
$this->fields = array();
if (!$this->_tarr) {
@@ -494,6 +512,9 @@ class ADORecordSet_ado extends ADORecordSet {
for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) {
switch($t) {
+ case 135: // timestamp
+ $this->fields[] = date('Y-m-d H:i:s',(integer)$f->value);
+ break;
case 133:// A date value (yyyymmdd)
$val = $f->value;
diff --git a/lib/adodb/drivers/adodb-ado_access.inc.php b/lib/adodb/drivers/adodb-ado_access.inc.php
index 37d3e8d8d7..4175620e61 100644
--- a/lib/adodb/drivers/adodb-ado_access.inc.php
+++ b/lib/adodb/drivers/adodb-ado_access.inc.php
@@ -1,6 +1,6 @@
GetOne('select @@identity');
+ }
+
+ function _affectedrows()
+ {
+ return $this->GetOne('select @@rowcount');
+ }
+
}
class ADORecordSet_ado_mssql extends ADORecordSet_ado {
diff --git a/lib/adodb/drivers/adodb-borland_ibase.inc.php b/lib/adodb/drivers/adodb-borland_ibase.inc.php
index 370529b6d1..3e63ffdb5d 100644
--- a/lib/adodb/drivers/adodb-borland_ibase.inc.php
+++ b/lib/adodb/drivers/adodb-borland_ibase.inc.php
@@ -1,6 +1,6 @@
ADOdb: Replace not supported because affected_rows does not work with Interbase
V2.00 13 May 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my)
+V2.12 12 June 2002 (c) 2000-2002 John Lim (jlim@natsoft.com.my)
This software is dual licensed using BSD-Style and LGPL. Where there is any discrepancy, the BSD-Style license will take precedence. This means you can use it in proprietary and commercial products.
@@ -20,7 +20,7 @@ This means you can use it in proprietary and commercial products. Unique Features-Code and idea by Iván Oliva ivan.oliva#amena.com.
-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. -
-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.
- +
The following code creates a very simple recordset pager, where you can scroll + from page to page of a recordset.
+-<?php -include_once('adodb.inc.php'); -include_once('tohtml.inc.php'); -session_register('curr_page'); +include_once('../adodb.inc.php'); +include_once('../adodb-pager.inc.php'); +session_start(); $db = NewADOConnection('mysql'); + $db->Connect('localhost','root','','xphplens'); -$num_of_rows_per_page = 10; -$sql = 'select * from products'; -if (isset($HTTP_GET_VARS['next_page'])) - $curr_page = $HTTP_GET_VARS['next_page']; -if (empty($curr_page)) $curr_page = 1; ## at first page +$sql = "select * from adoxyz "; -$rs = $db->PageExecute($sql, $num_of_rows_per_page, $curr_page); -if (!$rs) die('Query Failed'); +$pager = new ADODB_Pager($db,$sql); +$pager->Render($rows_per_page=5);+
This will create a basic record pager that looks like this: +
+
|< <<
+ >> >|
+ |
+ ||||||||||||||||||||||||
| ||||||||||||||||||||||||
Page 8/10 |
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. +
You can control the column titles by modifying your SQL (supported by most + databases): +
$sql = 'select id as "ID", firstname as "First Name", + lastname as "Last Name", created as "Date Created"+
from adoxyz';
The above code can be found in the adodb/tests/testpaging.php example + included with this release, and the class ADODB_Pager in adodb/adodb-pager.inc.php. + 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. +
Some of the code used here was contributed by Iván Oliva and Cornel + G.
+
$conn->Connect(...); - $conn->cacheSecs = 3600*24; // cache 24 hours + $conn->cacheSecs = 3600*24; # cache 24 hours $rs = $conn->CacheExecute('select * from table');@@ -1006,14 +1041,16 @@ to 60 minutes.
autoCommit: indicates whether automatic commit is enabled. Default is true.
charSet: set the default charset to use. Currently only interbase supports - this.
+ this. +dialect: set the default sql dialect to use. Currently only interbase supports +this.
metaTablesSQL: SQL statement to return a list of available tables. Eg. SHOW TABLES in MySQL.
genID: The latest id generated by GenID() if supported by the database.
cacheSecs: The number of seconds to cache recordsets if CacheExecute() or CacheSelectLimit() do not define the $secs2cache parameter.
-sysDate: The database function to call to get the current date and time - using the native date/timestamp type.
+sysDate: String that holds the name of the database function to call to get the current date. Useful for inserts and updates.
+sysTimeStamp: String that holds the name of the database function to call to get the current timestamp/datetime value.
ADOConnection( )
@@ -1243,7 +1280,41 @@ Similar to UpdateBlob (see above), but for Character Large OBjects.UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB')
Similar to UpdateBlob, except that we pass in a file path to where the blob resides. -
returns true if successful, false otherwise. +
returns true if successful, false otherwise. +
Replace($table, $arrFields, $keyCols,$autoQuote=false)
+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. +
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. +
Examples: +
+# 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'); + ++
GetUpdateSQL(&$rs, $arrFields, $forceUpdate=false,$magicq=false)
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 @@ -1447,6 +1518,9 @@ for ($i = 0; $i < $max; $i++) { and once by the magic_quotes_gpc.
Eg. $s = $db->qstr(HTTP_GET_VARS['name'],get_magic_quotes_gpc());
Returns the quoted string.
+ +Quotes the string, automatically checking get_magic_quotes_gpc() first. +If get_magic_quotes_gpc() is set, then we do not quote the string.
Returns the number of rows affected by a update or delete statement. Returns false if function not supported.
@@ -1829,9 +1903,42 @@ $rs = $conn->ExecuteSee the RoadMap article.
Also see the ADOdb proxy article - for bridging Windows and Unix databases using http remote procedure calls.
+ for bridging Windows and Unix databases using http remote procedure calls. For + your education, visit palslib.com for database info, + and read this article + on Optimizing PHP. +2.12 12 June 2002
+Added toexport.inc.php to export recordsets in CSV and tab-delimited format. +
CachePageExecute() does not work - fixed - thx John Huong. +
Interbase aliases not set properly in FetchField() - fixed. Thx Stefan Goethals. +
Added cache property to adodb pager class. The number of secs to cache recordsets. +
SQL rewriting bug in pageexecute() due to skipping of newlines due to missing /s modifier. Fixed. +
Max size of cached recordset due to a bug was 256000 bytes. Fixed. +
Speedup of 1st invocation of CacheExecute() by tuning code. +
We compare $rewritesql with $sql in pageexecute code in case of rewrite failure. +
2.11 7 June 2002
+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 +
DB2 support for CHARACTER type added - thx John Huong huongch#bigfoot.com +
For ado, $argProvider not properly checked. Fixed - kalimero#ngi.it +
Added $conn->Replace() function for update with automatic insert if the record does not exist. + Supported by all databases except interbase. +
2.10 4 June 2002
+Added uniqueSort property to indicate mssql ORDER BY cols must be unique. +
Optimized session handler by crc32 the data. We only write if session data has changed. +
adodb_sess_read in adodb-session.php now returns ''correctly - thanks to Jorma Tuomainen, webmaster#wizactive.com +
Mssql driver did not throw EXECUTE errors correctly because ErrorMsg() and ErrorNo() called in wrong order. +Pointed out by Alexios Fakos. Fixed. +
Changed ado to use client cursors. This fixes BeginTran() problems with ado. +
Added handling of timestamp type in ado. +
Added to ado_mssql support for insert_id() and affected_rows(). +
Added support for mssql.datetimeconvert=0, available since php 4.2.0. +
Made UnixDate() less strict, so that the time is ignored if present. +
Changed quote() so that it checks for magic_quotes_gpc. +
Changed maxblobsize for odbc to default to 64000.
2.00 13 May 2002
Added drivers informix72 for pre-7.3 versions, and oci805 for oracle 8.0.5, and postgres64 for postgresql 6.4 and earlier. The postgres and postgres7 drivers diff --git a/lib/adodb/server.php b/lib/adodb/server.php index 687bd57d97..e906a1753e 100644 --- a/lib/adodb/server.php +++ b/lib/adodb/server.php @@ -1,6 +1,6 @@ Execute($sql); if ($rs){ //$rs->timeToLive = 1; - echo rs2csv($rs,$conn,$sql); + echo _rs2serialize($rs,$conn,$sql); $rs->Close(); } else err($conn->ErrorNo(). $sep .$conn->ErrorMsg()); diff --git a/lib/adodb/tests/benchmark.php b/lib/adodb/tests/benchmark.php index 32002ede0b..bbf403bf81 100644 --- a/lib/adodb/tests/benchmark.php +++ b/lib/adodb/tests/benchmark.php @@ -8,7 +8,7 @@
ADODB Version: $ADODB_vers Host: $db->host Database: $db->database PHP: $phpv"; $e = error_reporting(E_ALL-E_WARNING); - - print "date1 (1999-02-20) = ".$db->DBDate('1999-2-20'); + print "date1 (1969-02-20) = ".$db->DBDate('1969-2-20'); + print "";
print "ts1 (1999-02-20 3:40:50) = ".$db->DBTimeStamp('1999-2-20 3:40:50');
print "
ts2 (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();
- $db->debug=false;
+ //$db->debug=true;
print "
Testing Commit: "; $time = $db->DBDate(time()); if (!$db->BeginTrans()) print 'Transactions not supported
'; 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()) { $rs->Close(); $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(); } else print 'OK'; if ($rs) $rs->Close(); - } else - print "Commit failed"; - + } else { + if (!$rs) { + print "Insert failed"; + $db->RollbackTrans(); + } else print "Commit failed"; + } /* ROLLBACK */ if (!$db->BeginTrans()) print "Error in BeginTrans()
"; print "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()) { $rs = $db->Execute("select * from ADOXYZ where id=100"); if ($rs && !$rs->EOF) print 'Fail: Data should rollback
'; @@ -307,11 +311,10 @@ GO $db->debug = false; $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) { - // print_r($rs); if ($rs->RecordCount() != 50) { print "RecordCount returns -1
"; if ($rs->PO_RecordCount('ADOXYZ') == 50) print "PO_RecordCount passed
"; @@ -586,7 +589,7 @@ GO if ($val == 0) echo "GenID not supported"; echo "
"; - 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"; print "
Testing execution of illegal statement: $sql
"; if ($db->Execute($sql) === false) { @@ -655,7 +658,9 @@ GO print "Invalid date {$rs->fields[0]}
"; } else print "Passed \$sysDate test ({$rs->fields[0]})
"; - + + print_r($rs->FetchField(0)); + print time(); $db->debug=$saved; } else { print "\$db->sysDate not defined
"; @@ -678,10 +683,44 @@ GO } $rs->Close(); } + + print "Test CSV
"; + 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 ""; + print rs2csv($rs); + print ""; + + $rs = $db->SelectLimit('select id,firstname,lastname,created,\'The "young man", he said\' from adoxyz',10); + + print "
"; + tab2csvout($rs); + print ""; + $db->debug=1; + + print "
Test Replace
"; + + $ret = $db->Replace('adoxyz', + array('id'=>1000,'firstname'=>'Harun','lastname'=>'Al-Rashid'), + array('id','firstname'), + $autoq = true); + if ($ret != 2) print "Replace failed: "; + print "test A return value=$ret (2 expected)"; + + $ret = $db->Replace('adoxyz', + array('id'=>1000,'firstname'=>'Sherazade','lastname'=>'Al-Rashid'), + 'id', + $autoq = true); + if ($ret != 1) print "Replace failed: "; + print "test B return value=$ret (1 expected)
"; + + ///////////////////////////////////////////////////////////// + include_once "PEAR.php"; - $db->debug =true; if ($i != 50) { print "
PEAR DB emulation error 1.1 EOF ($i)
"; $pear = false; @@ -713,14 +752,21 @@ GO global $TESTERRS; + $debugerr = true; + $db->debug = false; $TESTERRS = 0; $db->raiseErrorFn = 'adodb_test_err'; $db->Execute('select * from nowhere'); + if ($TESTERRS != 1) print "raiseErrorFn select nowhere failed
Connecting $db->databaseType...";
if ($db->Connect('', "scott", "tiger",'natsoft.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");
-if (!empty($testmssql) and false) { // MS SQL Server via ODBC
+if (!empty($testmssql) && false) { // MS SQL Server via ODBC
$db = ADONewConnection();
@@ -143,10 +143,11 @@ ADOLoadCode("ado_mssql");
if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC -- DSN-less
$db = &ADONewConnection("ado_mssql");
+ $db->debug=1;
print "Connecting DSN-less $db->databaseType...
";
$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, "", "", ""))
@@ -159,6 +160,7 @@ if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC
ADOLoadCode("mssql");
if (!empty($testmssql)) { // MS SQL Server -- the extension is buggy -- probably better to use ODBC
$db = ADONewConnection();
+ $db->debug=1;
print "Connecting $db->databaseType...
";
$db->Connect('(local)\NetSDK','','','northwind');
@@ -174,7 +176,7 @@ if (!empty($testmssql) && !empty($testado)) { // ADO ACCESS MSSQL with OLEDB pro
$db = &ADONewConnection("ado_mssql");
print "Connecting DSN-less OLEDB Provider $db->databaseType...
";
-
+ $db->debug=1;
$myDSN="SERVER=mangrove;DATABASE=ai;";
//$myDSN='SERVER=(local)\NetSDK;DATABASE=northwind;';
if ($db->PConnect($myDSN, "sa", "natsoft", 'SQLOLEDB'))
diff --git a/lib/adodb/tests/testgenid.php b/lib/adodb/tests/testgenid.php
index 51e3b0afba..5d76d74ca8 100644
--- a/lib/adodb/tests/testgenid.php
+++ b/lib/adodb/tests/testgenid.php
@@ -1,5 +1,7 @@
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 $output, size=".strlen($rs->fields[0])."";
+$fd = fopen($output, "wb");
+fwrite($fd, $rs->fields[0]);
+fclose($fd);
+
+print " View Image";
+//$rs = $conn->Execute('SELECT id,SUBSTRING(b1, 1, 10) FROM blobtest');
+//rs2html($rs);
+?>
\ No newline at end of file
diff --git a/lib/adodb/tests/testoci8.php b/lib/adodb/tests/testoci8.php
index 735e93e270..b1088aed99 100644
--- a/lib/adodb/tests/testoci8.php
+++ b/lib/adodb/tests/testoci8.php
@@ -2,7 +2,7 @@
debug = true;
-//$db->Connect('localhost:4321','scott','tiger','natsoft.domain');
-$db->Connect('localhost','root','','xphplens');
+$driver = 'mysql';
+$sql = 'select ID, firstname as "First Name", lastname as "Last Name", created as "Date Created" from adoxyz order by id';
-$num_of_rows_per_page = 7;
-$sql = "select * from adoxyz ";
+if ($driver == 'access') {
+ $db = NewADOConnection('access');
+ $db->PConnect("nwind", "", "", "");
+}
-if (isset($HTTP_GET_VARS['next_page']))
- $curr_page = $HTTP_GET_VARS['next_page'];
-if (empty($curr_page)) $curr_page = 1; ## at first page
+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');
+}
-$rs = $db->PageExecute($sql, $num_of_rows_per_page, $curr_page);
-if (!$rs) die('Query Failed');
+if ($driver == 'access') {
+ $db = NewADOConnection('access');
+ $db->Connect('nwind');
+}
-if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage())) {
- if (!$rs->AtFirstPage()) {
-?>
-First page
-Previous page
-AtLastPage()) {
-?>
-Next Page
-Connect('localhost','root','','xphplens');
}
+//$db->pageExecuteCountRows = false;
+
+$db->debug = true;
-?>
+$pager = new ADODB_Pager($db,$sql);
+//$pager->cache = 60;
+$pager->Render($rows=7);
+?>
\ No newline at end of file
diff --git a/lib/adodb/tests/testpear.php b/lib/adodb/tests/testpear.php
index c0e69b2167..1ae17c3613 100644
--- a/lib/adodb/tests/testpear.php
+++ b/lib/adodb/tests/testpear.php
@@ -1,6 +1,6 @@
\$HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']}";
+ if (!isset($HTTP_GET_VARS['nochange'])) $HTTP_SESSION_VARS['AVAR'] += 1;
+
+ print "\$HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']}
";
?>
\ No newline at end of file
diff --git a/lib/adodb/tips_portable_sql.htm b/lib/adodb/tips_portable_sql.htm
index 6c6cde133a..e2dbcafada 100644
--- a/lib/adodb/tips_portable_sql.htm
+++ b/lib/adodb/tips_portable_sql.htm
@@ -257,7 +257,8 @@ $rs = $db->Execute(sprintf($sqlSearchKeyWord,$db->qstr($word)));
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.
Visit the following page for more references on database theory and vendors:
- http://php.weblogs.com/sql_tutorial
+ http://php.weblogs.com/sql_tutorial.
+ Also read this article on Optimizing PHP.
(c) 2002 John Lim.
diff --git a/lib/adodb/toexport.inc.php b/lib/adodb/toexport.inc.php
new file mode 100644
index 0000000000..db45fe6c73
--- /dev/null
+++ b/lib/adodb/toexport.inc.php
@@ -0,0 +1,130 @@
+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;
+}
+?>
\ No newline at end of file
diff --git a/lib/adodb/tohtml.inc.php b/lib/adodb/tohtml.inc.php
index 22c4857e8b..a82f19dee7 100644
--- a/lib/adodb/tohtml.inc.php
+++ b/lib/adodb/tohtml.inc.php
@@ -1,6 +1,6 @@
FieldCount();
$hdr = "
\n\n";
-
for ($i=0; $i < $ncols; $i++) {
$field = $rs->FetchField($i);
if ($zheaderarray) $fname = $zheaderarray[$i];
--
2.39.5