forked from extern/egroupware
imported version 4.51 of ADOdb
This commit is contained in:
parent
00d45abcfe
commit
b3d517a98c
@ -7,7 +7,7 @@ global $ADODB_INCLUDED_CSV;
|
|||||||
$ADODB_INCLUDED_CSV = 1;
|
$ADODB_INCLUDED_CSV = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -249,4 +249,56 @@ $ADODB_INCLUDED_CSV = 1;
|
|||||||
$rs->InitArrayFields($arr,$flds);
|
$rs->InitArrayFields($arr,$flds);
|
||||||
return $rs;
|
return $rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save a file $filename and its $contents (normally for caching) with file locking
|
||||||
|
*/
|
||||||
|
function adodb_write_file($filename, $contents,$debug=false)
|
||||||
|
{
|
||||||
|
# http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows
|
||||||
|
# So to simulate locking, we assume that rename is an atomic operation.
|
||||||
|
# First we delete $filename, then we create a $tempfile write to it and
|
||||||
|
# rename to the desired $filename. If the rename works, then we successfully
|
||||||
|
# modified the file exclusively.
|
||||||
|
# What a stupid need - having to simulate locking.
|
||||||
|
# Risks:
|
||||||
|
# 1. $tempfile name is not unique -- very very low
|
||||||
|
# 2. unlink($filename) fails -- ok, rename will fail
|
||||||
|
# 3. adodb reads stale file because unlink fails -- ok, $rs timeout occurs
|
||||||
|
# 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated
|
||||||
|
if (strncmp(PHP_OS,'WIN',3) === 0) {
|
||||||
|
// skip the decimal place
|
||||||
|
$mtime = substr(str_replace(' ','_',microtime()),2);
|
||||||
|
// getmypid() actually returns 0 on Win98 - never mind!
|
||||||
|
$tmpname = $filename.uniqid($mtime).getmypid();
|
||||||
|
if (!($fd = fopen($tmpname,'a'))) return false;
|
||||||
|
$ok = ftruncate($fd,0);
|
||||||
|
if (!fwrite($fd,$contents)) $ok = false;
|
||||||
|
fclose($fd);
|
||||||
|
chmod($tmpname,0644);
|
||||||
|
// the tricky moment
|
||||||
|
@unlink($filename);
|
||||||
|
if (!@rename($tmpname,$filename)) {
|
||||||
|
unlink($tmpname);
|
||||||
|
$ok = false;
|
||||||
|
}
|
||||||
|
if (!$ok) {
|
||||||
|
if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed'));
|
||||||
|
}
|
||||||
|
return $ok;
|
||||||
|
}
|
||||||
|
if (!($fd = fopen($filename, 'a'))) return false;
|
||||||
|
if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) {
|
||||||
|
$ok = fwrite( $fd, $contents );
|
||||||
|
fclose($fd);
|
||||||
|
chmod($filename,0644);
|
||||||
|
}else {
|
||||||
|
fclose($fd);
|
||||||
|
if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename<br>\n");
|
||||||
|
$ok = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ok;
|
||||||
|
}
|
||||||
?>
|
?>
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @version V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
* @version V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @version V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
* @version V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -58,14 +58,7 @@
|
|||||||
{
|
{
|
||||||
return call_user_func_array(array($this->rs, $func), $params);
|
return call_user_func_array(array($this->rs, $func), $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
function __toString()
|
|
||||||
{
|
|
||||||
if (isset($rs->databaseType)) $s = ' for '.$rs->databaseType;
|
|
||||||
else $s = '';
|
|
||||||
|
|
||||||
return 'ADODB Iterator'.$s;
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasMore()
|
function hasMore()
|
||||||
{
|
{
|
||||||
@ -79,6 +72,12 @@ class ADODB_BASE_RS implements IteratorAggregate {
|
|||||||
function getIterator() {
|
function getIterator() {
|
||||||
return new ADODB_Iterator($this);
|
return new ADODB_Iterator($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function __toString()
|
||||||
|
{
|
||||||
|
include_once(ADODB_DIR.'/toexport.inc.php');
|
||||||
|
return _adodb_export($this,',',',',false,true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@ -63,7 +63,7 @@ function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_
|
|||||||
if ($uSet && $where) {
|
if ($uSet && $where) {
|
||||||
$update = "UPDATE $table SET $uSet WHERE $where";
|
$update = "UPDATE $table SET $uSet WHERE $where";
|
||||||
|
|
||||||
$rs = $zthis->Execute($update);
|
$rs = $zthis->_Execute($update);
|
||||||
if ($rs) {
|
if ($rs) {
|
||||||
if ($zthis->poorAffectedRows) {
|
if ($zthis->poorAffectedRows) {
|
||||||
/*
|
/*
|
||||||
@ -77,8 +77,10 @@ function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_
|
|||||||
|
|
||||||
$cnt = $zthis->GetOne("select count(*) from $table where $where");
|
$cnt = $zthis->GetOne("select count(*) from $table where $where");
|
||||||
if ($cnt > 0) return 1; // record already exists
|
if ($cnt > 0) return 1; // record already exists
|
||||||
} else
|
} else {
|
||||||
if (($zthis->Affected_Rows()>0)) return 1;
|
|
||||||
|
if (($zthis->Affected_Rows()>0)) return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// print "<p>Error=".$this->ErrorNo().'<p>';
|
// print "<p>Error=".$this->ErrorNo().'<p>';
|
||||||
@ -96,7 +98,7 @@ function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$insert = "INSERT INTO $table ($iCols) VALUES ($iVals)";
|
$insert = "INSERT INTO $table ($iCols) VALUES ($iVals)";
|
||||||
$rs = $zthis->Execute($insert);
|
$rs = $zthis->_Execute($insert);
|
||||||
return ($rs) ? 2 : 0;
|
return ($rs) ? 2 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +218,7 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
|
|||||||
if (preg_match('/\s*UNION\s*/is', $sql)) $rewritesql = $sql;
|
if (preg_match('/\s*UNION\s*/is', $sql)) $rewritesql = $sql;
|
||||||
else $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql);
|
else $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql);
|
||||||
|
|
||||||
$rstest = &$zthis->Execute($rewritesql,$inputarr);
|
$rstest = &$zthis->_Execute($rewritesql,$inputarr);
|
||||||
if ($rstest) {
|
if ($rstest) {
|
||||||
$qryRecs = $rstest->RecordCount();
|
$qryRecs = $rstest->RecordCount();
|
||||||
if ($qryRecs == -1) {
|
if ($qryRecs == -1) {
|
||||||
@ -266,11 +268,7 @@ function &_adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page,
|
|||||||
$lastpageno = (int) ceil($qryRecs / $nrows);
|
$lastpageno = (int) ceil($qryRecs / $nrows);
|
||||||
$zthis->_maxRecordCount = $qryRecs;
|
$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
|
// ***** Here we check whether $page is the last page or
|
||||||
// whether we are trying to retrieve
|
// whether we are trying to retrieve
|
||||||
@ -280,6 +278,12 @@ function &_adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page,
|
|||||||
$atlastpage = true;
|
$atlastpage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If page number <= 1, then we are at the first page
|
||||||
|
if (empty($page) || $page <= 1) {
|
||||||
|
$page = 1;
|
||||||
|
$atfirstpage = true;
|
||||||
|
}
|
||||||
|
|
||||||
// We get the data we want
|
// We get the data we want
|
||||||
$offset = $nrows * ($page-1);
|
$offset = $nrows * ($page-1);
|
||||||
if ($secs2cache > 0)
|
if ($secs2cache > 0)
|
||||||
@ -372,7 +376,7 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq
|
|||||||
// If the recordset field is one
|
// If the recordset field is one
|
||||||
// of the fields passed in then process.
|
// of the fields passed in then process.
|
||||||
$upperfname = strtoupper($field->name);
|
$upperfname = strtoupper($field->name);
|
||||||
if (adodb_key_exists($upperfname,$arrFields)) {
|
if (adodb_key_exists($upperfname,$arrFields,$forcenulls)) {
|
||||||
|
|
||||||
// If the existing field value in the recordset
|
// If the existing field value in the recordset
|
||||||
// is different from the value passed in then
|
// is different from the value passed in then
|
||||||
@ -392,31 +396,32 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq
|
|||||||
|
|
||||||
// Based on the datatype of the field
|
// Based on the datatype of the field
|
||||||
// Format the value properly for the database
|
// Format the value properly for the database
|
||||||
$type = $rs->MetaType($field->type);
|
$type = $rs->MetaType($field->type);
|
||||||
|
|
||||||
// is_null requires php 4.0.4
|
// is_null requires php 4.0.4
|
||||||
if (($forcenulls && is_null($arrFields[$upperfname])) ||
|
if (($forcenulls && is_null($arrFields[$upperfname])) ||
|
||||||
$arrFields[$upperfname] === 'null') {
|
$arrFields[$upperfname] === 'null') {
|
||||||
$setFields .= $field->name . " = null, ";
|
$setFields .= $field->name . " = null, ";
|
||||||
} else {
|
} else {
|
||||||
if ($type == 'null') {
|
if ($type == 'null') {
|
||||||
$type = 'C';
|
$type = 'C';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($upperfname,' ') !== false)
|
||||||
|
$fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;
|
||||||
|
else
|
||||||
|
$fnameq = $upperfname;
|
||||||
|
|
||||||
|
//we do this so each driver can customize the sql for
|
||||||
|
//DB specific column types.
|
||||||
|
//Oracle needs BLOB types to be handled with a returning clause
|
||||||
|
//postgres has special needs as well
|
||||||
|
$setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,
|
||||||
|
$arrFields, $magicq);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($upperfname,' ') !== false)
|
|
||||||
$fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;
|
|
||||||
else
|
|
||||||
$fnameq = $upperfname;
|
|
||||||
//we do this so each driver can customize the sql for
|
|
||||||
//DB specific column types.
|
|
||||||
//Oracle needs BLOB types to be handled with a returning clause
|
|
||||||
//postgres has special needs as well
|
|
||||||
$setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,
|
|
||||||
$arrFields, $magicq);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If there were any modified fields then build the rest of the update query.
|
// If there were any modified fields then build the rest of the update query.
|
||||||
if ($fieldUpdatedCount > 0 || $forceUpdate) {
|
if ($fieldUpdatedCount > 0 || $forceUpdate) {
|
||||||
@ -429,9 +434,10 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq
|
|||||||
|
|
||||||
$discard = false;
|
$discard = false;
|
||||||
// not a good hack, improvements?
|
// not a good hack, improvements?
|
||||||
if ($whereClause)
|
if ($whereClause) {
|
||||||
preg_match('/\s(LIMIT\s.*)/is', $whereClause[1], $discard);
|
if (preg_match('/\s(ORDER\s.*)/is', $whereClause[1], $discard));
|
||||||
else
|
else preg_match('/\s(LIMIT\s.*)/is', $whereClause[1], $discard);
|
||||||
|
} else
|
||||||
$whereClause = array(false,false);
|
$whereClause = array(false,false);
|
||||||
|
|
||||||
if ($discard)
|
if ($discard)
|
||||||
@ -503,7 +509,7 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$forcenulls=f
|
|||||||
// Loop through all of the fields in the recordset
|
// Loop through all of the fields in the recordset
|
||||||
foreach( $columns as $field ) {
|
foreach( $columns as $field ) {
|
||||||
$upperfname = strtoupper($field->name);
|
$upperfname = strtoupper($field->name);
|
||||||
if (adodb_key_exists($upperfname,$arrFields)) {
|
if (adodb_key_exists($upperfname,$arrFields,$forcenulls)) {
|
||||||
|
|
||||||
// Set the counter for the number of fields that will be inserted.
|
// Set the counter for the number of fields that will be inserted.
|
||||||
$fieldInsertedCount++;
|
$fieldInsertedCount++;
|
||||||
@ -539,8 +545,10 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$forcenulls=f
|
|||||||
|
|
||||||
// Get the table name from the existing query.
|
// Get the table name from the existing query.
|
||||||
if (!$tableName) {
|
if (!$tableName) {
|
||||||
preg_match("/FROM\s+".ADODB_TABLE_REGEX."/is", $rs->sql, $tableName);
|
if (preg_match("/FROM\s+".ADODB_TABLE_REGEX."/is", $rs->sql, $tableName))
|
||||||
$tableName = $tableName[1];
|
$tableName = $tableName[1];
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip off the comma and space on the end of both the fields
|
// Strip off the comma and space on the end of both the fields
|
||||||
@ -693,4 +701,105 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $fnameq, $arrFields,
|
|||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function _adodb_debug_execute(&$zthis, $sql, $inputarr)
|
||||||
|
{
|
||||||
|
global $HTTP_SERVER_VARS;
|
||||||
|
|
||||||
|
$ss = '';
|
||||||
|
if ($inputarr) {
|
||||||
|
foreach($inputarr as $kk=>$vv) {
|
||||||
|
if (is_string($vv) && strlen($vv)>64) $vv = substr($vv,0,64).'...';
|
||||||
|
$ss .= "($kk=>'$vv') ";
|
||||||
|
}
|
||||||
|
$ss = "[ $ss ]";
|
||||||
|
}
|
||||||
|
$sqlTxt = str_replace(',',', ',is_array($sql) ? $sql[0] : $sql);
|
||||||
|
|
||||||
|
// check if running from browser or command-line
|
||||||
|
$inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']);
|
||||||
|
|
||||||
|
if ($inBrowser) {
|
||||||
|
$ss = htmlspecialchars($ss);
|
||||||
|
if ($zthis->debug === -1)
|
||||||
|
ADOConnection::outp( "<br>\n($zthis->databaseType): ".htmlspecialchars($sqlTxt)." <code>$ss</code>\n<br>\n",false);
|
||||||
|
else
|
||||||
|
ADOConnection::outp( "<hr>\n($zthis->databaseType): ".htmlspecialchars($sqlTxt)." <code>$ss</code>\n<hr>\n",false);
|
||||||
|
} else {
|
||||||
|
ADOConnection::outp("-----\n($zthis->databaseType): ".$sqlTxt."\n-----\n",false);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qID = $zthis->_query($sql,$inputarr);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql
|
||||||
|
because ErrorNo() calls Execute('SELECT @ERROR'), causing recursion
|
||||||
|
*/
|
||||||
|
if ($zthis->databaseType == 'mssql') {
|
||||||
|
// ErrorNo is a slow function call in mssql, and not reliable in PHP 4.0.6
|
||||||
|
if($emsg = $zthis->ErrorMsg()) {
|
||||||
|
if ($err = $zthis->ErrorNo()) ADOConnection::outp($err.': '.$emsg);
|
||||||
|
}
|
||||||
|
} else if (!$qID) {
|
||||||
|
ADOConnection::outp($zthis->ErrorNo() .': '. $zthis->ErrorMsg());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $qID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _adodb_backtrace($printOrArr=true,$levels=9999)
|
||||||
|
{
|
||||||
|
if (PHPVERSION() < 4.3) return '';
|
||||||
|
|
||||||
|
$html = (isset($_SERVER['HTTP_USER_AGENT']));
|
||||||
|
$fmt = ($html) ? "</font><font color=#808080 size=-1> %% line %4d, file: <a href=\"file:/%s\">%s</a></font>" : "%% line %4d, file: %s";
|
||||||
|
|
||||||
|
$MAXSTRLEN = 64;
|
||||||
|
|
||||||
|
$s = ($html) ? '<pre align=left>' : '';
|
||||||
|
|
||||||
|
if (is_array($printOrArr)) $traceArr = $printOrArr;
|
||||||
|
else $traceArr = debug_backtrace();
|
||||||
|
array_shift($traceArr);
|
||||||
|
array_shift($traceArr);
|
||||||
|
$tabs = sizeof($traceArr)-2;
|
||||||
|
|
||||||
|
foreach ($traceArr as $arr) {
|
||||||
|
$levels -= 1;
|
||||||
|
if ($levels < 0) break;
|
||||||
|
|
||||||
|
$args = array();
|
||||||
|
for ($i=0; $i < $tabs; $i++) $s .= ($html) ? ' ' : "\t";
|
||||||
|
$tabs -= 1;
|
||||||
|
if ($html) $s .= '<font face="Courier New,Courier">';
|
||||||
|
if (isset($arr['class'])) $s .= $arr['class'].'.';
|
||||||
|
if (isset($arr['args']))
|
||||||
|
foreach($arr['args'] as $v) {
|
||||||
|
if (is_null($v)) $args[] = 'null';
|
||||||
|
else if (is_array($v)) $args[] = 'Array['.sizeof($v).']';
|
||||||
|
else if (is_object($v)) $args[] = 'Object:'.get_class($v);
|
||||||
|
else if (is_bool($v)) $args[] = $v ? 'true' : 'false';
|
||||||
|
else {
|
||||||
|
$v = (string) @$v;
|
||||||
|
$str = htmlspecialchars(substr($v,0,$MAXSTRLEN));
|
||||||
|
if (strlen($v) > $MAXSTRLEN) $str .= '...';
|
||||||
|
$args[] = $str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$s .= $arr['function'].'('.implode(', ',$args).')';
|
||||||
|
|
||||||
|
|
||||||
|
$s .= @sprintf($fmt, $arr['line'],$arr['file'],basename($arr['file']));
|
||||||
|
|
||||||
|
$s .= "\n";
|
||||||
|
}
|
||||||
|
if ($html) $s .= '</pre>';
|
||||||
|
if ($printOrArr) print $s;
|
||||||
|
|
||||||
|
return $s;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -230,6 +230,7 @@ class ADODB_Pager {
|
|||||||
if (!$this->db->pageExecuteCountRows) return '';
|
if (!$this->db->pageExecuteCountRows) return '';
|
||||||
$lastPage = $this->rs->LastPageNo();
|
$lastPage = $this->rs->LastPageNo();
|
||||||
if ($lastPage == -1) $lastPage = 1; // check for empty rs.
|
if ($lastPage == -1) $lastPage = 1; // check for empty rs.
|
||||||
|
if ($this->curr_page > $lastPage) $this->curr_page = 1;
|
||||||
return "<font size=-1>$this->page ".$this->curr_page."/".$lastPage."</font>";
|
return "<font size=-1>$this->page ".$this->curr_page."/".$lastPage."</font>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -622,7 +622,7 @@ Committed_AS: 348732 kB
|
|||||||
|
|
||||||
if (empty($HTTP_GET_VARS['hidem']))
|
if (empty($HTTP_GET_VARS['hidem']))
|
||||||
echo "<table border=1 width=100% bgcolor=lightyellow><tr><td colspan=2>
|
echo "<table border=1 width=100% bgcolor=lightyellow><tr><td colspan=2>
|
||||||
<b><a href=http://php.weblogs.com/adodb?perf=1>ADOdb</a> Performance Monitor</b> <font size=1>for $app</font></tr><tr><td>
|
<b><a href=http://adodb.sourceforge.net/?perf=1>ADOdb</a> Performance Monitor</b> <font size=1>for $app</font></tr><tr><td>
|
||||||
<a href=?do=stats><b>Performance Stats</b></a> <a href=?do=viewsql><b>View SQL</b></a>
|
<a href=?do=stats><b>Performance Stats</b></a> <a href=?do=viewsql><b>View SQL</b></a>
|
||||||
<a href=?do=tables><b>View Tables</b></a> <a href=?do=poll><b>Poll Stats</b></a>",
|
<a href=?do=tables><b>View Tables</b></a> <a href=?do=poll><b>Poll Stats</b></a>",
|
||||||
$allowsql ? ' <a href=?do=dosql><b>Run SQL</b></a>' : '',
|
$allowsql ? ' <a href=?do=dosql><b>Run SQL</b></a>' : '',
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -141,13 +141,13 @@ current timestamp is used. Unlike the function date(), it supports dates
|
|||||||
outside the 1901 to 2038 range.
|
outside the 1901 to 2038 range.
|
||||||
|
|
||||||
|
|
||||||
FUNCTION adodb_mktime($hr, $min, $sec, $month, $day, $year)
|
FUNCTION adodb_mktime($hr, $min, $sec [, $month, $day, $year])
|
||||||
|
|
||||||
Converts a local date to a unix timestamp. Unlike the function mktime(), it supports
|
Converts a local date to a unix timestamp. Unlike the function mktime(), it supports
|
||||||
dates outside the 1901 to 2038 range. Differs from mktime() in that all parameters
|
dates outside the 1901 to 2038 range. Differs from mktime() in that all parameters
|
||||||
are currently compulsory.
|
are currently compulsory.
|
||||||
|
|
||||||
FUNCTION adodb_gmmktime($hr, $min, $sec, $month, $day, $year)
|
FUNCTION adodb_gmmktime($hr, $min, $sec [, $month, $day, $year])
|
||||||
|
|
||||||
Converts a gmt date to a unix timestamp. Unlike the function gmmktime(), it supports
|
Converts a gmt date to a unix timestamp. Unlike the function gmmktime(), it supports
|
||||||
dates outside the 1901 to 2038 range. Differs from gmmktime() in that all parameters
|
dates outside the 1901 to 2038 range. Differs from gmmktime() in that all parameters
|
||||||
@ -174,6 +174,10 @@ c. Implement daylight savings, which looks awfully complicated, see
|
|||||||
|
|
||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
- 18 July 2004 0.15
|
||||||
|
All params in adodb_mktime were formerly compulsory. Now only the hour, min, secs is compulsory. This
|
||||||
|
brings it more in line with mktime (still not identical).
|
||||||
|
|
||||||
- 23 June 2004 0.14
|
- 23 June 2004 0.14
|
||||||
|
|
||||||
Allow you to define your own daylights savings function, adodb_daylight_sv.
|
Allow you to define your own daylights savings function, adodb_daylight_sv.
|
||||||
@ -271,7 +275,7 @@ First implementation.
|
|||||||
/*
|
/*
|
||||||
Version Number
|
Version Number
|
||||||
*/
|
*/
|
||||||
define('ADODB_DATE_VERSION',0.14);
|
define('ADODB_DATE_VERSION',0.15);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
We check for Windows as only +ve ints are accepted as dates on Windows.
|
We check for Windows as only +ve ints are accepted as dates on Windows.
|
||||||
@ -313,6 +317,9 @@ function adodb_date_test()
|
|||||||
// This flag disables calling of PHP native functions, so we can properly test the code
|
// This flag disables calling of PHP native functions, so we can properly test the code
|
||||||
if (!defined('ADODB_TEST_DATES')) define('ADODB_TEST_DATES',1);
|
if (!defined('ADODB_TEST_DATES')) define('ADODB_TEST_DATES',1);
|
||||||
|
|
||||||
|
$t = adodb_mktime(0,0,0);
|
||||||
|
if (!(adodb_date('Y-m-d') == date('Y-m-d'))) print 'Error in '.adodb_mktime(0,0,0).'<br>';
|
||||||
|
|
||||||
$t = adodb_mktime(0,0,0,6,1,2102);
|
$t = adodb_mktime(0,0,0,6,1,2102);
|
||||||
if (!(adodb_date('Y-m-d',$t) == '2102-06-01')) print 'Error in '.adodb_date('Y-m-d',$t).'<br>';
|
if (!(adodb_date('Y-m-d',$t) == '2102-06-01')) print 'Error in '.adodb_date('Y-m-d',$t).'<br>';
|
||||||
|
|
||||||
@ -428,7 +435,7 @@ function adodb_date_test()
|
|||||||
// we generate a timestamp, convert it to a date, and convert it back to a timestamp
|
// we generate a timestamp, convert it to a date, and convert it back to a timestamp
|
||||||
// and check if the roundtrip broke the original timestamp value.
|
// and check if the roundtrip broke the original timestamp value.
|
||||||
print "Testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: ";
|
print "Testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: ";
|
||||||
|
$cnt = 0;
|
||||||
for ($max += $i; $i < $max; $i += $offset) {
|
for ($max += $i; $i < $max; $i += $offset) {
|
||||||
$ret = adodb_date('m,d,Y,H,i,s',$i);
|
$ret = adodb_date('m,d,Y,H,i,s',$i);
|
||||||
$arr = explode(',',$ret);
|
$arr = explode(',',$ret);
|
||||||
@ -443,8 +450,9 @@ function adodb_date_test()
|
|||||||
$fail = true;
|
$fail = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
$cnt += 1;
|
||||||
}
|
}
|
||||||
|
echo "Tested $cnt dates<br>";
|
||||||
if (!$fail) print "<p>Passed !</p>";
|
if (!$fail) print "<p>Passed !</p>";
|
||||||
else print "<p><b>Failed</b> :-(</p>";
|
else print "<p><b>Failed</b> :-(</p>";
|
||||||
}
|
}
|
||||||
@ -717,6 +725,8 @@ function adodb_date2($fmt, $d=false, $is_gmt=false)
|
|||||||
*/
|
*/
|
||||||
function adodb_date($fmt,$d=false,$is_gmt=false)
|
function adodb_date($fmt,$d=false,$is_gmt=false)
|
||||||
{
|
{
|
||||||
|
static $daylight;
|
||||||
|
|
||||||
if ($d === false) return ($is_gmt)? @gmdate($fmt): @date($fmt);
|
if ($d === false) return ($is_gmt)? @gmdate($fmt): @date($fmt);
|
||||||
if (!defined('ADODB_TEST_DATES')) {
|
if (!defined('ADODB_TEST_DATES')) {
|
||||||
if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
|
if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
|
||||||
@ -728,7 +738,8 @@ function adodb_date($fmt,$d=false,$is_gmt=false)
|
|||||||
$_day_power = 86400;
|
$_day_power = 86400;
|
||||||
|
|
||||||
$arr = _adodb_getdate($d,true,$is_gmt);
|
$arr = _adodb_getdate($d,true,$is_gmt);
|
||||||
if (function_exists('adodb_daylight_sv')) adodb_daylight_sv($arr, $is_gmt);
|
if (!isset($daylight)) $daylight = function_exists('adodb_daylight_sv');
|
||||||
|
if ($daylight) adodb_daylight_sv($arr, $is_gmt);
|
||||||
|
|
||||||
$year = $arr['year'];
|
$year = $arr['year'];
|
||||||
$month = $arr['mon'];
|
$month = $arr['mon'];
|
||||||
@ -852,7 +863,7 @@ function adodb_date($fmt,$d=false,$is_gmt=false)
|
|||||||
Returns a timestamp given a GMT/UTC time.
|
Returns a timestamp given a GMT/UTC time.
|
||||||
Note that $is_dst is not implemented and is ignored.
|
Note that $is_dst is not implemented and is ignored.
|
||||||
*/
|
*/
|
||||||
function adodb_gmmktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false)
|
function adodb_gmmktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false)
|
||||||
{
|
{
|
||||||
return adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst,true);
|
return adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst,true);
|
||||||
}
|
}
|
||||||
@ -863,13 +874,15 @@ function adodb_gmmktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false)
|
|||||||
|
|
||||||
Not a very fast algorithm - O(n) operation. Could be optimized to O(1).
|
Not a very fast algorithm - O(n) operation. Could be optimized to O(1).
|
||||||
*/
|
*/
|
||||||
function adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false,$is_gmt=false)
|
function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false,$is_gmt=false)
|
||||||
{
|
{
|
||||||
if (!defined('ADODB_TEST_DATES')) {
|
if (!defined('ADODB_TEST_DATES')) {
|
||||||
// for windows, we don't check 1970 because with timezone differences,
|
// for windows, we don't check 1970 because with timezone differences,
|
||||||
// 1 Jan 1970 could generate negative timestamp, which is illegal
|
// 1 Jan 1970 could generate negative timestamp, which is illegal
|
||||||
if (!defined('ADODB_NO_NEGATIVE_TS') || ($year >= 1971))
|
if (1971 < $year && $year < 2038
|
||||||
if (1901 < $year && $year < 2038)
|
|| $mon === false
|
||||||
|
|| !defined('ADODB_NO_NEGATIVE_TS') && (1901 < $year && $year < 2038)
|
||||||
|
)
|
||||||
return $is_gmt?
|
return $is_gmt?
|
||||||
@gmmktime($hr,$min,$sec,$mon,$day,$year):
|
@gmmktime($hr,$min,$sec,$mon,$day,$year):
|
||||||
@mktime($hr,$min,$sec,$mon,$day,$year);
|
@mktime($hr,$min,$sec,$mon,$day,$year);
|
||||||
|
@ -4,31 +4,6 @@
|
|||||||
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.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
Redistributions of source code must retain the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer.
|
|
||||||
Redistributions in binary form must reproduce the above copyright notice, this l
|
|
||||||
ist of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
materials provided with the distribution.
|
|
||||||
Neither the name of the ars Cognita, Inc., nor the names of its contributors may be used
|
|
||||||
to endorse or promote products derived from this software without specific prior
|
|
||||||
written permission.
|
|
||||||
|
|
||||||
DISCLAIMER:
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WA
|
|
||||||
RRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIREC
|
|
||||||
T, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR P
|
|
||||||
ROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWI
|
|
||||||
SE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE P
|
|
||||||
OSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/**
|
/**
|
||||||
* xmlschema is a class that allows the user to quickly and easily
|
* xmlschema is a class that allows the user to quickly and easily
|
||||||
@ -104,6 +79,7 @@ if( !defined( 'XMLS_DEFAULT_UPGRADE_METHOD' ) ) {
|
|||||||
*/
|
*/
|
||||||
if( !defined( '_ADODB_LAYER' ) ) {
|
if( !defined( '_ADODB_LAYER' ) ) {
|
||||||
require( 'adodb.inc.php' );
|
require( 'adodb.inc.php' );
|
||||||
|
require( 'adodb-datadict.inc.php' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -274,7 +250,14 @@ class dbTable extends dbObject {
|
|||||||
|
|
||||||
switch( $this->currentElement ) {
|
switch( $this->currentElement ) {
|
||||||
case 'INDEX':
|
case 'INDEX':
|
||||||
xml_set_object( $parser, $this->addIndex( $attributes ) );
|
if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
|
||||||
|
xml_set_object( $parser, $this->addIndex( $attributes ) );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'DATA':
|
||||||
|
if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
|
||||||
|
xml_set_object( $parser, $this->addData( $attributes ) );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'DROP':
|
case 'DROP':
|
||||||
$this->drop();
|
$this->drop();
|
||||||
@ -288,7 +271,7 @@ class dbTable extends dbObject {
|
|||||||
|
|
||||||
$this->addField( $fieldName, $fieldType, $fieldSize, $fieldOpts );
|
$this->addField( $fieldName, $fieldType, $fieldSize, $fieldOpts );
|
||||||
break;
|
break;
|
||||||
case 'KEY':
|
case 'KEY':
|
||||||
case 'NOTNULL':
|
case 'NOTNULL':
|
||||||
case 'AUTOINCREMENT':
|
case 'AUTOINCREMENT':
|
||||||
// Add a field option
|
// Add a field option
|
||||||
@ -304,6 +287,11 @@ class dbTable extends dbObject {
|
|||||||
|
|
||||||
$this->addFieldOpt( $this->current_field, $this->currentElement, $attributes['VALUE'] );
|
$this->addFieldOpt( $this->current_field, $this->currentElement, $attributes['VALUE'] );
|
||||||
break;
|
break;
|
||||||
|
case 'DEFDATE':
|
||||||
|
case 'DEFTIMESTAMP':
|
||||||
|
// Add a field option to the table object
|
||||||
|
$this->addFieldOpt( $this->current_field, $this->currentElement );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// print_r( array( $tag, $attributes ) );
|
// print_r( array( $tag, $attributes ) );
|
||||||
}
|
}
|
||||||
@ -318,6 +306,12 @@ class dbTable extends dbObject {
|
|||||||
switch( $this->currentElement ) {
|
switch( $this->currentElement ) {
|
||||||
// Table constraint
|
// Table constraint
|
||||||
case 'CONSTRAINT':
|
case 'CONSTRAINT':
|
||||||
|
if( isset( $this->current_field ) ) {
|
||||||
|
$this->addFieldOpt( $this->current_field, $this->currentElement, $cdata );
|
||||||
|
} else {
|
||||||
|
$this->addTableOpt( $cdata );
|
||||||
|
}
|
||||||
|
break;
|
||||||
// Table option
|
// Table option
|
||||||
case 'OPT':
|
case 'OPT':
|
||||||
$this->addTableOpt( $cdata );
|
$this->addTableOpt( $cdata );
|
||||||
@ -341,6 +335,10 @@ class dbTable extends dbObject {
|
|||||||
xml_set_object( $parser, $this->parent );
|
xml_set_object( $parser, $this->parent );
|
||||||
$this->destroy();
|
$this->destroy();
|
||||||
break;
|
break;
|
||||||
|
case 'FIELD':
|
||||||
|
unset($this->current_field);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,6 +354,19 @@ class dbTable extends dbObject {
|
|||||||
return $this->indexes[$name];
|
return $this->indexes[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds data to a table object
|
||||||
|
*
|
||||||
|
* @param array $attributes Data attributes
|
||||||
|
* @return object dbData object
|
||||||
|
*/
|
||||||
|
function &addData( $attributes ) {
|
||||||
|
if( !isset( $this->data ) ) {
|
||||||
|
$this->data =& new dbData( $this, $attributes );
|
||||||
|
}
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a field to a table object
|
* Adds a field to a table object
|
||||||
*
|
*
|
||||||
@ -404,7 +415,7 @@ class dbTable extends dbObject {
|
|||||||
|
|
||||||
// Set the field options
|
// Set the field options
|
||||||
if( isset( $opts ) ) {
|
if( isset( $opts ) ) {
|
||||||
$this->fields[$field_id]['OPTS'] = $opts;
|
$this->fields[$field_id]['OPTS'][] = $opts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,7 +522,7 @@ class dbTable extends dbObject {
|
|||||||
if( is_array( $opt ) ) {
|
if( is_array( $opt ) ) {
|
||||||
$key = key( $opt );
|
$key = key( $opt );
|
||||||
$value = $opt[key( $opt )];
|
$value = $opt[key( $opt )];
|
||||||
$fldarray[$field_id][$key] = $value;
|
@$fldarray[$field_id][$key] .= $value;
|
||||||
// Option doesn't have arguments
|
// Option doesn't have arguments
|
||||||
} else {
|
} else {
|
||||||
$fldarray[$field_id][$opt] = $opt;
|
$fldarray[$field_id][$opt] = $opt;
|
||||||
@ -548,6 +559,10 @@ class dbTable extends dbObject {
|
|||||||
$sql[] = $index->create( $xmls );
|
$sql[] = $index->create( $xmls );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( isset( $this->data ) ) {
|
||||||
|
$sql[] = $this->data->create( $xmls );
|
||||||
|
}
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -733,6 +748,192 @@ class dbIndex extends dbObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a data object in ADOdb's datadict format
|
||||||
|
*
|
||||||
|
* This class stores information about table data.
|
||||||
|
*
|
||||||
|
* @package axmls
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
class dbData extends dbObject {
|
||||||
|
|
||||||
|
var $data = array();
|
||||||
|
|
||||||
|
var $row;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the new dbIndex object.
|
||||||
|
*
|
||||||
|
* @param object $parent Parent object
|
||||||
|
* @param array $attributes Attributes
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
function dbData( &$parent, $attributes = NULL ) {
|
||||||
|
$this->parent =& $parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XML Callback to process start elements
|
||||||
|
*
|
||||||
|
* Processes XML opening tags.
|
||||||
|
* Elements currently processed are: DROP, CLUSTERED, BITMAP, UNIQUE, FULLTEXT & HASH.
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _tag_open( &$parser, $tag, $attributes ) {
|
||||||
|
$this->currentElement = strtoupper( $tag );
|
||||||
|
|
||||||
|
switch( $this->currentElement ) {
|
||||||
|
case 'ROW':
|
||||||
|
$this->row = count( $this->data );
|
||||||
|
$this->data[$this->row] = array();
|
||||||
|
break;
|
||||||
|
case 'F':
|
||||||
|
$this->addField($attributes);
|
||||||
|
default:
|
||||||
|
// print_r( array( $tag, $attributes ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XML Callback to process CDATA elements
|
||||||
|
*
|
||||||
|
* Processes XML cdata.
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _tag_cdata( &$parser, $cdata ) {
|
||||||
|
switch( $this->currentElement ) {
|
||||||
|
// Index field name
|
||||||
|
case 'F':
|
||||||
|
$this->addData( $cdata );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XML Callback to process end elements
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _tag_close( &$parser, $tag ) {
|
||||||
|
$this->currentElement = '';
|
||||||
|
|
||||||
|
switch( strtoupper( $tag ) ) {
|
||||||
|
case 'DATA':
|
||||||
|
xml_set_object( $parser, $this->parent );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a field to the index
|
||||||
|
*
|
||||||
|
* @param string $name Field name
|
||||||
|
* @return string Field list
|
||||||
|
*/
|
||||||
|
function addField( $attributes ) {
|
||||||
|
if( isset( $attributes['NAME'] ) ) {
|
||||||
|
$name = $attributes['NAME'];
|
||||||
|
} else {
|
||||||
|
$name = count($this->data[$this->row]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the field index so we know where we are
|
||||||
|
$this->current_field = $this->FieldID( $name );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds options to the index
|
||||||
|
*
|
||||||
|
* @param string $opt Comma-separated list of index options.
|
||||||
|
* @return string Option list
|
||||||
|
*/
|
||||||
|
function addData( $cdata ) {
|
||||||
|
if( !isset( $this->data[$this->row] ) ) {
|
||||||
|
$this->data[$this->row] = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !isset( $this->data[$this->row][$this->current_field] ) ) {
|
||||||
|
$this->data[$this->row][$this->current_field] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->data[$this->row][$this->current_field] .= $cdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates the SQL that will create the index in the database
|
||||||
|
*
|
||||||
|
* @param object $xmls adoSchema object
|
||||||
|
* @return array Array containing index creation SQL
|
||||||
|
*/
|
||||||
|
function create( &$xmls ) {
|
||||||
|
$table = $xmls->dict->TableName($this->parent->name);
|
||||||
|
$table_field_count = count($this->parent->fields);
|
||||||
|
$sql = array();
|
||||||
|
|
||||||
|
// eliminate any columns that aren't in the table
|
||||||
|
foreach( $this->data as $row ) {
|
||||||
|
$table_fields = $this->parent->fields;
|
||||||
|
$fields = array();
|
||||||
|
|
||||||
|
foreach( $row as $field_id => $field_data ) {
|
||||||
|
if( !array_key_exists( $field_id, $table_fields ) ) {
|
||||||
|
if( is_numeric( $field_id ) ) {
|
||||||
|
$field_id = reset( array_keys( $table_fields ) );
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$name = $table_fields[$field_id]['NAME'];
|
||||||
|
|
||||||
|
switch( $table_fields[$field_id]['TYPE'] ) {
|
||||||
|
case 'C':
|
||||||
|
case 'C2':
|
||||||
|
case 'X':
|
||||||
|
case 'X2':
|
||||||
|
$fields[$name] = $xmls->db->qstr( $field_data );
|
||||||
|
break;
|
||||||
|
case 'I':
|
||||||
|
case 'I1':
|
||||||
|
case 'I2':
|
||||||
|
case 'I4':
|
||||||
|
case 'I8':
|
||||||
|
$fields[$name] = intval($field_data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$fields[$name] = $field_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($table_fields[$field_id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check that at least 1 column is specified
|
||||||
|
if( empty( $fields ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check that no required columns are missing
|
||||||
|
if( count( $fields ) < $table_field_count ) {
|
||||||
|
foreach( $table_fields as $field ) {
|
||||||
|
if( ( in_array( 'NOTNULL', $field['OPTS'] ) || in_array( 'KEY', $field['OPTS'] ) ) && !in_array( 'AUTOINCREMENT', $field['OPTS'] ) ) {
|
||||||
|
continue(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql[] = 'INSERT INTO '. $table .' ('. implode( ',', array_keys( $fields ) ) .') VALUES ('. implode( ',', $fields ) .')';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the SQL to execute a list of provided SQL queries
|
* Creates the SQL to execute a list of provided SQL queries
|
||||||
*
|
*
|
||||||
@ -788,8 +989,6 @@ class dbQuerySet extends dbObject {
|
|||||||
case 'NONE':
|
case 'NONE':
|
||||||
$this->prefixMethod = 'NONE';
|
$this->prefixMethod = 'NONE';
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
$this->prefixMethod = 'AUTO';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -884,19 +1083,11 @@ class dbQuerySet extends dbObject {
|
|||||||
* @return string SQL query string.
|
* @return string SQL query string.
|
||||||
*/
|
*/
|
||||||
function buildQuery( $sql = NULL ) {
|
function buildQuery( $sql = NULL ) {
|
||||||
if( !isset( $this->query ) ) {
|
if( !isset( $this->query ) OR empty( $sql ) ) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( empty( $sql ) ) {
|
$this->query .= $sql;
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !empty( $this->query ) ) {
|
|
||||||
$this->query .= ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->query .= trim( $sql );
|
|
||||||
|
|
||||||
return $this->query;
|
return $this->query;
|
||||||
}
|
}
|
||||||
@ -911,8 +1102,7 @@ class dbQuerySet extends dbObject {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->queries[] = $this->query;
|
$this->queries[] = $return = trim($this->query);
|
||||||
$return = $this->query;
|
|
||||||
|
|
||||||
unset( $this->query );
|
unset( $this->query );
|
||||||
|
|
||||||
@ -933,9 +1123,9 @@ class dbQuerySet extends dbObject {
|
|||||||
|
|
||||||
// Process object prefix.
|
// Process object prefix.
|
||||||
// Evaluate SQL statements to prepend prefix to objects
|
// Evaluate SQL statements to prepend prefix to objects
|
||||||
$query = $this->prefixQuery( '/^\s*((?is)INSERT\s+(INTO\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query );
|
$query = $this->prefixQuery( '/^\s*((?is)INSERT\s+(INTO\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
|
||||||
$query = $this->prefixQuery( '/^\s*((?is)UPDATE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query );
|
$query = $this->prefixQuery( '/^\s*((?is)UPDATE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
|
||||||
$query = $this->prefixQuery( '/^\s*((?is)DELETE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query );
|
$query = $this->prefixQuery( '/^\s*((?is)DELETE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
|
||||||
|
|
||||||
// SELECT statements aren't working yet
|
// SELECT statements aren't working yet
|
||||||
#$data = preg_replace( '/(?ias)(^\s*SELECT\s+.*\s+FROM)\s+(\W\s*,?\s*)+((?i)\s+WHERE.*$)/', "\1 $prefix\2 \3", $data );
|
#$data = preg_replace( '/(?ias)(^\s*SELECT\s+.*\s+FROM)\s+(\W\s*,?\s*)+((?i)\s+WHERE.*$)/', "\1 $prefix\2 \3", $data );
|
||||||
@ -1099,8 +1289,8 @@ class adoSchema {
|
|||||||
$this->mgq = get_magic_quotes_runtime();
|
$this->mgq = get_magic_quotes_runtime();
|
||||||
set_magic_quotes_runtime(0);
|
set_magic_quotes_runtime(0);
|
||||||
|
|
||||||
$this->debug = $this->db->debug;
|
|
||||||
$this->db =& $db;
|
$this->db =& $db;
|
||||||
|
$this->debug = $this->db->debug;
|
||||||
$this->dict = NewDataDictionary( $this->db );
|
$this->dict = NewDataDictionary( $this->db );
|
||||||
$this->sqlArray = array();
|
$this->sqlArray = array();
|
||||||
$this->schemaVersion = XMLS_SCHEMA_VERSION;
|
$this->schemaVersion = XMLS_SCHEMA_VERSION;
|
||||||
@ -1204,10 +1394,11 @@ class adoSchema {
|
|||||||
* @see ParseSchemaString()
|
* @see ParseSchemaString()
|
||||||
*
|
*
|
||||||
* @param string $file Name of XML schema file.
|
* @param string $file Name of XML schema file.
|
||||||
|
* @param bool $returnSchema Return schema rather than parsing.
|
||||||
* @return array Array of SQL queries, ready to execute
|
* @return array Array of SQL queries, ready to execute
|
||||||
*/
|
*/
|
||||||
function ParseSchema( $filename ) {
|
function ParseSchema( $filename, $returnSchema = FALSE ) {
|
||||||
return $this->ParseSchemaString( $this->ConvertSchemaFile ( $filename ) );
|
return $this->ParseSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1217,12 +1408,13 @@ class adoSchema {
|
|||||||
* and generate the SQL necessary to create the database described by the schema.
|
* and generate the SQL necessary to create the database described by the schema.
|
||||||
*
|
*
|
||||||
* @param string $file Name of XML schema file.
|
* @param string $file Name of XML schema file.
|
||||||
|
* @param bool $returnSchema Return schema rather than parsing.
|
||||||
* @return array Array of SQL queries, ready to execute.
|
* @return array Array of SQL queries, ready to execute.
|
||||||
*
|
*
|
||||||
* @deprecated Replaced by adoSchema::ParseSchema() and adoSchema::ParseSchemaString()
|
* @deprecated Replaced by adoSchema::ParseSchema() and adoSchema::ParseSchemaString()
|
||||||
* @see ParseSchema(), ParseSchemaString()
|
* @see ParseSchema(), ParseSchemaString()
|
||||||
*/
|
*/
|
||||||
function ParseSchemaFile( $filename ) {
|
function ParseSchemaFile( $filename, $returnSchema = FALSE ) {
|
||||||
// Open the file
|
// Open the file
|
||||||
if( !($fp = fopen( $filename, 'r' )) ) {
|
if( !($fp = fopen( $filename, 'r' )) ) {
|
||||||
// die( 'Unable to open file' );
|
// die( 'Unable to open file' );
|
||||||
@ -1234,6 +1426,13 @@ class adoSchema {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $returnSchema )
|
||||||
|
{
|
||||||
|
return $xmlstring;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->success = 2;
|
||||||
|
|
||||||
$xmlParser = $this->create_parser();
|
$xmlParser = $this->create_parser();
|
||||||
|
|
||||||
// Process the file
|
// Process the file
|
||||||
@ -1260,9 +1459,10 @@ class adoSchema {
|
|||||||
* @see ParseSchema()
|
* @see ParseSchema()
|
||||||
*
|
*
|
||||||
* @param string $xmlstring XML schema string.
|
* @param string $xmlstring XML schema string.
|
||||||
|
* @param bool $returnSchema Return schema rather than parsing.
|
||||||
* @return array Array of SQL queries, ready to execute.
|
* @return array Array of SQL queries, ready to execute.
|
||||||
*/
|
*/
|
||||||
function ParseSchemaString( $xmlstring ) {
|
function ParseSchemaString( $xmlstring, $returnSchema = FALSE ) {
|
||||||
if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
|
if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1272,10 +1472,15 @@ class adoSchema {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$xmlParser = $this->create_parser();
|
if ( $returnSchema )
|
||||||
|
{
|
||||||
|
return $xmlstring;
|
||||||
|
}
|
||||||
|
|
||||||
$this->success = 2;
|
$this->success = 2;
|
||||||
|
|
||||||
|
$xmlParser = $this->create_parser();
|
||||||
|
|
||||||
if( !xml_parse( $xmlParser, $xmlstring, TRUE ) ) {
|
if( !xml_parse( $xmlParser, $xmlstring, TRUE ) ) {
|
||||||
die( sprintf(
|
die( sprintf(
|
||||||
"XML error: %s at line %d",
|
"XML error: %s at line %d",
|
||||||
@ -1285,9 +1490,46 @@ class adoSchema {
|
|||||||
}
|
}
|
||||||
|
|
||||||
xml_parser_free( $xmlParser );
|
xml_parser_free( $xmlParser );
|
||||||
|
|
||||||
return $this->sqlArray;
|
return $this->sqlArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads an XML schema from a file and converts it to uninstallation SQL.
|
||||||
|
*
|
||||||
|
* Call this method to load the specified schema (see the DTD for the proper format) from
|
||||||
|
* the filesystem and generate the SQL necessary to remove the database described.
|
||||||
|
* @see RemoveSchemaString()
|
||||||
|
*
|
||||||
|
* @param string $file Name of XML schema file.
|
||||||
|
* @param bool $returnSchema Return schema rather than parsing.
|
||||||
|
* @return array Array of SQL queries, ready to execute
|
||||||
|
*/
|
||||||
|
function RemoveSchema( $filename, $returnSchema = FALSE ) {
|
||||||
|
return $this->RemoveSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts an XML schema string to uninstallation SQL.
|
||||||
|
*
|
||||||
|
* Call this method to parse a string containing an XML schema (see the DTD for the proper format)
|
||||||
|
* and generate the SQL necessary to uninstall the database described by the schema.
|
||||||
|
* @see RemoveSchema()
|
||||||
|
*
|
||||||
|
* @param string $schema XML schema string.
|
||||||
|
* @param bool $returnSchema Return schema rather than parsing.
|
||||||
|
* @return array Array of SQL queries, ready to execute.
|
||||||
|
*/
|
||||||
|
function RemoveSchemaString( $schema, $returnSchema = FALSE ) {
|
||||||
|
|
||||||
|
// grab current version
|
||||||
|
if( !( $version = $this->SchemaStringVersion( $schema ) ) ) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->ParseSchemaString( $this->TransformSchema( $schema, 'remove-' . $version), $returnSchema );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies the current XML schema to the database (post execution).
|
* Applies the current XML schema to the database (post execution).
|
||||||
*
|
*
|
||||||
@ -1448,38 +1690,12 @@ class adoSchema {
|
|||||||
if( $version == $newVersion ) {
|
if( $version == $newVersion ) {
|
||||||
$result = $schema;
|
$result = $schema;
|
||||||
} else {
|
} else {
|
||||||
// Fail if XSLT extension is not available
|
$result = $this->TransformSchema( $schema, 'convert-' . $version . '-' . $newVersion);
|
||||||
if( ! function_exists( 'xslt_create' ) ) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$xsl_file = dirname( __FILE__ ) . '/xsl/convert-' . $version . '-' . $newVersion . '.xsl';
|
|
||||||
|
|
||||||
// look for xsl
|
|
||||||
if( !is_readable( $xsl_file ) ) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$arguments = array (
|
|
||||||
'/_xml' => $schema,
|
|
||||||
'/_xsl' => file_get_contents ($xsl_file)
|
|
||||||
);
|
|
||||||
|
|
||||||
// create an XSLT processor
|
|
||||||
$xh = xslt_create ();
|
|
||||||
|
|
||||||
// set error handler
|
|
||||||
xslt_set_error_handler ($xh, array (&$this, 'xslt_error_handler'));
|
|
||||||
|
|
||||||
// process the schema
|
|
||||||
$result = xslt_process ($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
|
|
||||||
|
|
||||||
xslt_free ($xh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( is_string ($newFile) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
|
if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
|
||||||
fwrite ($fp, $result);
|
fwrite( $fp, $result );
|
||||||
fclose ($fp);
|
fclose( $fp );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@ -1520,43 +1736,66 @@ class adoSchema {
|
|||||||
$result = substr( $result, 3 );
|
$result = substr( $result, 3 );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Fail if XSLT extension is not available
|
$result = $this->TransformSchema( $filename, 'convert-' . $version . '-' . $newVersion, 'file' );
|
||||||
if( ! function_exists( 'xslt_create' ) ) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$xsl_file = dirname( __FILE__ ) . '/xsl/convert-' . $version . '-' . $newVersion . '.xsl';
|
|
||||||
|
|
||||||
// look for xsl
|
|
||||||
if( !is_readable( $xsl_file ) ) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$arguments = array (
|
|
||||||
'/_xml' => file_get_contents ($filename),
|
|
||||||
'/_xsl' => file_get_contents ($xsl_file)
|
|
||||||
);
|
|
||||||
|
|
||||||
// create an XSLT processor
|
|
||||||
$xh = xslt_create ();
|
|
||||||
|
|
||||||
// set error handler
|
|
||||||
xslt_set_error_handler ($xh, array (&$this, 'xslt_error_handler'));
|
|
||||||
|
|
||||||
// process the schema
|
|
||||||
$result = xslt_process ($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
|
|
||||||
|
|
||||||
xslt_free ($xh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( is_string ($newFile) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
|
if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
|
||||||
fwrite ($fp, $result);
|
fwrite( $fp, $result );
|
||||||
fclose ($fp);
|
fclose( $fp );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function TransformSchema( $schema, $xsl, $schematype='string' )
|
||||||
|
{
|
||||||
|
// Fail if XSLT extension is not available
|
||||||
|
if( ! function_exists( 'xslt_create' ) ) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$xsl_file = dirname( __FILE__ ) . '/xsl/' . $xsl . '.xsl';
|
||||||
|
|
||||||
|
// look for xsl
|
||||||
|
if( !is_readable( $xsl_file ) ) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch( $schematype )
|
||||||
|
{
|
||||||
|
case 'file':
|
||||||
|
if( !is_readable( $schema ) ) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$schema = file_get_contents( $schema );
|
||||||
|
break;
|
||||||
|
case 'string':
|
||||||
|
default:
|
||||||
|
if( !is_string( $schema ) ) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$arguments = array (
|
||||||
|
'/_xml' => $schema,
|
||||||
|
'/_xsl' => file_get_contents( $xsl_file )
|
||||||
|
);
|
||||||
|
|
||||||
|
// create an XSLT processor
|
||||||
|
$xh = xslt_create ();
|
||||||
|
|
||||||
|
// set error handler
|
||||||
|
xslt_set_error_handler ($xh, array (&$this, 'xslt_error_handler'));
|
||||||
|
|
||||||
|
// process the schema
|
||||||
|
$result = xslt_process ($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
|
||||||
|
|
||||||
|
xslt_free ($xh);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes XSLT transformation errors
|
* Processes XSLT transformation errors
|
||||||
*
|
*
|
||||||
@ -1692,7 +1931,7 @@ class adoSchema {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( $details->primary_key ) {
|
if( $details->primary_key ) {
|
||||||
$content[] = '<PRIMARY/>';
|
$content[] = '<KEY/>';
|
||||||
} elseif( $details->not_null ) {
|
} elseif( $details->not_null ) {
|
||||||
$content[] = '<NOTNULL/>';
|
$content[] = '<NOTNULL/>';
|
||||||
}
|
}
|
||||||
@ -1743,6 +1982,10 @@ class adoSchema {
|
|||||||
$schema .= ' <data>' . "\n";
|
$schema .= ' <data>' . "\n";
|
||||||
|
|
||||||
while( $row = $rs->FetchRow() ) {
|
while( $row = $rs->FetchRow() ) {
|
||||||
|
foreach( $row as $key => $val ) {
|
||||||
|
$row[$key] = htmlentities($row);
|
||||||
|
}
|
||||||
|
|
||||||
$schema .= ' <row><f>' . implode( '</f><f>', $row ) . '</f></row>' . "\n";
|
$schema .= ' <row><f>' . implode( '</f><f>', $row ) . '</f></row>' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1780,7 +2023,7 @@ class adoSchema {
|
|||||||
// prefix too long
|
// prefix too long
|
||||||
case strlen( $prefix ) > XMLS_PREFIX_MAXLEN:
|
case strlen( $prefix ) > XMLS_PREFIX_MAXLEN:
|
||||||
// prefix contains invalid characters
|
// prefix contains invalid characters
|
||||||
case !preg_match( '/^[a-z][a-z0-9]+$/i', $prefix ):
|
case !preg_match( '/^[a-z][a-z0-9_]+$/i', $prefix ):
|
||||||
logMsg( 'Invalid prefix: ' . $prefix );
|
logMsg( 'Invalid prefix: ' . $prefix );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1931,8 +2174,8 @@ class adoSchema {
|
|||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function logMsg( $msg, $title = NULL ) {
|
function logMsg( $msg, $title = NULL, $force = FALSE ) {
|
||||||
if( XMLS_DEBUG ) {
|
if( XMLS_DEBUG or $force ) {
|
||||||
echo '<pre>';
|
echo '<pre>';
|
||||||
|
|
||||||
if( isset( $title ) ) {
|
if( isset( $title ) ) {
|
||||||
|
@ -224,7 +224,7 @@
|
|||||||
var $substr = 'substr'; /// substring operator
|
var $substr = 'substr'; /// substring operator
|
||||||
var $length = 'length'; /// string length operator
|
var $length = 'length'; /// string length operator
|
||||||
var $random = 'rand()'; /// random function
|
var $random = 'rand()'; /// random function
|
||||||
var $upperCase = false; /// uppercase function
|
var $upperCase = 'upper'; /// uppercase function
|
||||||
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.
|
||||||
var $true = '1'; /// string that represents TRUE for a database
|
var $true = '1'; /// string that represents TRUE for a database
|
||||||
@ -348,15 +348,17 @@
|
|||||||
|
|
||||||
if ($newline) $msg .= "<br>\n";
|
if ($newline) $msg .= "<br>\n";
|
||||||
|
|
||||||
if (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) echo $msg;
|
if (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) || !$newline) echo $msg;
|
||||||
else echo strip_tags($msg);
|
else echo strip_tags($msg);
|
||||||
|
|
||||||
|
|
||||||
if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // do not flush if output buffering enabled - useless - thx to Jesse Mullan
|
if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // do not flush if output buffering enabled - useless - thx to Jesse Mullan
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Time()
|
function Time()
|
||||||
{
|
{
|
||||||
$rs =& $this->Execute("select $this->sysTimeStamp");
|
$rs =& $this->_Execute("select $this->sysTimeStamp");
|
||||||
if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields));
|
if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -617,7 +619,7 @@
|
|||||||
For databases that require positioned params, eg $1, $2, $3 for postgresql,
|
For databases that require positioned params, eg $1, $2, $3 for postgresql,
|
||||||
pass in Param(false) before setting the first parameter.
|
pass in Param(false) before setting the first parameter.
|
||||||
*/
|
*/
|
||||||
function Param($name)
|
function Param($name,$type='C')
|
||||||
{
|
{
|
||||||
return '?';
|
return '?';
|
||||||
}
|
}
|
||||||
@ -754,7 +756,9 @@
|
|||||||
$ret =& $fn($this,$sql,$inputarr);
|
$ret =& $fn($this,$sql,$inputarr);
|
||||||
if (isset($ret)) return $ret;
|
if (isset($ret)) return $ret;
|
||||||
}
|
}
|
||||||
if ($inputarr && is_array($inputarr)) {
|
if ($inputarr) {
|
||||||
|
if (!is_array($inputarr)) $inputarr = array($inputarr);
|
||||||
|
|
||||||
$element0 = reset($inputarr);
|
$element0 = reset($inputarr);
|
||||||
# is_object check because oci8 descriptors can be passed in
|
# is_object check because oci8 descriptors can be passed in
|
||||||
$array_2d = is_array($element0) && !is_object(reset($element0));
|
$array_2d = is_array($element0) && !is_object(reset($element0));
|
||||||
@ -782,7 +786,7 @@
|
|||||||
if ($i+1 != sizeof($sqlarr))
|
if ($i+1 != sizeof($sqlarr))
|
||||||
ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql));
|
ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql));
|
||||||
|
|
||||||
$ret =& $this->_Execute($sql,false);
|
$ret =& $this->_Execute($sql);
|
||||||
if (!$ret) return $ret;
|
if (!$ret) return $ret;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -803,60 +807,23 @@
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function& _Execute($sql,$inputarr=false)
|
function& _Execute($sql,$inputarr=false)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->debug) {
|
if ($this->debug) {
|
||||||
global $HTTP_SERVER_VARS;
|
global $ADODB_INCLUDED_LIB;
|
||||||
|
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
|
||||||
$ss = '';
|
$this->_queryID = _adodb_debug_execute($this, $sql,$inputarr);
|
||||||
if ($inputarr) {
|
|
||||||
foreach($inputarr as $kk=>$vv) {
|
|
||||||
if (is_string($vv) && strlen($vv)>64) $vv = substr($vv,0,64).'...';
|
|
||||||
$ss .= "($kk=>'$vv') ";
|
|
||||||
}
|
|
||||||
$ss = "[ $ss ]";
|
|
||||||
}
|
|
||||||
$sqlTxt = str_replace(',',', ',is_array($sql) ?$sql[0] : $sql);
|
|
||||||
|
|
||||||
// check if running from browser or command-line
|
|
||||||
$inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']);
|
|
||||||
|
|
||||||
if ($inBrowser) {
|
|
||||||
if ($this->debug === -1)
|
|
||||||
ADOConnection::outp( "<br>\n($this->databaseType): ".htmlspecialchars($sqlTxt)." <code>$ss</code>\n<br>\n",false);
|
|
||||||
else
|
|
||||||
ADOConnection::outp( "<hr>\n($this->databaseType): ".htmlspecialchars($sqlTxt)." <code>$ss</code>\n<hr>\n",false);
|
|
||||||
} else {
|
|
||||||
ADOConnection::outp("-----\n($this->databaseType): ".($sqlTxt)." \n-----\n",false);
|
|
||||||
}
|
|
||||||
$this->_queryID = $this->_query($sql,$inputarr);
|
|
||||||
/*
|
|
||||||
Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql
|
|
||||||
because ErrorNo() calls Execute('SELECT @ERROR'), causing recursion
|
|
||||||
*/
|
|
||||||
if ($this->databaseType == 'mssql') {
|
|
||||||
// ErrorNo is a slow function call in mssql, and not reliable in PHP 4.0.6
|
|
||||||
if($emsg = $this->ErrorMsg()) {
|
|
||||||
if ($err = $this->ErrorNo()) ADOConnection::outp($err.': '.$emsg);
|
|
||||||
}
|
|
||||||
} else if (!$this->_queryID) {
|
|
||||||
ADOConnection::outp($this->ErrorNo() .': '. $this->ErrorMsg());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
//****************************
|
$this->_queryID = @$this->_query($sql,$inputarr);
|
||||||
// non-debug version of query
|
|
||||||
//****************************
|
|
||||||
|
|
||||||
$this->_queryID =@$this->_query($sql,$inputarr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************
|
/************************
|
||||||
// OK, query executed
|
// OK, query executed
|
||||||
*************************/
|
*************************/
|
||||||
|
|
||||||
if ($this->_queryID === false) {
|
if ($this->_queryID === false) { // error handling if query fails
|
||||||
// error handling if query fails
|
|
||||||
if ($this->debug == 99) adodb_backtrace(true,5);
|
if ($this->debug == 99) adodb_backtrace(true,5);
|
||||||
$fn = $this->raiseErrorFn;
|
$fn = $this->raiseErrorFn;
|
||||||
if ($fn) {
|
if ($fn) {
|
||||||
@ -866,12 +833,8 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->_queryID === true) { // return simplified recordset for inserts/updates/deletes with lower overhead
|
||||||
if ($this->_queryID === true) {
|
|
||||||
// return simplified empty recordset for inserts/updates/deletes with lower overhead
|
|
||||||
$rs =& new ADORecordSet_empty();
|
$rs =& new ADORecordSet_empty();
|
||||||
#if (is_array($sql)) $rs->sql = $sql[0];
|
|
||||||
#else $rs->sql = $sql;
|
|
||||||
return $rs;
|
return $rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -885,7 +848,7 @@
|
|||||||
if ($rs->_numOfRows <= 0) {
|
if ($rs->_numOfRows <= 0) {
|
||||||
global $ADODB_COUNTRECS;
|
global $ADODB_COUNTRECS;
|
||||||
if ($ADODB_COUNTRECS) {
|
if ($ADODB_COUNTRECS) {
|
||||||
if (!$rs->EOF){
|
if (!$rs->EOF) {
|
||||||
$rs = &$this->_rs2rs($rs,-1,-1,!is_array($sql));
|
$rs = &$this->_rs2rs($rs,-1,-1,!is_array($sql));
|
||||||
$rs->_queryID = $this->_queryID;
|
$rs->_queryID = $this->_queryID;
|
||||||
} else
|
} else
|
||||||
@ -1241,7 +1204,7 @@
|
|||||||
if ($rs) {
|
if ($rs) {
|
||||||
if (!$rs->EOF) $ret = reset($rs->fields);
|
if (!$rs->EOF) $ret = reset($rs->fields);
|
||||||
$rs->Close();
|
$rs->Close();
|
||||||
}
|
}
|
||||||
$ADODB_COUNTRECS = $crecs;
|
$ADODB_COUNTRECS = $crecs;
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
@ -1481,6 +1444,10 @@
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global $ADODB_INCLUDED_CSV;
|
||||||
|
if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
|
||||||
|
|
||||||
$f = $this->_gencachename($sql.serialize($inputarr),false);
|
$f = $this->_gencachename($sql.serialize($inputarr),false);
|
||||||
adodb_write_file($f,''); // is adodb_write_file needed?
|
adodb_write_file($f,''); // is adodb_write_file needed?
|
||||||
if (!@unlink($f)) {
|
if (!@unlink($f)) {
|
||||||
@ -1631,7 +1598,7 @@
|
|||||||
$forcenulls = defined('ADODB_FORCE_NULLS') ? true : false;
|
$forcenulls = defined('ADODB_FORCE_NULLS') ? true : false;
|
||||||
}
|
}
|
||||||
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
|
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
|
||||||
return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq);
|
return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq,$forcenulls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1650,7 +1617,7 @@
|
|||||||
$forcenulls = defined('ADODB_FORCE_NULLS') ? true : false;
|
$forcenulls = defined('ADODB_FORCE_NULLS') ? true : false;
|
||||||
}
|
}
|
||||||
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
|
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
|
||||||
return _adodb_getinsertsql($this,$rs,$arrFields,$magicq);
|
return _adodb_getinsertsql($this,$rs,$arrFields,$magicq,$forcenulls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2505,7 +2472,10 @@
|
|||||||
* @return an associative array indexed by the first column of the array,
|
* @return an associative array indexed by the first column of the array,
|
||||||
* or false if the data has less than 2 cols.
|
* or false if the data has less than 2 cols.
|
||||||
*/
|
*/
|
||||||
function &GetAssoc($force_array = false, $first2cols = false) {
|
function &GetAssoc($force_array = false, $first2cols = false)
|
||||||
|
{
|
||||||
|
global $ADODB_EXTENSION;
|
||||||
|
|
||||||
$cols = $this->_numOfFields;
|
$cols = $this->_numOfFields;
|
||||||
if ($cols < 2) {
|
if ($cols < 2) {
|
||||||
return false;
|
return false;
|
||||||
@ -2514,32 +2484,64 @@
|
|||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
if (!$first2cols && ($cols > 2 || $force_array)) {
|
if (!$first2cols && ($cols > 2 || $force_array)) {
|
||||||
if ($numIndex) {
|
if ($ADODB_EXTENSION) {
|
||||||
while (!$this->EOF) {
|
if ($numIndex) {
|
||||||
$results[trim($this->fields[0])] = array_slice($this->fields, 1);
|
while (!$this->EOF) {
|
||||||
$this->MoveNext();
|
$results[trim($this->fields[0])] = array_slice($this->fields, 1);
|
||||||
|
adodb_movenext($this);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (!$this->EOF) {
|
||||||
|
$results[trim(reset($this->fields))] = array_slice($this->fields, 1);
|
||||||
|
adodb_movenext($this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (!$this->EOF) {
|
if ($numIndex) {
|
||||||
$results[trim(reset($this->fields))] = array_slice($this->fields, 1);
|
while (!$this->EOF) {
|
||||||
$this->MoveNext();
|
$results[trim($this->fields[0])] = array_slice($this->fields, 1);
|
||||||
|
$this->MoveNext();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (!$this->EOF) {
|
||||||
|
$results[trim(reset($this->fields))] = array_slice($this->fields, 1);
|
||||||
|
$this->MoveNext();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// return scalar values
|
if ($ADODB_EXTENSION) {
|
||||||
if ($numIndex) {
|
// return scalar values
|
||||||
while (!$this->EOF) {
|
if ($numIndex) {
|
||||||
// some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
|
while (!$this->EOF) {
|
||||||
$results[trim(($this->fields[0]))] = $this->fields[1];
|
// some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
|
||||||
$this->MoveNext();
|
$results[trim(($this->fields[0]))] = $this->fields[1];
|
||||||
|
adodb_movenext($this);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (!$this->EOF) {
|
||||||
|
// some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
|
||||||
|
$v1 = trim(reset($this->fields));
|
||||||
|
$v2 = ''.next($this->fields);
|
||||||
|
$results[$v1] = $v2;
|
||||||
|
adodb_movenext($this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (!$this->EOF) {
|
if ($numIndex) {
|
||||||
// some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
|
while (!$this->EOF) {
|
||||||
$v1 = trim(reset($this->fields));
|
// some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
|
||||||
$v2 = ''.next($this->fields);
|
$results[trim(($this->fields[0]))] = $this->fields[1];
|
||||||
$results[$v1] = $v2;
|
$this->MoveNext();
|
||||||
$this->MoveNext();
|
}
|
||||||
|
} else {
|
||||||
|
while (!$this->EOF) {
|
||||||
|
// some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
|
||||||
|
$v1 = trim(reset($this->fields));
|
||||||
|
$v2 = ''.next($this->fields);
|
||||||
|
$results[$v1] = $v2;
|
||||||
|
$this->MoveNext();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2728,7 +2730,8 @@
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Random access to a specific row in the recordset. Some databases do not support
|
* Random access to a specific row in the recordset. Some databases do not support
|
||||||
@ -2989,7 +2992,8 @@
|
|||||||
*/
|
*/
|
||||||
function &FetchNextObj()
|
function &FetchNextObj()
|
||||||
{
|
{
|
||||||
return $this->FetchNextObject(false);
|
$o = $this->FetchNextObject(false);
|
||||||
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3415,6 +3419,7 @@
|
|||||||
if (!$dbType) return false;
|
if (!$dbType) return false;
|
||||||
$db = strtolower($dbType);
|
$db = strtolower($dbType);
|
||||||
switch ($db) {
|
switch ($db) {
|
||||||
|
case 'ifx':
|
||||||
case 'maxsql': $db = 'mysqlt'; break;
|
case 'maxsql': $db = 'mysqlt'; break;
|
||||||
case 'postgres':
|
case 'postgres':
|
||||||
case 'pgsql': $db = 'postgres7'; break;
|
case 'pgsql': $db = 'postgres7'; break;
|
||||||
@ -3456,44 +3461,111 @@
|
|||||||
if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2);
|
if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2);
|
||||||
$errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false;
|
$errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false;
|
||||||
|
|
||||||
|
if (strpos($db,'://')) {
|
||||||
|
$origdsn = $db;
|
||||||
|
$dsna = @parse_url($db);
|
||||||
|
if (!$dsna) {
|
||||||
|
// special handling of oracle, which might not have host
|
||||||
|
$db = str_replace('@/','@adodb-fakehost/',$db);
|
||||||
|
$dsna = parse_url($db);
|
||||||
|
if (!$dsna) return false;
|
||||||
|
$dsna['host'] = '';
|
||||||
|
}
|
||||||
|
$db = @$dsna['scheme'];
|
||||||
|
if (!$db) return false;
|
||||||
|
$dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : '';
|
||||||
|
$dsna['user'] = isset($dsna['user']) ? rawurldecode($dsna['user']) : '';
|
||||||
|
$dsna['pass'] = isset($dsna['pass']) ? rawurldecode($dsna['pass']) : '';
|
||||||
|
$dsna['path'] = isset($dsna['path']) ? rawurldecode(substr($dsna['path'],1)) : '';
|
||||||
|
|
||||||
|
if (isset($dsna['query'])) {
|
||||||
|
$opt1 = explode('&',$dsna['query']);
|
||||||
|
foreach($opt1 as $k => $v) {
|
||||||
|
$arr = explode('=',$v);
|
||||||
|
$opt[$arr[0]] = isset($arr[1]) ? rawurldecode($arr[1]) : 1;
|
||||||
|
}
|
||||||
|
} else $opt = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* phptype: Database backend used in PHP (mysql, odbc etc.)
|
||||||
|
* dbsyntax: Database used with regards to SQL syntax etc.
|
||||||
|
* protocol: Communication protocol to use (tcp, unix etc.)
|
||||||
|
* hostspec: Host specification (hostname[:port])
|
||||||
|
* database: Database to use on the DBMS server
|
||||||
|
* username: User name for login
|
||||||
|
* password: Password for login
|
||||||
|
*/
|
||||||
if (!empty($ADODB_NEWCONNECTION)) {
|
if (!empty($ADODB_NEWCONNECTION)) {
|
||||||
$obj = $ADODB_NEWCONNECTION($db);
|
$obj = $ADODB_NEWCONNECTION($db);
|
||||||
if ($obj) {
|
|
||||||
if ($errorfn) $obj->raiseErrorFn = $errorfn;
|
} else {
|
||||||
return $obj;
|
|
||||||
|
if (!isset($ADODB_LASTDB)) $ADODB_LASTDB = '';
|
||||||
|
if (empty($db)) $db = $ADODB_LASTDB;
|
||||||
|
|
||||||
|
if ($db != $ADODB_LASTDB) $db = ADOLoadCode($db);
|
||||||
|
|
||||||
|
if (!$db) {
|
||||||
|
if (isset($origdsn)) $db = $origdsn;
|
||||||
|
if ($errorfn) {
|
||||||
|
// raise an error
|
||||||
|
$ignore = false;
|
||||||
|
$errorfn('ADONewConnection', 'ADONewConnection', -998,
|
||||||
|
"could not load the database driver for '$db'",
|
||||||
|
$db,false,$ignore);
|
||||||
|
} else
|
||||||
|
ADOConnection::outp( "<p>ADONewConnection: Unable to load database driver '$db'</p>",false);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cls = 'ADODB_'.$db;
|
||||||
|
if (!class_exists($cls)) {
|
||||||
|
adodb_backtrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$obj =& new $cls();
|
||||||
|
}
|
||||||
|
|
||||||
|
# constructor should not fail
|
||||||
|
if ($obj) {
|
||||||
|
if ($errorfn) $obj->raiseErrorFn = $errorfn;
|
||||||
|
if (isset($dsna)) {
|
||||||
|
|
||||||
|
foreach($opt as $k => $v) {
|
||||||
|
switch(strtolower($k)) {
|
||||||
|
case 'persist':
|
||||||
|
case 'persistent': $persist = $v; break;
|
||||||
|
case 'debug': $obj->debug = (integer) $v; break;
|
||||||
|
#ibase
|
||||||
|
case 'dialect': $obj->dialect = (integer) $v; break;
|
||||||
|
case 'charset': $obj->charset = $v; break;
|
||||||
|
case 'buffers': $obj->buffers = $v; break;
|
||||||
|
case 'fetchmode': $obj->SetFetchMode($v); break;
|
||||||
|
#ado
|
||||||
|
case 'charpage': $obj->charPage = $v; break;
|
||||||
|
#mysql, mysqli
|
||||||
|
case 'clientflags': $obj->clientFlags = $v; break;
|
||||||
|
#mysqli
|
||||||
|
case 'port': $obj->port = $v; break;
|
||||||
|
case 'socket': $obj->socket = $v; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($persist))
|
||||||
|
$ok = $obj->Connect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);
|
||||||
|
else
|
||||||
|
$ok = $obj->PConnect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);
|
||||||
|
|
||||||
|
if (!$ok) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($ADODB_LASTDB)) $ADODB_LASTDB = '';
|
|
||||||
if (empty($db)) $db = $ADODB_LASTDB;
|
|
||||||
|
|
||||||
if ($db != $ADODB_LASTDB) $db = ADOLoadCode($db);
|
|
||||||
|
|
||||||
if (!$db) {
|
|
||||||
if ($errorfn) {
|
|
||||||
// raise an error
|
|
||||||
$ignore = false;
|
|
||||||
$errorfn('ADONewConnection', 'ADONewConnection', -998,
|
|
||||||
"could not load the database driver for '$db",
|
|
||||||
$db,false,$ignore);
|
|
||||||
} else
|
|
||||||
ADOConnection::outp( "<p>ADONewConnection: Unable to load database driver '$db'</p>",false);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$cls = 'ADODB_'.$db;
|
|
||||||
if (!class_exists($cls)) {
|
|
||||||
adodb_backtrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$obj =& new $cls();
|
|
||||||
if ($errorfn) $obj->raiseErrorFn = $errorfn;
|
|
||||||
|
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// $perf == true means called by NewPerfMonitor()
|
// $perf == true means called by NewPerfMonitor()
|
||||||
function _adodb_getdriver($provider,$drivername,$perf=false)
|
function _adodb_getdriver($provider,$drivername,$perf=false)
|
||||||
{
|
{
|
||||||
@ -3511,8 +3583,6 @@
|
|||||||
break;
|
break;
|
||||||
case 'db2':
|
case 'db2':
|
||||||
break;
|
break;
|
||||||
case 'sapdb':
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
$drivername = 'generic';
|
$drivername = 'generic';
|
||||||
break;
|
break;
|
||||||
@ -3561,56 +3631,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save a file $filename and its $contents (normally for caching) with file locking
|
|
||||||
*/
|
|
||||||
function adodb_write_file($filename, $contents,$debug=false)
|
|
||||||
{
|
|
||||||
# http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows
|
|
||||||
# So to simulate locking, we assume that rename is an atomic operation.
|
|
||||||
# First we delete $filename, then we create a $tempfile write to it and
|
|
||||||
# rename to the desired $filename. If the rename works, then we successfully
|
|
||||||
# modified the file exclusively.
|
|
||||||
# What a stupid need - having to simulate locking.
|
|
||||||
# Risks:
|
|
||||||
# 1. $tempfile name is not unique -- very very low
|
|
||||||
# 2. unlink($filename) fails -- ok, rename will fail
|
|
||||||
# 3. adodb reads stale file because unlink fails -- ok, $rs timeout occurs
|
|
||||||
# 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated
|
|
||||||
if (strncmp(PHP_OS,'WIN',3) === 0) {
|
|
||||||
// skip the decimal place
|
|
||||||
$mtime = substr(str_replace(' ','_',microtime()),2);
|
|
||||||
// getmypid() actually returns 0 on Win98 - never mind!
|
|
||||||
$tmpname = $filename.uniqid($mtime).getmypid();
|
|
||||||
if (!($fd = fopen($tmpname,'a'))) return false;
|
|
||||||
$ok = ftruncate($fd,0);
|
|
||||||
if (!fwrite($fd,$contents)) $ok = false;
|
|
||||||
fclose($fd);
|
|
||||||
chmod($tmpname,0644);
|
|
||||||
// the tricky moment
|
|
||||||
@unlink($filename);
|
|
||||||
if (!@rename($tmpname,$filename)) {
|
|
||||||
unlink($tmpname);
|
|
||||||
$ok = false;
|
|
||||||
}
|
|
||||||
if (!$ok) {
|
|
||||||
if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed'));
|
|
||||||
}
|
|
||||||
return $ok;
|
|
||||||
}
|
|
||||||
if (!($fd = fopen($filename, 'a'))) return false;
|
|
||||||
if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) {
|
|
||||||
$ok = fwrite( $fd, $contents );
|
|
||||||
fclose($fd);
|
|
||||||
chmod($filename,0644);
|
|
||||||
}else {
|
|
||||||
fclose($fd);
|
|
||||||
if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename<br>\n");
|
|
||||||
$ok = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Perform a print_r, with pre tags for better formatting.
|
Perform a print_r, with pre tags for better formatting.
|
||||||
@ -3631,54 +3651,9 @@
|
|||||||
*/
|
*/
|
||||||
function adodb_backtrace($printOrArr=true,$levels=9999)
|
function adodb_backtrace($printOrArr=true,$levels=9999)
|
||||||
{
|
{
|
||||||
$s = '';
|
global $ADODB_INCLUDED_LIB;
|
||||||
if (PHPVERSION() < 4.3) return;
|
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
|
||||||
|
return _adodb_backtrace($printOrArr,$levels);
|
||||||
$html = (isset($_SERVER['HTTP_USER_AGENT']));
|
|
||||||
$fmt = ($html) ? "</font><font color=#808080 size=-1> %% line %4d, file: <a href=\"file:/%s\">%s</a></font>" : "%% line %4d, file: %s";
|
|
||||||
|
|
||||||
$MAXSTRLEN = 64;
|
|
||||||
|
|
||||||
$s = ($html) ? '<pre align=left>' : '';
|
|
||||||
|
|
||||||
if (is_array($printOrArr)) $traceArr = $printOrArr;
|
|
||||||
else $traceArr = debug_backtrace();
|
|
||||||
array_shift($traceArr);
|
|
||||||
$tabs = sizeof($traceArr)-1;
|
|
||||||
|
|
||||||
foreach ($traceArr as $arr) {
|
|
||||||
$levels -= 1;
|
|
||||||
if ($levels < 0) break;
|
|
||||||
|
|
||||||
$args = array();
|
|
||||||
for ($i=0; $i < $tabs; $i++) $s .= ($html) ? ' ' : "\t";
|
|
||||||
$tabs -= 1;
|
|
||||||
if ($html) $s .= '<font face="Courier New,Courier">';
|
|
||||||
if (isset($arr['class'])) $s .= $arr['class'].'.';
|
|
||||||
if (isset($arr['args']))
|
|
||||||
foreach($arr['args'] as $v) {
|
|
||||||
if (is_null($v)) $args[] = 'null';
|
|
||||||
else if (is_array($v)) $args[] = 'Array['.sizeof($v).']';
|
|
||||||
else if (is_object($v)) $args[] = 'Object:'.get_class($v);
|
|
||||||
else if (is_bool($v)) $args[] = $v ? 'true' : 'false';
|
|
||||||
else {
|
|
||||||
$v = (string) @$v;
|
|
||||||
$str = htmlspecialchars(substr($v,0,$MAXSTRLEN));
|
|
||||||
if (strlen($v) > $MAXSTRLEN) $str .= '...';
|
|
||||||
$args[] = $str;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$s .= $arr['function'].'('.implode(', ',$args).')';
|
|
||||||
|
|
||||||
|
|
||||||
$s .= @sprintf($fmt, $arr['line'],$arr['file'],basename($arr['file']));
|
|
||||||
|
|
||||||
$s .= "\n";
|
|
||||||
}
|
|
||||||
if ($html) $s .= '</pre>';
|
|
||||||
if ($printOrArr) print $s;
|
|
||||||
|
|
||||||
return $s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // defined
|
} // defined
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -2,11 +2,16 @@
|
|||||||
<head>
|
<head>
|
||||||
<title>ADODB Manual</title>
|
<title>ADODB Manual</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
<XSTYLE
|
|
||||||
body,td {font-family:Arial,Helvetica,sans-serif;font-size:11pt}
|
|
||||||
pre {font-size:9pt}
|
<style>
|
||||||
.toplink {font-size:8pt}
|
pre {
|
||||||
/>
|
background-color: #eee;
|
||||||
|
padding: 0.75em 1.5em;
|
||||||
|
font-size: 12px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="#FFFFFF">
|
<body bgcolor="#FFFFFF">
|
||||||
|
|
||||||
@ -26,10 +31,9 @@
|
|||||||
<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</a><br>
|
</b><b><a href="#install">Installation</a><br>
|
||||||
<a href="#mininstall">Minimum Install</a><br>
|
<a href="#mininstall">Minimum Install</a><br>
|
||||||
<a href="#coding">Initializing Code and Connection Examples</a><br>
|
<a href="#coding">Initializing Code and Connectioning to Databases</a><br>
|
||||||
<font size="2"><a href=#adonewconnection>ADONewConnection</a></font>
|
</b><font size="2"> <a href=#dsnsupport>Data Source Name (DSN) Support</a></font> <a href=#connect_ex>Connection Examples</a></font> <br>
|
||||||
<font size="2"><a href=#adonewconnection>NewADOConnection</a></font><br>
|
<b><a href="#speed">High Speed ADOdb - tuning tips</a></b><br>
|
||||||
<a href="#speed">High Speed ADOdb - tuning tips</a></b><br>
|
|
||||||
<b><a href="#hack">Hacking and Modifying ADOdb Safely</a><br>
|
<b><a href="#hack">Hacking and Modifying ADOdb Safely</a><br>
|
||||||
<a href="#php5">PHP5 Features</a></b><br>
|
<a href="#php5">PHP5 Features</a></b><br>
|
||||||
<font size="2"><a href=#php5iterators>foreach iterators</a> <a href=#php5exceptions>exceptions</a></font><br>
|
<font size="2"><a href=#php5iterators>foreach iterators</a> <a href=#php5exceptions>exceptions</a></font><br>
|
||||||
@ -232,22 +236,73 @@ $conn = &ADONewConnection('mysql');
|
|||||||
using the <b>ADONewConnection</b>($driver) function.
|
using the <b>ADONewConnection</b>($driver) function.
|
||||||
<b>NewADOConnection</b>($driver) is an alternative name for the same function.</p>
|
<b>NewADOConnection</b>($driver) is an alternative name for the same function.</p>
|
||||||
|
|
||||||
<p>At this point, you are not connected to the database. You will first need to decide
|
<p>At this point, you are not connected to the database (no longer true if you pass in a <a href=#dsnsupport>dsn</a>). You will first need to decide
|
||||||
whether to use <i>persistent</i> or <i>non-persistent</i> connections. The advantage of <i>persistent</i>
|
whether to use <i>persistent</i> or <i>non-persistent</i> connections. The advantage of <i>persistent</i>
|
||||||
connections is that they are faster, as the database connection is never closed (even
|
connections is that they are faster, as the database connection is never closed (even
|
||||||
when you call Close()). <i>Non-persistent </i>connections take up much fewer resources though,
|
when you call Close()). <i>Non-persistent </i>connections take up much fewer resources though,
|
||||||
reducing the risk of your database and your web-server becoming overloaded.
|
reducing the risk of your database and your web-server becoming overloaded.
|
||||||
<p>For persistent connections,
|
<p>For persistent connections,
|
||||||
use $conn-><a href="reference.functions.pconnect.html">PConnect()</a>,
|
use $conn-><a href="#pconnect">PConnect()</a>,
|
||||||
or $conn-><a href="reference.functions.connect.html">Connect()</a> for non-persistent connections.
|
or $conn-><a href="#connect">Connect()</a> for non-persistent connections.
|
||||||
Some database drivers also support <a href="reference.functions.nconnect.html">NConnect()</a>, which forces
|
Some database drivers also support <a href="#nconnect">NConnect()</a>, which forces
|
||||||
the creation of a new connection.
|
the creation of a new connection.
|
||||||
|
|
||||||
<a name=connection_gotcha></a>
|
<a name=connection_gotcha></a>
|
||||||
<p><i>Connection Gotcha</i>: If you create two connections, but both use the same userid and password,
|
<p><b>Connection Gotcha</b>: If you create two connections, but both use the same userid and password,
|
||||||
PHP will share the same connection. This can cause problems if the connections are meant to
|
PHP will share the same connection. This can cause problems if the connections are meant to
|
||||||
different databases. The solution is to always use different userid's for different databases,
|
different databases. The solution is to always use different userid's for different databases,
|
||||||
or use NConnect().
|
or use NConnect().
|
||||||
|
|
||||||
|
<a name=dsnsupport></a>
|
||||||
|
<h3>Data Source Name (DSN) Support</h3>
|
||||||
|
<p> Since ADOdb 4.51, you can connect to a database by passing a dsn to NewADOConnection() (or ADONewConnection, which is
|
||||||
|
the same function). The dsn format is:
|
||||||
|
<pre>
|
||||||
|
$driver://$username:$password@hostname/$database?options[=value]
|
||||||
|
</pre><p>
|
||||||
|
NewADOConnection() calls Connect() or PConnect() internally for you. If the connection fails, false is returned.
|
||||||
|
<pre>
|
||||||
|
<font color=#008000># non-persistent connection</font>
|
||||||
|
$dsn = 'mysql://root:pwd@localhost/mydb';
|
||||||
|
$db = NewADOConnection($dsn);
|
||||||
|
if (!$db) die("Connection failed");
|
||||||
|
|
||||||
|
<font color=#008000># no need to call connect/pconnect!</font>
|
||||||
|
$arr = $db->GetArray("select * from table");
|
||||||
|
|
||||||
|
<font color=#008000># persistent connection</font>
|
||||||
|
$dsn2 = 'mysql://root:pwd@localhost/mydb?persist';
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
If you have special characters such as /:? in your dsn, then you need to rawurlencode them first:
|
||||||
|
<pre>
|
||||||
|
$pwd = rawurlencode($pwd);
|
||||||
|
$dsn = "mysql://root:$pwd@localhost/mydb";
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
Legal options are:
|
||||||
|
<p>
|
||||||
|
<table align=center border=1><tr><td>For all drivers<td>
|
||||||
|
'persist', 'persistent', 'debug', 'fetchmode'
|
||||||
|
<tr><td>Interbase/Firebird
|
||||||
|
<td>
|
||||||
|
'dialect',
|
||||||
|
'charset',
|
||||||
|
'buffers'
|
||||||
|
<tr><td>M'soft ADO<td>
|
||||||
|
'charpage'
|
||||||
|
|
||||||
|
<tr><td>MySQL<td>
|
||||||
|
'clientflags'
|
||||||
|
<tr><td>MySQLi<td>
|
||||||
|
'port', 'socket', 'clientflags'
|
||||||
|
</table>
|
||||||
|
<p>
|
||||||
|
For all drivers, when the options <i>persist</i> or <i>persistent</i> are set, a persistent connection is forced.
|
||||||
|
The <i>debug</i> option enables debugging. The <i>fetchmode</i> calls <a href=#setfetchmode>SetFetchMode()</a>.
|
||||||
|
If no value is defined for an option, then the value is set to 1.
|
||||||
|
<p>
|
||||||
|
ADOdb DSN's are compatible with version 1.0 of PEAR DB's DSN format.
|
||||||
<a name=connect_ex>
|
<a name=connect_ex>
|
||||||
<h3>Examples of Connecting to Databases</h3>
|
<h3>Examples of Connecting to Databases</h3>
|
||||||
<h4>MySQL and Most Other Database Drivers</h4>
|
<h4>MySQL and Most Other Database Drivers</h4>
|
||||||
@ -256,8 +311,23 @@ different databases. The solution is to always use different userid's for differ
|
|||||||
<pre>
|
<pre>
|
||||||
$conn = &ADONewConnection('mysql');
|
$conn = &ADONewConnection('mysql');
|
||||||
$conn->PConnect('localhost','userid','password','database');
|
$conn->PConnect('localhost','userid','password','database');
|
||||||
|
|
||||||
|
<font color=#008000># or dsn </font>
|
||||||
|
$dsn = 'mysql://user:pwd@localhost/mydb';
|
||||||
|
$conn = ADONewConnection($dsn); # no need for Connect()
|
||||||
|
|
||||||
|
<font color=#008000># or persistent dsn</font>
|
||||||
|
$dsn = 'mysql://user:pwd@localhost/mydb?persist';
|
||||||
|
$conn = ADONewConnection($dsn); # no need for PConnect()
|
||||||
|
|
||||||
|
<font color=#008000># a more complex example:</font>
|
||||||
|
$pwd = urlencode($pwd);
|
||||||
|
$flags = MYSQL_CLIENT_COMPRESS;
|
||||||
|
$dsn = "mysql://user:$pwd@localhost/mydb?persist&clientflags=$flags";
|
||||||
|
$conn = ADONewConnection($dsn); # no need for PConnect()
|
||||||
</pre>
|
</pre>
|
||||||
<p> Most other database drivers use a similar convention: Connect($server, $user, $password, $database). Exceptions are listed below.
|
<p> For most drivers, you can use the standard function: Connect($server, $user, $password, $database), or
|
||||||
|
a <a href=dsnsupport>DSN</a> since ADOdb 4.51. Exceptions to this are listed below.
|
||||||
<h4>PostgreSQL</h4>
|
<h4>PostgreSQL</h4>
|
||||||
<p>PostgreSQL accepts connections using: </p>
|
<p>PostgreSQL accepts connections using: </p>
|
||||||
<p>a. the standard connection string:</p>
|
<p>a. the standard connection string:</p>
|
||||||
@ -267,7 +337,14 @@ different databases. The solution is to always use different userid's for differ
|
|||||||
<p> b. the classical 4 parameters:</p>
|
<p> b. the classical 4 parameters:</p>
|
||||||
<pre>
|
<pre>
|
||||||
$conn->PConnect('localhost','userid','password','database');
|
$conn->PConnect('localhost','userid','password','database');
|
||||||
</pre><a name=ldap></a>
|
</pre>
|
||||||
|
<p>c. dsn:
|
||||||
|
<pre>
|
||||||
|
$dsn = 'postgres7://user:pwd@localhost/mydb?persist'; # persist is optional
|
||||||
|
$conn = ADONewConnection($dsn); # no need for Connect/PConnect
|
||||||
|
</pre>
|
||||||
|
<a name=ldap></a>
|
||||||
|
|
||||||
<h4>LDAP</h4>
|
<h4>LDAP</h4>
|
||||||
<p>Here is an example of querying a LDAP server. Thanks to Josh Eldridge for the driver and this example:
|
<p>Here is an example of querying a LDAP server. Thanks to Josh Eldridge for the driver and this example:
|
||||||
<pre>
|
<pre>
|
||||||
@ -313,12 +390,22 @@ You define the database in the $host parameter:
|
|||||||
$conn = &ADONewConnection('ibase');
|
$conn = &ADONewConnection('ibase');
|
||||||
$conn->PConnect('localhost:c:\ibase\employee.gdb','sysdba','masterkey');
|
$conn->PConnect('localhost:c:\ibase\employee.gdb','sysdba','masterkey');
|
||||||
</pre>
|
</pre>
|
||||||
|
<p>Or dsn:
|
||||||
|
<pre>
|
||||||
|
$dsn = 'firebird://user:pwd@localhost/mydb?persist&dialect=3'; # persist is optional
|
||||||
|
$conn = ADONewConnection($dsn); # no need for Connect/PConnect
|
||||||
|
</pre>
|
||||||
<h4>SQLite</h4>
|
<h4>SQLite</h4>
|
||||||
Sqlite will create the database file if it does not exist.
|
Sqlite will create the database file if it does not exist.
|
||||||
<pre>
|
<pre>
|
||||||
$conn = &ADONewConnection('sqlite');
|
$conn = &ADONewConnection('sqlite');
|
||||||
$conn->PConnect('c:\path\to\sqlite.db'); # sqlite will create if does not exist
|
$conn->PConnect('c:\path\to\sqlite.db'); # sqlite will create if does not exist
|
||||||
</pre>
|
</pre>
|
||||||
|
<p>Or dsn:
|
||||||
|
<pre>
|
||||||
|
$dsn = 'sqlite://user:pwd@localhost/mydb?persist'; # persist is optional
|
||||||
|
$conn = ADONewConnection($dsn); # no need for Connect/PConnect
|
||||||
|
</pre>
|
||||||
<h4>Oracle (oci8)</h4>
|
<h4>Oracle (oci8)</h4>
|
||||||
<p>With oci8, you can connect in multiple ways. Note that oci8 works fine with
|
<p>With oci8, you can connect in multiple ways. Note that oci8 works fine with
|
||||||
newer versions of the Oracle, eg. 9i and 10g.</p>
|
newer versions of the Oracle, eg. 9i and 10g.</p>
|
||||||
@ -337,6 +424,17 @@ newer versions of the Oracle, eg. 9i and 10g.</p>
|
|||||||
(CONNECT_DATA=(SID=$sid)))";
|
(CONNECT_DATA=(SID=$sid)))";
|
||||||
$conn->Connect($cstr, 'scott', 'tiger');
|
$conn->Connect($cstr, 'scott', 'tiger');
|
||||||
</pre>
|
</pre>
|
||||||
|
<p>f. ADOdb dsn:
|
||||||
|
<pre>
|
||||||
|
$dsn = 'oci8://user:pwd@tnsname?persist'; # persist is optional
|
||||||
|
$conn = ADONewConnection($dsn); # no need for Connect/PConnect
|
||||||
|
|
||||||
|
$dsn = 'oci8://user:pwd@host/sid';
|
||||||
|
$conn = ADONewConnection($dsn);
|
||||||
|
|
||||||
|
$dsn = 'oci8://user:pwd@/'; # oracle on local machine
|
||||||
|
$conn = ADONewConnection($dsn);
|
||||||
|
</pre>
|
||||||
<a name=dsnless></a>
|
<a name=dsnless></a>
|
||||||
<h4>DSN-less ODBC (access and mssql examples)</h4>
|
<h4>DSN-less ODBC (access and mssql examples)</h4>
|
||||||
<p>ODBC DSN's can be created in the ODBC control panel, or you can use a DSN-less
|
<p>ODBC DSN's can be created in the ODBC control panel, or you can use a DSN-less
|
||||||
@ -395,16 +493,27 @@ using the ADOdb library and Microsoft's ADO:
|
|||||||
qstr, Affected_Rows, Insert_ID</p></td>
|
qstr, Affected_Rows, Insert_ID</p></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<p>The fastest way to access the fields is by accessing the array $recordset->fields
|
<p>The fastest way to access the field data is by accessing the array $recordset->fields
|
||||||
directly. Also set the global variables <a href="#adodb_fetch_mode">$ADODB_FETCH_MODE</a>
|
directly. Also set the global variables <a href="#adodb_fetch_mode">$ADODB_FETCH_MODE</a>
|
||||||
= ADODB_FETCH_NUM, and (for oci8, ibase/firebird and odbc) <a href="#adodb_countrecs">$ADODB_COUNTRECS</a> = false
|
= ADODB_FETCH_NUM, and (for oci8, ibase/firebird and odbc) <a href="#adodb_countrecs">$ADODB_COUNTRECS</a> = false
|
||||||
before you connect to your database.</p>
|
before you connect to your database.</p>
|
||||||
<p>Consider using bind parameters if your database supports it, as it improves
|
<p>Consider using bind parameters if your database supports it, as it improves
|
||||||
query plan reuse. Use ADOdb's performance tuning system to identify bottlenecks
|
query plan reuse. Use ADOdb's performance tuning system to identify bottlenecks
|
||||||
quickly. At the time of writing (Dec 2003), this means oci8 and odbc drivers.</p>
|
quickly. At the time of writing (Dec 2003), this means oci8 and odbc drivers.</p>
|
||||||
<p>Lastly make sure you have a PHP accelerator cache installed such as APC, Turck
|
<p>Lastly make sure you have a PHP accelerator cache installed such as APC, Turck
|
||||||
MMCache, Zend Accelerator or ionCube.</p>
|
MMCache, Zend Accelerator or ionCube.</p>
|
||||||
<p>Informix tips: Disable scrollable cursors with $db->cursorType = 0.
|
<p><b>Advanced Tips</b>
|
||||||
|
<p>If you have the <a href=http://adodb.sourceforge.net/#extension>ADOdb C extension</a> installed,
|
||||||
|
you can replace your calls to $rs->MoveNext() with adodb_movenext($rs).
|
||||||
|
This doubles the speed of this operation. For retrieving entire recordsets at once,
|
||||||
|
use GetArray(), which uses the high speed extension function adodb_getall($rs) internally.
|
||||||
|
<p>Execute() is the default way to run queries. You can use the low-level functions _Execute() and _query()
|
||||||
|
to reduce query overhead. Both these functions share the same parameters as Execute().
|
||||||
|
<p>If you do not have any bind parameters or your database supports binding (without emulation),
|
||||||
|
then you can call _Execute() directly. Calling this function bypasses bind emulation. Debugging is still supported in _Execute().
|
||||||
|
<p>If you do not require debugging facilities nor emulated binding, and do not require a recordset to be returned, then you can call _query. This is great for inserts, updates and deletes. Calling this function
|
||||||
|
bypasses emulated binding, debugging, and recordset handling. Either the resultid, true or false are returned by _query().
|
||||||
|
<p>For Informix, you can disable scrollable cursors with $db->cursorType = 0.
|
||||||
<p><a name=hack></a> </p>
|
<p><a name=hack></a> </p>
|
||||||
<h2>Hacking ADOdb Safely</h2>
|
<h2>Hacking ADOdb Safely</h2>
|
||||||
<p>You might want to modify ADOdb for your own purposes. Luckily you can
|
<p>You might want to modify ADOdb for your own purposes. Luckily you can
|
||||||
@ -416,7 +525,7 @@ the function-name stored in this variable if it is defined.
|
|||||||
is placed in the <i>hack_mysql</i> and <i>hack_postgres7</i> classes. The recordset class naming convention
|
is placed in the <i>hack_mysql</i> and <i>hack_postgres7</i> classes. The recordset class naming convention
|
||||||
can be controlled using $rsPrefix. Here we set it to 'hack_rs_', which will make ADOdb use
|
can be controlled using $rsPrefix. Here we set it to 'hack_rs_', which will make ADOdb use
|
||||||
<i>hack_rs_mysql</i> and <i>hack_rs_postgres7</i> as the recordset classes.
|
<i>hack_rs_mysql</i> and <i>hack_rs_postgres7</i> as the recordset classes.
|
||||||
If you want to use the default ADOdb drivers return false.
|
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
class hack_mysql extends adodb_mysql {
|
class hack_mysql extends adodb_mysql {
|
||||||
@ -425,7 +534,7 @@ var $rsPrefix = 'hack_rs_';
|
|||||||
}
|
}
|
||||||
|
|
||||||
class hack_rs_mysql extends ADORecordSet_mysql {
|
class hack_rs_mysql extends ADORecordSet_mysql {
|
||||||
/* Your mods here */
|
/* Your mods here */
|
||||||
}
|
}
|
||||||
|
|
||||||
class hack_postgres7 extends adodb_postgres7 {
|
class hack_postgres7 extends adodb_postgres7 {
|
||||||
@ -449,9 +558,8 @@ function& hack_factory($driver)
|
|||||||
}
|
}
|
||||||
|
|
||||||
include_once('adodb.inc.php');
|
include_once('adodb.inc.php');
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
<p>Don't forget to call the constructor of the parent class.
|
<p><p>Don't forget to call the constructor of the parent class in your constructor. If you want to use the default ADOdb drivers return false in the above hack_factory() function.
|
||||||
<a name="php5"></a>
|
<a name="php5"></a>
|
||||||
<h2>PHP5 Features</h2>
|
<h2>PHP5 Features</h2>
|
||||||
ADOdb 4.02 or later will transparently determine which version of PHP you are using.
|
ADOdb 4.02 or later will transparently determine which version of PHP you are using.
|
||||||
@ -481,6 +589,7 @@ catch exceptions on errors as they occur.
|
|||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
<p>Note that reaching EOF is <b>not</b> considered an error nor an exception.
|
<p>Note that reaching EOF is <b>not</b> considered an error nor an exception.
|
||||||
|
If you want to use the default ADOdb drivers return false.
|
||||||
</ul>
|
</ul>
|
||||||
<h3><a name="drivers"></a>Databases Supported</h3>
|
<h3><a name="drivers"></a>Databases Supported</h3>
|
||||||
The <i>name</i> below is the value you pass to NewADOConnection($name) to create a connection object for that database.
|
The <i>name</i> below is the value you pass to NewADOConnection($name) to create a connection object for that database.
|
||||||
@ -1391,20 +1500,24 @@ PEAR::setErrorHandling('PEAR_ERROR_DIE');
|
|||||||
<p>We now support connecting using PEAR style DSN's. A DSN is a connection string
|
<p>We now support connecting using PEAR style DSN's. A DSN is a connection string
|
||||||
of the form:</p>
|
of the form:</p>
|
||||||
<p>$dsn = <i>"$driver://$username:$password@$hostname/$databasename"</i>;</p>
|
<p>$dsn = <i>"$driver://$username:$password@$hostname/$databasename"</i>;</p>
|
||||||
<p>You pass the DSN to the static class function DB::Connect. An example:</p>
|
<p>An example:</p>
|
||||||
<pre> include_once('../adodb/adodb-pear.inc.php');
|
<pre>
|
||||||
$username = 'root';
|
$username = 'root';
|
||||||
$password = '';
|
$password = '';
|
||||||
$hostname = 'localhost';
|
$hostname = 'localhost';
|
||||||
$databasename = 'xphplens';
|
$databasename = 'xphplens';
|
||||||
$driver = 'mysql';
|
$driver = 'mysql';
|
||||||
$dsn = "$driver://$username:$password@$hostname/$databasename";</pre>
|
$dsn = "$driver://$username:$password@$hostname/$databasename"
|
||||||
<pre> $db = DB::Connect($dsn);<br> $rs = $db->query('select firstname,lastname from adoxyz');
|
$db = NewADOConnection();
|
||||||
|
# DB::Connect($dsn) also works if you include 'adodb/adodb-pear.inc.php' at the top
|
||||||
|
$rs = $db->query('select firstname,lastname from adoxyz');
|
||||||
$cnt = 0;
|
$cnt = 0;
|
||||||
while ($arr = $rs->fetchRow()) {
|
while ($arr = $rs->fetchRow()) {
|
||||||
print_r($arr); print "<br>";
|
print_r($arr); print "<br>";
|
||||||
}</pre>
|
}</pre>
|
||||||
<p>This requires PEAR to be installed and in the default include path in php.ini.</p>
|
</p>
|
||||||
|
<p> <a href="#dsnsupport">More info and connection examples</a> on the DSN format.
|
||||||
|
|
||||||
<h2><a name="pear"></a>PEAR Compatibility</h2>
|
<h2><a name="pear"></a>PEAR Compatibility</h2>
|
||||||
We support DSN's (see above), and the following functions:
|
We support DSN's (see above), and the following functions:
|
||||||
<pre>
|
<pre>
|
||||||
@ -1465,7 +1578,7 @@ $<font color="#663300">rs</font> = $<font color="#663300">conn</font>->CacheExec
|
|||||||
</font> <p><font color="#000000">Since ADOdb 2.30, we support the generation of
|
</font> <p><font color="#000000">Since ADOdb 2.30, we support the generation of
|
||||||
SQL to create pivot tables, also known as cross-tabulations. For further explanation
|
SQL to create pivot tables, also known as cross-tabulations. For further explanation
|
||||||
read this DevShed <a href=http://www.devshed.com/Server_Side/MySQL/MySQLWiz/>Cross-Tabulation
|
read this DevShed <a href=http://www.devshed.com/Server_Side/MySQL/MySQLWiz/>Cross-Tabulation
|
||||||
tutorial. We assume that your database supports the SQL case-when expression. </font></p>
|
tutorial</a>. We assume that your database supports the SQL case-when expression. </font></p>
|
||||||
<font color="#000000">
|
<font color="#000000">
|
||||||
<p>In this example, we will use the Northwind database from Microsoft. In the
|
<p>In this example, we will use the Northwind database from Microsoft. In the
|
||||||
database, we have a products table, and we want to analyze this table by <i>suppliers
|
database, we have a products table, and we want to analyze this table by <i>suppliers
|
||||||
@ -1892,9 +2005,30 @@ only with SELECT statements.
|
|||||||
# $rs is now just like any other ADOdb recordset object<br> rs2html($rs);</pre>
|
# $rs is now just like any other ADOdb recordset object<br> rs2html($rs);</pre>
|
||||||
<p>ExecuteCursor() is a helper function that does the following internally:
|
<p>ExecuteCursor() is a helper function that does the following internally:
|
||||||
<pre>
|
<pre>
|
||||||
$stmt = $db->Prepare("BEGIN :RS := SP_FOO(); END;", true);
|
$stmt = $db->Prepare("begin :cursorvar := getdata(:param1); end;", true);
|
||||||
$db->Parameter($stmt, $cur, 'RS', false, -1, OCI_B_CURSOR);
|
$db->Parameter($stmt, $cur, 'cursorvar', false, -1, OCI_B_CURSOR);
|
||||||
$rs = $db->Execute($stmt);</pre>
|
$rs = $db->Execute($stmt,$bindarr);
|
||||||
|
</pre>
|
||||||
|
<p>ExecuteCursor only accepts 1 out parameter. So if you have 2 out parameters, use:
|
||||||
|
<pre>
|
||||||
|
$vv = 'A%';
|
||||||
|
$stmt = $db->PrepareSP("BEGIN list_tabs(:crsr,:tt); END;");
|
||||||
|
$db->OutParameter($stmt, $cur, 'crsr', -1, OCI_B_CURSOR);
|
||||||
|
$db->OutParameter($stmt, $vv, 'tt', 32); # return varchar(32)
|
||||||
|
$arr = $db->GetArray($stmt);
|
||||||
|
print_r($arr);
|
||||||
|
echo " val = $vv"; ## outputs 'TEST'
|
||||||
|
</pre>
|
||||||
|
for the following PL/SQL:
|
||||||
|
<pre>
|
||||||
|
TYPE TabType IS REF CURSOR RETURN TAB%ROWTYPE;
|
||||||
|
|
||||||
|
PROCEDURE list_tabs(tabcursor IN OUT TabType,tablenames IN OUT VARCHAR) IS
|
||||||
|
BEGIN
|
||||||
|
OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames;
|
||||||
|
tablenames := 'TEST';
|
||||||
|
END list_tabs;
|
||||||
|
</pre>
|
||||||
<p><b>SelectLimit<a name="selectlimit"></a>($sql,$numrows=-1,$offset=-1,$inputarr=false)</b></p>
|
<p><b>SelectLimit<a name="selectlimit"></a>($sql,$numrows=-1,$offset=-1,$inputarr=false)</b></p>
|
||||||
<p>Returns a recordset if successful. Returns false otherwise. Performs a select
|
<p>Returns a recordset if successful. Returns false otherwise. Performs a select
|
||||||
statement, simulating PostgreSQL's SELECT statement, LIMIT $numrows OFFSET
|
statement, simulating PostgreSQL's SELECT statement, LIMIT $numrows OFFSET
|
||||||
@ -3144,8 +3278,32 @@ $<font color="#663300">rs</font> = $<font color="#663300">conn</font>->Execute
|
|||||||
PHP</a>. </p>
|
PHP</a>. </p>
|
||||||
</font>
|
</font>
|
||||||
<h2>Change Log<a name="Changes"></a><a name="changes"></a><a name="changelog"></a></h2>
|
<h2>Change Log<a name="Changes"></a><a name="changes"></a><a name="changelog"></a></h2>
|
||||||
|
<p><a name=4.51></a><b>4.51 29 July 2004</b>
|
||||||
|
<p>Added adodb-xmlschema 1.0.2. Thx dan and richard.
|
||||||
|
<p>Added new adorecordset_ext_* classes. If ADOdb extension installed for mysql, mysqlt and oci8
|
||||||
|
(but not oci8po), we use the superfast ADOdb extension code for movenext.
|
||||||
|
<p>Added schema support to mssql and odbc_mssql MetaPrimaryKeys().
|
||||||
|
<p>Patched MSSQL driver to support PHP NULL and Boolean values
|
||||||
|
while binding the input array parameters in the _query() function. By Stephen Farmer.
|
||||||
|
<p>Added support for clob's for mssql, UpdateBlob(). Thx to gfran#directa.com.br
|
||||||
|
<p>Added normalize support for postgresql (true=lowercase table name, or false=case-sensitive table names)
|
||||||
|
to MetaColumns($table, $normalize=true).
|
||||||
|
<p>PHP5 variant dates in ADO not working. Fixed in adodb-ado.inc.php.
|
||||||
|
<p>Constant ADODB_FORCE_NULLS was not working properly for many releases (for GetUpdateSQL). Fixed.
|
||||||
|
Also GetUpdateSQL strips off ORDER BY now - thx Elieser Leão.
|
||||||
|
<p>Perf Monitor for oci8 now dynamically highlights optimizer_* params if too high/low.
|
||||||
|
<p>Added dsn support to NewADOConnection/ADONewConnection.
|
||||||
|
<p>Fixed out of page bounds bug in _adodb_pageexecute_all_rows() Thx to "Sergio Strampelli" sergio#rir.it
|
||||||
|
<p>Speedup of movenext for mysql and oci8 drivers.
|
||||||
|
<p>Moved debugging code _adodb_debug_execute() to adodb-lib.inc.php.
|
||||||
|
<p>Fixed postgresql bytea detection bug. See http://phplens.com/lens/lensforum/msgs.php?id=9849.
|
||||||
|
<p>Fixed ibase datetimestamp typo in PHP5. Thx stefan.
|
||||||
|
<p>Removed whitespace at end of odbtp drivers.
|
||||||
|
<p>Added db2 metaprimarykeys fix.
|
||||||
|
<p>Optimizations to MoveNext() for mysql and oci8. Misc speedups to Get* functions.
|
||||||
<p><a name=4.50></a><b>4.50 6 July 2004</b>
|
<p><a name=4.50></a><b>4.50 6 July 2004</b>
|
||||||
<p>Bumped it to 4.50 to avoid confusion with PHP 4.3.x series.
|
<p>Bumped it to 4.50 to avoid confusion with PHP 4.3.x series.
|
||||||
|
<p>Added db2 metatables and metacolumns extensions.
|
||||||
<p>Added alpha PDO driver. Very buggy, only works with odbc.
|
<p>Added alpha PDO driver. Very buggy, only works with odbc.
|
||||||
<p>Tested mysqli. Set poorAffectedRows = true. Cleaned up movenext() and _fetch().
|
<p>Tested mysqli. Set poorAffectedRows = true. Cleaned up movenext() and _fetch().
|
||||||
<p>PageExecute does not work properly with php5 (return val not a variable). Reported Dmytro Sychevsky sych#php.com.ua. Fixed.
|
<p>PageExecute does not work properly with php5 (return val not a variable). Reported Dmytro Sychevsky sych#php.com.ua. Fixed.
|
||||||
|
@ -1,553 +1,276 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>ADODB Data Dictionary Manual</title>
|
<title>ADODB Data Dictionary Manual</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type"
|
||||||
<style type="text/css">
|
content="text/html; charset=iso-8859-1">
|
||||||
|
<style type="text/css">
|
||||||
body, td {
|
body, td {
|
||||||
/*font-family: Arial, Helvetica, sans-serif;*/
|
/*font-family: Arial, Helvetica, sans-serif;*/
|
||||||
font-size: 11pt;
|
font-size: 11pt;
|
||||||
}
|
}
|
||||||
pre {
|
pre {
|
||||||
font-size: 9pt;
|
font-size: 9pt;
|
||||||
|
background-color: #EEEEEE; padding: .5em; margin: 0px;
|
||||||
}
|
}
|
||||||
.toplink {
|
.toplink {
|
||||||
font-size: 8pt;
|
font-size: 8pt;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="#FFFFFF">
|
<body style="background-color: rgb(255, 255, 255);">
|
||||||
|
|
||||||
<h2>ADOdb Data Dictionary Library for PHP</h2>
|
<h2>ADOdb Data Dictionary Library for PHP</h2>
|
||||||
<p>V4.50 6 July 2004 (c) 2000-2004 John Lim (<a href="mailto:jlim#natsoft.com.my">jlim#natsoft.com.my</a>).<br> AXMLS (c) 2004 ars Cognita, Inc</p>
|
<p>V4.50 6 July 2004 (c) 2000-2004 John Lim (<a
|
||||||
<p><font size="1">This software is dual licensed using BSD-Style and LGPL. This means you can use it in compiled proprietary and commercial products.</font></p>
|
href="mailto:jlim#natsoft.com.my">jlim#natsoft.com.my</a>).<br>
|
||||||
<table border=1><tr><td><font color=red>Kindly note that the ADOdb home page has moved to <a href=http://adodb.sourceforge.net/>http://adodb.sourceforge.net/</a> because of the persistent
|
AXMLS (c) 2004 ars Cognita, Inc</p>
|
||||||
unreliability of http://php.weblogs.com. <b>Please change your links</b>!</font></td></tr></table>
|
<p><font size="1">This software is dual licensed using BSD-Style and
|
||||||
<p>Useful ADOdb links: <a href=http://adodb.sourceforge.net/#download>Download</a> <a href=http://adodb.sourceforge.net/#docs>Other Docs</a>
|
LGPL. This means you can use it in compiled proprietary and commercial
|
||||||
|
products.</font></p>
|
||||||
<p>This documentation describes a PHP class library to automate the creation of tables,
|
<table border="1">
|
||||||
indexes and foreign key constraints portably for multiple databases. Richard Tango-Lowy and Dan Cech
|
<tbody>
|
||||||
have been kind enough to contribute <a href=#xmlschema>AXMLS</a>, an XML schema system for defining databases.</p>
|
<tr>
|
||||||
|
<td><font color="red">Kindly note that the ADOdb home page has
|
||||||
<p>Currently the following databases are supported:</p>
|
moved to <a href="http://adodb.sourceforge.net/">http://adodb.sourceforge.net/</a>
|
||||||
<p>
|
because of the persistent unreliability of http://php.weblogs.com. <b>Please
|
||||||
<b>Well-tested:</b> PostgreSQL, MySQL, Oracle, MSSQL.<br />
|
change your links</b>!</font></td>
|
||||||
<b>Beta-quality:</b> DB2, Informix, Sybase, Interbase, Firebird.<br />
|
</tr>
|
||||||
<b>Alpha-quality:</b> MS Access (does not support DEFAULT values) and generic ODBC.
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<p>Useful ADOdb links: <a href="http://adodb.sourceforge.net/#download">Download</a>
|
||||||
|
<a href="http://adodb.sourceforge.net/#docs">Other Docs</a>
|
||||||
|
</p>
|
||||||
|
<p>This documentation describes a PHP class library to automate the
|
||||||
|
creation of tables, indexes and foreign key constraints portably for
|
||||||
|
multiple databases. Richard Tango-Lowy and Dan Cech have been kind
|
||||||
|
enough to contribute <a href="#xmlschema">AXMLS</a>, an XML schema
|
||||||
|
system for defining databases. You can contact them at
|
||||||
|
dcech#phpwerx.net and richtl#arscognita.com.</p>
|
||||||
|
<p>Currently the following databases are supported:</p>
|
||||||
|
<p> <b>Well-tested:</b> PostgreSQL, MySQL, Oracle, MSSQL.<br>
|
||||||
|
<b>Beta-quality:</b> DB2, Informix, Sybase, Interbase, Firebird.<br>
|
||||||
|
<b>Alpha-quality:</b> MS Access (does not support DEFAULT values) and
|
||||||
|
generic ODBC.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3>Example Usage</h3>
|
<h3>Example Usage</h3>
|
||||||
<pre>
|
<pre> include_once('adodb.inc.php');<br> <font color="#006600"># First create a normal connection</font><br> $db->NewADOConnection('mysql');<br> $db->Connect(...);<br><br> <font
|
||||||
include_once('adodb.inc.php');
|
color="#006600"># Then create a data dictionary object, using this connection</font><br> $dict = <strong>NewDataDictionary</strong>($db);<br><br> <font
|
||||||
<font color="#006600"># First create a normal connection</font>
|
color="#006600"># We have a portable declarative data dictionary format in ADOdb, similar to SQL.<br> # Field types use 1 character codes, and fields are separated by commas.<br> # The following example creates three fields: "col1", "col2" and "col3":</font><br> $flds = " <br> <font
|
||||||
$db->NewADOConnection('mysql');
|
color="#663300"><strong> col1 C(32) NOTNULL DEFAULT 'abc',<br> col2 I DEFAULT 0,<br> col3 N(12.2)</strong></font><br> ";<br><br> <font
|
||||||
$db->Connect(...);
|
color="#006600"># We demonstrate creating tables and indexes</font><br> $sqlarray = $dict-><strong>CreateTableSQL</strong>($tabname, $flds, $taboptarray);<br> $dict-><strong>ExecuteSQLArray</strong>($sqlarray);<br><br> $idxflds = 'co11, col2';<br> $sqlarray = $dict-><strong>CreateIndexSQL</strong>($idxname, $tabname, $idxflds);<br> $dict-><strong>ExecuteSQLArray</strong>($sqlarray);<br></pre>
|
||||||
|
|
||||||
<font color="#006600"># Then create a data dictionary object, using this connection</font>
|
|
||||||
$dict = <strong>NewDataDictionary</strong>($db);
|
|
||||||
|
|
||||||
<font color="#006600"># We have a portable declarative data dictionary format in ADOdb, similar to SQL.
|
|
||||||
# Field types use 1 character codes, and fields are separated by commas.
|
|
||||||
# The following example creates three fields: "col1", "col2" and "col3":</font>
|
|
||||||
$flds = "
|
|
||||||
<font color="#663300"><strong> col1 C(32) NOTNULL DEFAULT 'abc',
|
|
||||||
col2 I DEFAULT 0,
|
|
||||||
col3 N(12.2)</strong></font>
|
|
||||||
";
|
|
||||||
|
|
||||||
<font color="#006600"># We demonstrate creating tables and indexes</font>
|
|
||||||
$sqlarray = $dict-><strong>CreateTableSQL</strong>($tabname, $flds, $taboptarray);
|
|
||||||
$dict-><strong>ExecuteSQLArray</strong>($sqlarray);<br>
|
|
||||||
$idxflds = 'co11, col2';
|
|
||||||
$sqlarray = $dict-><strong>CreateIndexSQL</strong>($idxname, $tabname, $idxflds);
|
|
||||||
$dict-><strong>ExecuteSQLArray</strong>($sqlarray);
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h3>Functions</h3>
|
<h3>Functions</h3>
|
||||||
|
|
||||||
<h4>function CreateDatabase($dbname, $optionsarray=false)</h4>
|
<h4>function CreateDatabase($dbname, $optionsarray=false)</h4>
|
||||||
<p>Create a database with the name $dbname;</p>
|
<p>Create a database with the name $dbname;</p>
|
||||||
|
|
||||||
<h4>function CreateTableSQL($tabname, $fldarray, $taboptarray=false)</h4>
|
<h4>function CreateTableSQL($tabname, $fldarray, $taboptarray=false)</h4>
|
||||||
<pre>
|
<pre> RETURNS: an array of strings, the sql to be executed, or false<br> $tabname: name of table<br> $fldarray: string (or array) containing field info<br> $taboptarray: array containing table options<br></pre>
|
||||||
RETURNS: an array of strings, the sql to be executed, or false
|
<p>The new format of $fldarray uses a free text format, where each
|
||||||
$tabname: name of table
|
field is comma-delimited.
|
||||||
$fldarray: string (or array) containing field info
|
The first token for each field is the field name, followed by the type
|
||||||
$taboptarray: array containing table options
|
and optional
|
||||||
</pre>
|
|
||||||
<p>The new format of $fldarray uses a free text format, where each field is comma-delimited.
|
|
||||||
The first token for each field is the field name, followed by the type and optional
|
|
||||||
field size. Then optional keywords in $otheroptions:</p>
|
field size. Then optional keywords in $otheroptions:</p>
|
||||||
<pre> "$fieldname $type $colsize $otheroptions"</pre>
|
<pre> "$fieldname $type $colsize $otheroptions"</pre>
|
||||||
<p>The older (and still supported) format of $fldarray is a 2-dimensional array, where each row in the 1st dimension represents one field. Each row has this format:</p>
|
<p>The older (and still supported) format of $fldarray is a
|
||||||
|
2-dimensional array, where each row in the 1st dimension represents one
|
||||||
|
field. Each row has this format:</p>
|
||||||
<pre> array($fieldname, $type, [,$colsize] [,$otheroptions]*)</pre>
|
<pre> array($fieldname, $type, [,$colsize] [,$otheroptions]*)</pre>
|
||||||
|
<p>The first 2 fields must be the field name and the field type. The
|
||||||
<p>The first 2 fields must be the field name and the field type. The field type can be a portable type codes or the actual type for that database.</p>
|
field type can be a portable type codes or the actual type for that
|
||||||
|
database.</p>
|
||||||
<p>Legal portable type codes include:</p>
|
<p>Legal portable type codes include:</p>
|
||||||
<pre>
|
<pre> C: varchar<br> X: Largest varchar size <br> XL: For Oracle, returns CLOB, otherwise same as 'X' above<br><br> C2: Multibyte varchar<br> X2: Multibyte varchar (largest size)<br><br> B: BLOB (binary large object)<br><br> D: Date (some databases do not support this, and we return a datetime type)<br> T: Datetime or Timestamp<br> L: Integer field suitable for storing booleans (0 or 1)<br> I: Integer (mapped to I4)<br> I1: 1-byte integer<br> I2: 2-byte integer<br> I4: 4-byte integer<br> I8: 8-byte integer<br> F: Floating point number<br> N: Numeric or decimal number<br></pre>
|
||||||
C: varchar
|
<p>The $colsize field represents the size of the field. If a decimal
|
||||||
X: Largest varchar size
|
number is used, then it is assumed that the number following the dot is
|
||||||
XL: For Oracle, returns CLOB, otherwise same as 'X' above
|
the precision, so 6.2 means a number of size 6 digits and 2 decimal
|
||||||
|
places. It is recommended that the default for number types be
|
||||||
C2: Multibyte varchar
|
represented as a string to avoid any rounding errors.</p>
|
||||||
X2: Multibyte varchar (largest size)
|
|
||||||
|
|
||||||
B: BLOB (binary large object)
|
|
||||||
|
|
||||||
D: Date (some databases do not support this, and we return a datetime type)
|
|
||||||
T: Datetime or Timestamp
|
|
||||||
L: Integer field suitable for storing booleans (0 or 1)
|
|
||||||
I: Integer (mapped to I4)
|
|
||||||
I1: 1-byte integer
|
|
||||||
I2: 2-byte integer
|
|
||||||
I4: 4-byte integer
|
|
||||||
I8: 8-byte integer
|
|
||||||
F: Floating point number
|
|
||||||
N: Numeric or decimal number
|
|
||||||
</pre>
|
|
||||||
<p>The $colsize field represents the size of the field. If a decimal number is used, then it is assumed that the number following the dot is the precision, so 6.2 means a number of size 6 digits and 2 decimal places. It is recommended that the default for number types be represented as a string to avoid any rounding errors.</p>
|
|
||||||
<p>The $otheroptions include the following keywords (case-insensitive):</p>
|
<p>The $otheroptions include the following keywords (case-insensitive):</p>
|
||||||
<pre>
|
<pre> AUTO For autoincrement number. Emulated with triggers if not available.<br> Sets NOTNULL also.<br> AUTOINCREMENT Same as auto.<br> KEY Primary key field. Sets NOTNULL also. Compound keys are supported.<br> PRIMARY Same as KEY.<br> DEF Synonym for DEFAULT for lazy typists.<br> DEFAULT The default value. Character strings are auto-quoted unless<br> the string begins and ends with spaces, eg ' SYSDATE '.<br> NOTNULL If field is not null.<br> DEFDATE Set default value to call function to get today's date.<br> DEFTIMESTAMP Set default to call function to get today's datetime.<br> NOQUOTE Prevents autoquoting of default string values.<br> CONSTRAINTS Additional constraints defined at the end of the field<br> definition.<br></pre>
|
||||||
AUTO For autoincrement number. Emulated with triggers if not available.
|
<p>The Data Dictonary accepts two formats, the older array
|
||||||
Sets NOTNULL also.
|
specification:</p>
|
||||||
AUTOINCREMENT Same as auto.
|
<pre> $flds = array(<br> array('COLNAME', 'DECIMAL', '8.4', 'DEFAULT' => 0, 'NOTNULL'),<br> array('id', 'I' , 'AUTO'),<br> array('`MY DATE`', 'D' , 'DEFDATE'),<br> array('NAME', 'C' , '32', 'CONSTRAINTS' => 'FOREIGN KEY REFERENCES reftable')<br> );<br></pre>
|
||||||
KEY Primary key field. Sets NOTNULL also. Compound keys are supported.
|
|
||||||
PRIMARY Same as KEY.
|
|
||||||
DEF Synonym for DEFAULT for lazy typists.
|
|
||||||
DEFAULT The default value. Character strings are auto-quoted unless
|
|
||||||
the string begins and ends with spaces, eg ' SYSDATE '.
|
|
||||||
NOTNULL If field is not null.
|
|
||||||
DEFDATE Set default value to call function to get today's date.
|
|
||||||
DEFTIMESTAMP Set default to call function to get today's datetime.
|
|
||||||
NOQUOTE Prevents autoquoting of default string values.
|
|
||||||
CONSTRAINTS Additional constraints defined at the end of the field
|
|
||||||
definition.
|
|
||||||
</pre>
|
|
||||||
<p>The Data Dictonary accepts two formats, the older array specification:</p>
|
|
||||||
<pre>
|
|
||||||
$flds = array(
|
|
||||||
array('COLNAME', 'DECIMAL', '8.4', 'DEFAULT' => 0, 'NOTNULL'),
|
|
||||||
array('id', 'I' , 'AUTO'),
|
|
||||||
array('`MY DATE`', 'D' , 'DEFDATE'),
|
|
||||||
array('NAME', 'C' , '32', 'CONSTRAINTS' => 'FOREIGN KEY REFERENCES reftable')
|
|
||||||
);
|
|
||||||
</pre>
|
|
||||||
<p>Or the simpler declarative format:</p>
|
<p>Or the simpler declarative format:</p>
|
||||||
<pre>
|
<pre> $flds = "<font color="#660000"><strong><br> COLNAME DECIMAL(8.4) DEFAULT 0 NOTNULL,<br> id I AUTO,<br> `MY DATE` D DEFDATE,<br> NAME C(32) CONSTRAINTS 'FOREIGN KEY REFERENCES reftable'</strong></font><br> ";<br></pre>
|
||||||
$flds = "<font color="#660000"><strong>
|
<p>Note that if you have special characters in the field name (e.g. My
|
||||||
COLNAME DECIMAL(8.4) DEFAULT 0 NOTNULL,
|
Date), you should enclose it in back-quotes. Normally field names are
|
||||||
id I AUTO,
|
not case-sensitive, but if you enclose it in back-quotes, some
|
||||||
`MY DATE` D DEFDATE,
|
databases will treat the names as case-sensitive (eg. Oracle) , and
|
||||||
NAME C(32) CONSTRAINTS 'FOREIGN KEY REFERENCES reftable'</strong></font>
|
others won't. So be careful.</p>
|
||||||
";
|
<p>The $taboptarray is the 3rd parameter of the CreateTableSQL
|
||||||
</pre>
|
function. This contains table specific settings. Legal keywords include:</p>
|
||||||
<p>Note that if you have special characters in the field name (e.g. My Date), you should enclose it in back-quotes. Normally field names are not case-sensitive, but if you enclose it in back-quotes, some databases will treat the names as case-sensitive (eg. Oracle) , and others won't. So be careful.</p>
|
|
||||||
|
|
||||||
<p>The $taboptarray is the 3rd parameter of the CreateTableSQL function. This contains table specific settings. Legal keywords include:</p>
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><b>REPLACE</b><br />
|
<li><b>REPLACE</b><br>
|
||||||
Indicates that the previous table definition should be removed (dropped)together with ALL data. See first example below.
|
Indicates that the previous table definition should be removed
|
||||||
</li>
|
(dropped)together with ALL data. See first example below. </li>
|
||||||
<li><b>DROP</b><br />
|
<li><b>DROP</b><br>
|
||||||
Drop table. Useful for removing unused tables.
|
Drop table. Useful for removing unused tables. </li>
|
||||||
</li>
|
<li><b>CONSTRAINTS</b><br>
|
||||||
<li><b>CONSTRAINTS</b><br />
|
Define this as the key, with the constraint as the value. See the
|
||||||
Define this as the key, with the constraint as the value. See the postgresql example below.
|
postgresql example below. Additional constraints defined for the whole
|
||||||
Additional constraints defined for the whole table. You will probably need to prefix this with a comma.
|
table. You will probably need to prefix this with a comma. </li>
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
|
<p>Database specific table options can be defined also using the name
|
||||||
<p>Database specific table options can be defined also using the name of the database type as the array key. In the following example, <em>create the table as ISAM with MySQL, and store the table in the "users" tablespace if using Oracle</em>. And because we specified REPLACE, drop the table first.</p>
|
of the database type as the array key. In the following example, <em>create
|
||||||
<pre> $taboptarray = array('mysql' => 'TYPE=ISAM', 'oci8' => 'tablespace users', 'REPLACE');</pre>
|
the table as ISAM with MySQL, and store the table in the "users"
|
||||||
|
tablespace if using Oracle</em>. And because we specified REPLACE, drop
|
||||||
<p>You can also define foreignkey constraints. The following is syntax for postgresql:
|
the table first.</p>
|
||||||
<pre> $taboptarray = array('constraints' => ', FOREIGN KEY (col1) REFERENCES reftable (refcol)');</pre>
|
<pre> $taboptarray = array('mysql' => 'TYPE=ISAM', 'oci8' => 'tablespace users', 'REPLACE');</pre>
|
||||||
|
<p>You can also define foreignkey constraints. The following is syntax
|
||||||
|
for postgresql:
|
||||||
|
</p>
|
||||||
|
<pre> $taboptarray = array('constraints' => ', FOREIGN KEY (col1) REFERENCES reftable (refcol)');</pre>
|
||||||
<h4>function DropTableSQL($tabname)</h4>
|
<h4>function DropTableSQL($tabname)</h4>
|
||||||
<p>Returns the SQL to drop the specified table.</p>
|
<p>Returns the SQL to drop the specified table.</p>
|
||||||
|
|
||||||
<h4>function ChangeTableSQL($tabname, $flds)</h4>
|
<h4>function ChangeTableSQL($tabname, $flds)</h4>
|
||||||
<p>Checks to see if table exists, if table does not exist, behaves like CreateTableSQL.
|
<p>Checks to see if table exists, if table does not exist, behaves like
|
||||||
If table exists, generates appropriate ALTER TABLE MODIFY COLUMN commands if
|
CreateTableSQL. If table exists, generates appropriate ALTER TABLE
|
||||||
field already exists, or ALTER TABLE ADD $column if field does not exist.</p>
|
MODIFY COLUMN commands if field already exists, or ALTER TABLE ADD
|
||||||
<p>The class must be connected to the database for ChangeTableSQL to detect the
|
$column if field does not exist.</p>
|
||||||
existence of the table. Idea and code contributed by Florian Buzin.</p>
|
<p>The class must be connected to the database for ChangeTableSQL to
|
||||||
|
detect the existence of the table. Idea and code contributed by Florian
|
||||||
<h4>function CreateIndexSQL($idxname, $tabname, $flds, $idxoptarray=false)</h4>
|
Buzin.</p>
|
||||||
<pre>
|
<h4>function CreateIndexSQL($idxname, $tabname, $flds,
|
||||||
RETURNS: an array of strings, the sql to be executed, or false
|
$idxoptarray=false)</h4>
|
||||||
$idxname: name of index
|
<pre> RETURNS: an array of strings, the sql to be executed, or false<br> $idxname: name of index<br> $tabname: name of table<br> $flds: list of fields as a comma delimited string or an array of strings<br> $idxoptarray: array of index creation options<br></pre>
|
||||||
$tabname: name of table
|
<p>$idxoptarray is similar to $taboptarray in that index specific
|
||||||
$flds: list of fields as a comma delimited string or an array of strings
|
information can be embedded in the array. Other options include:</p>
|
||||||
$idxoptarray: array of index creation options
|
<pre> CLUSTERED Create clustered index (only mssql)<br> BITMAP Create bitmap index (only oci8)<br> UNIQUE Make unique index<br> FULLTEXT Make fulltext index (only mysql)<br> HASH Create hash index (only postgres)<br> DROP Drop legacy index<br></pre>
|
||||||
</pre>
|
|
||||||
<p>$idxoptarray is similar to $taboptarray in that index specific information can be embedded in the array. Other options include:</p>
|
|
||||||
<pre>
|
|
||||||
CLUSTERED Create clustered index (only mssql)
|
|
||||||
BITMAP Create bitmap index (only oci8)
|
|
||||||
UNIQUE Make unique index
|
|
||||||
FULLTEXT Make fulltext index (only mysql)
|
|
||||||
HASH Create hash index (only postgres)
|
|
||||||
DROP Drop legacy index
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h4>function DropIndexSQL ($idxname, $tabname = NULL)</h4>
|
<h4>function DropIndexSQL ($idxname, $tabname = NULL)</h4>
|
||||||
<p>Returns the SQL to drop the specified index.</p>
|
<p>Returns the SQL to drop the specified index.</p>
|
||||||
|
|
||||||
<h4>function AddColumnSQL($tabname, $flds)</h4>
|
<h4>function AddColumnSQL($tabname, $flds)</h4>
|
||||||
<p>Add one or more columns. Not guaranteed to work under all situations.</p>
|
<p>Add one or more columns. Not guaranteed to work under all situations.</p>
|
||||||
|
|
||||||
<h4>function AlterColumnSQL($tabname, $flds)</h4>
|
<h4>function AlterColumnSQL($tabname, $flds)</h4>
|
||||||
<p>Warning, not all databases support this feature.</p>
|
<p>Warning, not all databases support this feature.</p>
|
||||||
|
|
||||||
<h4>function DropColumnSQL($tabname, $flds)</h4>
|
<h4>function DropColumnSQL($tabname, $flds)</h4>
|
||||||
<p>Drop 1 or more columns.</p>
|
<p>Drop 1 or more columns.</p>
|
||||||
|
|
||||||
<h4>function SetSchema($schema)</h4>
|
<h4>function SetSchema($schema)</h4>
|
||||||
<p>Set the schema.</p>
|
<p>Set the schema.</p>
|
||||||
|
|
||||||
<h4>function &MetaTables()</h4>
|
<h4>function &MetaTables()</h4>
|
||||||
<h4>function &MetaColumns($tab, $upper=true, $schema=false)</h4>
|
<h4>function &MetaColumns($tab, $upper=true, $schema=false)</h4>
|
||||||
<h4>function &MetaPrimaryKeys($tab,$owner=false,$intkey=false)</h4>
|
<h4>function &MetaPrimaryKeys($tab,$owner=false,$intkey=false)</h4>
|
||||||
<h4>function &MetaIndexes($table, $primary = false, $owner = false)</h4>
|
<h4>function &MetaIndexes($table, $primary = false, $owner = false)</h4>
|
||||||
<p>These functions are wrappers for the corresponding functions in the connection object. However, the table names will be autoquoted by the TableName function (see below) before being passed to the connection object.</p>
|
<p>These functions are wrappers for the corresponding functions in the
|
||||||
|
connection object. However, the table names will be autoquoted by the
|
||||||
|
TableName function (see below) before being passed to the connection
|
||||||
|
object.</p>
|
||||||
<h4>function NameQuote($name = NULL)</h4>
|
<h4>function NameQuote($name = NULL)</h4>
|
||||||
<p>If the provided name is quoted with backquotes (`) or contains special characters, returns the name quoted with the appropriate quote character, otherwise the name is returned unchanged.</p>
|
<p>If the provided name is quoted with backquotes (`) or contains
|
||||||
|
special characters, returns the name quoted with the appropriate quote
|
||||||
|
character, otherwise the name is returned unchanged.</p>
|
||||||
<h4>function TableName($name)</h4>
|
<h4>function TableName($name)</h4>
|
||||||
<p>The same as NameQuote, but will prepend the current schema if specified</p>
|
<p>The same as NameQuote, but will prepend the current schema if
|
||||||
|
specified</p>
|
||||||
<h4>function MetaType($t,$len=-1,$fieldobj=false)</h4>
|
<h4>function MetaType($t,$len=-1,$fieldobj=false)</h4>
|
||||||
<h4>function ActualType($meta)</h4>
|
<h4>function ActualType($meta)</h4>
|
||||||
<p>Convert between database-independent 'Meta' and database-specific 'Actual' type codes.</p>
|
<p>Convert between database-independent 'Meta' and database-specific
|
||||||
|
'Actual' type codes.</p>
|
||||||
<h4>function ExecuteSQLArray($sqlarray, $contOnError = true)</h4>
|
<h4>function ExecuteSQLArray($sqlarray, $contOnError = true)</h4>
|
||||||
<pre>
|
<pre> RETURNS: 0 if failed, 1 if executed all but with errors, 2 if executed successfully<br> $sqlarray: an array of strings with sql code (no semicolon at the end of string)<br> $contOnError: if true, then continue executing even if error occurs<br></pre>
|
||||||
RETURNS: 0 if failed, 1 if executed all but with errors, 2 if executed successfully
|
<p>Executes an array of SQL strings returned by CreateTableSQL or
|
||||||
$sqlarray: an array of strings with sql code (no semicolon at the end of string)
|
CreateIndexSQL.</p>
|
||||||
$contOnError: if true, then continue executing even if error occurs
|
<hr>
|
||||||
</pre>
|
<a name="xmlschema"></a>
|
||||||
<p>Executes an array of SQL strings returned by CreateTableSQL or CreateIndexSQL.</p>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
<a name=xmlschema></a>
|
|
||||||
<h2>ADOdb XML Schema (AXMLS)</h2>
|
<h2>ADOdb XML Schema (AXMLS)</h2>
|
||||||
<p>This is a class contributed by Richard Tango-Lowy and Dan Cech that allows the user to quickly
|
<p>This is a class contributed by Richard Tango-Lowy and Dan Cech that
|
||||||
and easily build a database using the excellent ADODB database library and a simple XML formatted file.
|
allows the user to quickly
|
||||||
You can <a href=http://sourceforge.net/projects/adodb-xmlschema/>download the latest version of AXMLS here</a>.</p>
|
and easily build a database using the excellent ADODB database library
|
||||||
|
and a simple XML formatted file.
|
||||||
|
You can <a href="http://sourceforge.net/projects/adodb-xmlschema/">download
|
||||||
|
the latest version of AXMLS here</a>.</p>
|
||||||
<h3>Quick Start</h3>
|
<h3>Quick Start</h3>
|
||||||
<p>First, create an XML database schema. Let's call it "schema.xml:"</p>
|
<p>Adodb-xmlschema, or AXMLS, is a set of classes that allow the user
|
||||||
<pre>
|
to quickly and easily build or upgrade a database on almost any RDBMS
|
||||||
<?xml version="1.0"?>
|
using the excellent ADOdb database library and a simple XML formatted
|
||||||
<schema version="0.2">
|
schema file. Our goal is to give developers a tool that's simple to
|
||||||
<table name="mytable">
|
use, but that will allow them to create a single file that can build,
|
||||||
<field name="row1" type="I">
|
upgrade, and manipulate databases on most RDBMS platforms.</p>
|
||||||
<descr>An integer row that's a primary key and autoincrements</descr>
|
<span style="font-weight: bold;"> Installing axmls</span>
|
||||||
<KEY/>
|
<p>The easiest way to install AXMLS to download and install any recent
|
||||||
<AUTOINCREMENT/>
|
version of the ADOdb database abstraction library. To install AXMLS
|
||||||
</field>
|
manually, simply copy the adodb-xmlschema.inc.php file and the xsl
|
||||||
<field name="row2" type="C" size="16">
|
directory into your adodb directory.</p>
|
||||||
<descr>A 16 character varchar row that can't be null</descr>
|
<span style="font-weight: bold;"> Using AXMLS in Your Application</span>
|
||||||
<NOTNULL/>
|
<p>There are two steps involved in using AXMLS in your application:
|
||||||
</field>
|
first, you must create a schema, or XML representation of your
|
||||||
<index name="myindex">
|
database, and second, you must create the PHP code that will parse and
|
||||||
<col>row1</col>
|
execute the schema.</p>
|
||||||
<col>row2</col>
|
<p>Let's begin with a schema that describes a typical, if simplistic
|
||||||
</index>
|
user management table for an application.</p>
|
||||||
</table>
|
<pre class="listing"><pre><?xml version="1.0"?><br><schema version="0.2"><br><br> <table name="users"><br> <desc>A typical users table for our application.</desc><br> <field name="userId" type="I"><br> <descr>A unique ID assigned to each user.</descr><br><br> <KEY/><br> <AUTOINCREMENT/><br> </field><br> <br> <field name="userName" type="C" size="16"><NOTNULL/></field><br><br> <br> <index name="userName"><br> <descr>Put a unique index on the user name</descr><br> <col>userName</col><br> <UNIQUE/><br><br> </index><br> </table><br> <br> <sql><br> <descr>Insert some data into the users table.</descr><br> <query>insert into users (userName) values ( 'admin' )</query><br><br> <query>insert into users (userName) values ( 'Joe' )</query><br> </sql><br></schema> <br></pre></pre>
|
||||||
<sql>
|
<p>Let's take a detailed look at this schema.</p>
|
||||||
<descr>SQL to be executed only on specific platforms</descr>
|
<p>The opening <?xml version="1.0"?> tag is required by XML. The
|
||||||
<query platform="postgres|postgres7">
|
<schema> tag tells the parser that the enclosed markup defines an
|
||||||
insert into mytable ( row1, row2 ) values ( 12, 'stuff' )
|
XML schema. The version="0.2" attribute sets <em>the version of the
|
||||||
</query>
|
AXMLS DTD used by the XML schema.</em> </p>
|
||||||
<query platform="mysql">
|
<p>All versions of AXMLS prior to version 1.0 have a schema version of
|
||||||
insert into mytable ( row1, row2 ) values ( 12, 'different stuff' )
|
"0.1". The current schema version is "0.2".</p>
|
||||||
</query>
|
<pre class="listing"><pre><?xml version="1.0"?><br><schema version="0.2"><br> ...<br></schema><br></pre></pre>
|
||||||
</sql>
|
<p>Next we define one or more tables. A table consists of a fields (and
|
||||||
</schema>
|
other objects) enclosed by <table> tags. The name="" attribute
|
||||||
</pre>
|
specifies the name of the table that will be created in the database.</p>
|
||||||
|
<pre class="listing"><pre><table name="users"><br><br> <desc>A typical users table for our application.</desc><br> <field name="userId" type="I"><br><br> <descr>A unique ID assigned to each user.</descr><br> <KEY/><br> <AUTOINCREMENT/><br> </field><br> <br> <field name="userName" type="C" size="16"><NOTNULL/></field><br><br> <br></table><br></pre></pre>
|
||||||
<p>Create a new database using the appropriate tool for your platform.<br />
|
<p>This table is called "users" and has a description and two fields.
|
||||||
Executing the following PHP code will create the a <i>mytable</i> and <i>myindex</i>
|
The description is optional, and is currently only for your own
|
||||||
in the database and insert one row into <i>mytable</i> if the platform is postgres or mysql.</p>
|
information; it is not applied to the database.</p>
|
||||||
|
<p>The first <field> tag will create a field named "userId" of
|
||||||
<pre>
|
type "I", or integer. (See the ADOdb Data Dictionary documentation for
|
||||||
include_once('/path/to/adodb.inc.php');
|
a list of valid types.) This <field> tag encloses two special
|
||||||
include_once('/path/to/adodb-xmlschema.inc.php');
|
field options: <KEY/>, which specifies this field as a primary
|
||||||
|
key, and <AUTOINCREMENT/>, which specifies that the database
|
||||||
<font color="#006600">// To build the schema, start by creating a normal ADOdb connection:</font>
|
engine should automatically fill this field with the next available
|
||||||
$db->NewADOConnection( 'mysql' );
|
value when a new row is inserted.</p>
|
||||||
$db->Connect( ... );
|
<p>The second <field> tag will create a field named "userName" of
|
||||||
|
type "C", or character, and of length 16 characters. The
|
||||||
<font color="#006600">// Create the schema object and build the query array.</font>
|
<NOTNULL/> option specifies that this field does not allow NULLs.</p>
|
||||||
$schema = new <b>adoSchema</b>( $db );
|
<p>There are two ways to add indexes to a table. The simplest is to
|
||||||
|
mark a field with the <KEY/> option as described above; a primary
|
||||||
<font color="#006600">// Optionally, set a prefix for newly-created tables. In this example
|
key is a unique index. The second and more powerful method uses the
|
||||||
// the prefix "myprefix_" will result in a table named "myprefix_tablename".</font>
|
<index> tags.</p>
|
||||||
$schema-><b>SetPrefix</b>( 'myprefix_' );
|
<pre class="listing"><pre><table name="users"><br> ...<br> <br> <index name="userName"><br> <descr>Put a unique index on the user name</descr><br> <col>userName</col><br><br> <UNIQUE/><br> </index><br> <br></table><br></pre></pre>
|
||||||
|
<p>The <index> tag specifies that an index should be created on
|
||||||
<font color="#006600">// Build the SQL array</font>
|
the enclosing table. The name="" attribute provides the name of the
|
||||||
$schema-><b>ParseSchema</b>( 'schema.xml' );
|
index that will be created in the database. The description, as above,
|
||||||
|
is for your information only. The <col> tags list each column
|
||||||
<font color="#006600">// Execute the SQL on the database</font>
|
that will be included in the index. Finally, the <UNIQUE/> tag
|
||||||
$result = $schema-><b>ExecuteSchema</b>();
|
specifies that this will be created as a unique index.</p>
|
||||||
|
<p>Finally, AXMLS allows you to include arbitrary SQL that will be
|
||||||
<font color="#006600">// Finally, clean up after the XML parser
|
applied to the database when the schema is executed.</p>
|
||||||
// (PHP won't do this for you!)</font>
|
<pre class="listing"><pre><sql><br> <descr>Insert some data into the users table.</descr><br> <query>insert into users (userName) values ( 'admin' )</query><br><br> <query>insert into users (userName) values ( 'Joe' )</query><br></sql><br></pre></pre>
|
||||||
$schema-><b>Destroy</b>();
|
<p>The <sql> tag encloses any number of SQL queries that you
|
||||||
</pre>
|
define for your own use.</p>
|
||||||
|
<p>Now that we've defined an XML schema, you need to know how to apply
|
||||||
|
it to your database. Here's a simple PHP script that shows how to load
|
||||||
<h3>Using AXMLS in Your
|
the schema.</p>
|
||||||
Application</h3>
|
<pre class="listing"><pre><?PHP<br>/* You must tell the script where to find the ADOdb and<br> * the AXMLS libraries.<br> */<br>require( "path_to_adodb/adodb.inc.php");<br>require( "path_to_adodb/adodb-xmlschema.inc.php" );<br><br>/* Configuration information. Define the schema filename,<br> * RDBMS platform (see the ADODB documentation for valid<br> * platform names), and database connection information here.<br> */<br>$schemaFile = 'example.xml';<br>$platform = 'mysql';<br>$dbHost = 'localhost';<br>$dbName = 'database';<br>$dbUser = 'username';<br>$dbPassword = 'password';<br><br>/* Start by creating a normal ADODB connection.<br> */<br>$db = ADONewConnection( $platform );<br>$db->Connect( $dbHost, $dbUser, $dbPassword, $dbName );<br><br>/* Use the database connection to create a new adoSchema object.<br> */<br>$schema = new adoSchema( $db );<br><br>/* Call ParseSchema() to build SQL from the XML schema file.<br> * Then call ExecuteSchema() to apply the resulting SQL to <br> * the database.<br> */<br>$sql = $schema->ParseSchema( $schemaFile );<br>$result = $schema->ExecuteSchema();<br>?><br></pre></pre>
|
||||||
|
<p>Let's look at each part of the example in turn. After you manually
|
||||||
<p>
|
create the database, there are three steps required to load (or
|
||||||
There are two steps involved in using
|
upgrade) your schema.</p>
|
||||||
AXMLS in your application: first,
|
<p>First, create a normal ADOdb connection. The variables and values
|
||||||
you must create a schema, or XML representation of your
|
here should be those required to connect to your database.</p>
|
||||||
database, and second, you must create the PHP code that will
|
<pre class="listing"><pre>$db = ADONewConnection( 'mysql' );<br>$db->Connect( 'host', 'user', 'password', 'database' );<br></pre></pre>
|
||||||
parse and execute the schema.</p>
|
<p>Second, create the adoSchema object that load and manipulate your
|
||||||
<p>Let's begin with a schema that describes a typical, if simplistic
|
schema. You must pass an ADOdb database connection object in order to
|
||||||
user management table for an application.</p>
|
create the adoSchema object.</p>
|
||||||
<pre class="listing"><pre>
|
<pre class="listing"><pre>$schema = new adoSchema( $db );<br></pre></pre>
|
||||||
<?xml version="1.0"?>
|
<p>Third, call ParseSchema() to parse the schema and then
|
||||||
<schema version="0.2">
|
ExecuteSchema() to apply it to the database. You must pass
|
||||||
|
ParseSchema() the path and filename of your schema file.</p>
|
||||||
<table name="users">
|
<pre class="listing"><pre><br>$schema->ParseSchema( $schemaFile ); <br>$schema->ExecuteSchema(); <br></pre></pre>
|
||||||
<desc>A typical users table for our application.</desc>
|
<p>Execute the above code and then log into your database. If you've
|
||||||
<field name="userId" type="I">
|
done all this right, you should see your tables, indexes, and SQL.</p>
|
||||||
<descr>A unique ID assigned to each user.</descr>
|
<p>You can find the source files for this tutorial in the examples
|
||||||
<KEY/>
|
directory as tutorial_shema.xml and tutorial.php. See the class
|
||||||
<AUTOINCREMENT/>
|
documentation for a more detailed description of the adoSchema methods,
|
||||||
</field>
|
including methods and schema elements that are not described in this
|
||||||
|
tutorial.</p>
|
||||||
<field name="userName" type="C" size="16"><NOTNULL/></field>
|
|
||||||
|
|
||||||
<index name="userName">
|
|
||||||
<descr>Put a unique index on the user name</descr>
|
|
||||||
<col>userName</col>
|
|
||||||
<UNIQUE/>
|
|
||||||
</index>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<sql>
|
|
||||||
<descr>Insert some data into the users table.</descr>
|
|
||||||
<query>insert into users (userName) values ( 'admin' )</query>
|
|
||||||
<query>insert into users (userName) values ( 'Joe' )</query>
|
|
||||||
</sql>
|
|
||||||
</schema>
|
|
||||||
</pre></pre>
|
|
||||||
<p>Let's take a detailed look at this schema.</p>
|
|
||||||
<p>The opening <?xml version="1.0"?> tag is
|
|
||||||
required by XML. The <schema> tag
|
|
||||||
tells the parser that the enclosed markup defines an XML
|
|
||||||
schema. The version="0.2" attribute sets
|
|
||||||
<em>the version of the AXMLS DTD used by the XML
|
|
||||||
schema.</em> <p>All versions of AXMLS prior
|
|
||||||
to version 1.0 have a schema version of "0.1". The current
|
|
||||||
schema version is "0.2".</p></p>
|
|
||||||
<pre class="listing"><pre>
|
|
||||||
<?xml version="1.0"?>
|
|
||||||
<schema version="0.2">
|
|
||||||
...
|
|
||||||
</schema>
|
|
||||||
</pre></pre>
|
|
||||||
<p>Next we define one or more tables. A table consists of a
|
|
||||||
fields (and other objects) enclosed by
|
|
||||||
<table> tags. The
|
|
||||||
name="" attribute specifies the name of
|
|
||||||
the table that will be created in the database.</p>
|
|
||||||
<pre class="listing"><pre>
|
|
||||||
<table name="users">
|
|
||||||
|
|
||||||
<desc>A typical users table for our application.</desc>
|
|
||||||
<field name="userId" type="I">
|
|
||||||
<descr>A unique ID assigned to each user.</descr>
|
|
||||||
<KEY/>
|
|
||||||
<AUTOINCREMENT/>
|
|
||||||
</field>
|
|
||||||
|
|
||||||
<field name="userName" type="C" size="16"><NOTNULL/></field>
|
|
||||||
|
|
||||||
</table>
|
|
||||||
</pre></pre>
|
|
||||||
<p>This table is called "users" and has a description and
|
|
||||||
two fields. The description is optional, and is currently
|
|
||||||
only for your own information; it is not applied to the
|
|
||||||
database.</p>
|
|
||||||
<p>The first <field> tag will create
|
|
||||||
a field named "userId" of type "I", or integer. (See the
|
|
||||||
ADOdb Data Dictionary
|
|
||||||
documentation for a list of valid types.) This
|
|
||||||
<field> tag encloses two special
|
|
||||||
field options: <KEY/>, which
|
|
||||||
specifies this field as a primary key, and
|
|
||||||
<AUTOINCREMENT/>, which specifies
|
|
||||||
that the database engine should automatically fill this
|
|
||||||
field with the next available value when a new row is
|
|
||||||
inserted.</p>
|
|
||||||
<p>The second <field> tag will create
|
|
||||||
a field named "userName" of type "C", or character, and of
|
|
||||||
length 16 characters. The <NOTNULL/>
|
|
||||||
option specifies that this field does not allow
|
|
||||||
NULLs.</p>
|
|
||||||
<p>There are two ways to add indexes to a table. The
|
|
||||||
simplest is to mark a field with the
|
|
||||||
<KEY/> option as described above; a
|
|
||||||
primary key is a unique index. The second and more powerful
|
|
||||||
method uses the <index> tags.</p>
|
|
||||||
<pre class="listing"><pre>
|
|
||||||
<table name="users">
|
|
||||||
...
|
|
||||||
|
|
||||||
<index name="userName">
|
|
||||||
<descr>Put a unique index on the user name</descr>
|
|
||||||
<col>userName</col>
|
|
||||||
<UNIQUE/>
|
|
||||||
</index>
|
|
||||||
|
|
||||||
</table>
|
|
||||||
</pre></pre>
|
|
||||||
<p>The <index> tag specifies that an
|
|
||||||
index should be created on the enclosing table. The
|
|
||||||
name="" attribute provides the name of the
|
|
||||||
index that will be created in the database. The
|
|
||||||
description, as above, is for your information only. The
|
|
||||||
<col> tags list each column that
|
|
||||||
will be included in the index. Finally, the
|
|
||||||
<UNIQUE/> tag specifies that this
|
|
||||||
will be created as a unique index.</p>
|
|
||||||
<p>Finally, AXMLS allows you to include arbitrary SQL that
|
|
||||||
will be applied to the database when the schema is
|
|
||||||
executed.</p>
|
|
||||||
<pre class="listing"><pre>
|
|
||||||
<sql>
|
|
||||||
<descr>Insert some data into the users table.</descr>
|
|
||||||
<query>insert into users (userName) values ( 'admin' )</query>
|
|
||||||
<query>insert into users (userName) values ( 'Joe' )</query>
|
|
||||||
</sql>
|
|
||||||
</pre></pre>
|
|
||||||
<p>The <sql> tag encloses any number
|
|
||||||
of SQL queries that you define for your own use.</p>
|
|
||||||
<p>Now that we've defined an XML schema, you need to know how to
|
|
||||||
apply it to your database. Here's a simple PHP script that shows
|
|
||||||
how to load the schema.</p>
|
|
||||||
<p><pre class="listing"><pre>
|
|
||||||
<?PHP
|
|
||||||
/* You must tell the script where to find the ADOdb and
|
|
||||||
* the AXMLS libraries.
|
|
||||||
*/
|
|
||||||
require( "path_to_adodb/adodb.inc.php");
|
|
||||||
require( "path_to_adodb/adodb-xmlschema.inc.php" );
|
|
||||||
|
|
||||||
/* Configuration information. Define the schema filename,
|
|
||||||
* RDBMS platform (see the ADODB documentation for valid
|
|
||||||
* platform names), and database connection information here.
|
|
||||||
*/
|
|
||||||
$schemaFile = 'example.xml';
|
|
||||||
$platform = 'mysql';
|
|
||||||
$dbHost = 'localhost';
|
|
||||||
$dbName = 'database';
|
|
||||||
$dbUser = 'username';
|
|
||||||
$dbPassword = 'password';
|
|
||||||
|
|
||||||
/* Start by creating a normal ADODB connection.
|
|
||||||
*/
|
|
||||||
$db = ADONewConnection( $platform );
|
|
||||||
$db->Connect( $dbHost, $dbUser, $dbPassword, $dbName );
|
|
||||||
|
|
||||||
/* Use the database connection to create a new adoSchema object.
|
|
||||||
*/
|
|
||||||
$schema = new adoSchema( $db );
|
|
||||||
|
|
||||||
/* Call ParseSchema() to build SQL from the XML schema file.
|
|
||||||
* Then call ExecuteSchema() to apply the resulting SQL to
|
|
||||||
* the database.
|
|
||||||
*/
|
|
||||||
$sql = $schema->ParseSchema( $schemaFile );
|
|
||||||
$result = $schema->ExecuteSchema();
|
|
||||||
?>
|
|
||||||
</pre></pre></p>
|
|
||||||
<p>Let's look at each part of the example in turn. After you
|
|
||||||
manually create the database, there are three steps required to
|
|
||||||
load (or upgrade) your schema.</p>
|
|
||||||
<p>First, create a normal ADOdb connection. The variables
|
|
||||||
and values here should be those required to connect to your
|
|
||||||
database.</p>
|
|
||||||
<pre class="listing"><pre>
|
|
||||||
$db = ADONewConnection( 'mysql' );
|
|
||||||
$db->Connect( 'host', 'user', 'password', 'database' );
|
|
||||||
</pre></pre>
|
|
||||||
<p>Second, create the adoSchema object that load and
|
|
||||||
manipulate your schema. You must pass an ADOdb database
|
|
||||||
connection object in order to create the adoSchema
|
|
||||||
object.</p>
|
|
||||||
<pre class="listing"><pre>
|
|
||||||
$schema = new adoSchema( $db );
|
|
||||||
</pre></pre>
|
|
||||||
<p>Third, call ParseSchema() to parse the
|
|
||||||
schema and then ExecuteSchema() to apply
|
|
||||||
it to the database. You must pass
|
|
||||||
ParseSchema() the path and filename of
|
|
||||||
your schema file.</p>
|
|
||||||
<pre class="listing"><pre>
|
|
||||||
$schema->ParseSchema( $schemaFile );
|
|
||||||
$schema->ExecuteSchema();
|
|
||||||
</pre></pre>
|
|
||||||
<p>Execute the above code and then log into your database. If you've
|
|
||||||
done all this right, you should see your tables, indexes, and
|
|
||||||
SQL.</p>
|
|
||||||
<p>You can find the source files for this tutorial in the
|
|
||||||
examples directory as
|
|
||||||
tutorial_shema.xml and
|
|
||||||
tutorial.php. See the class documentation for
|
|
||||||
a more detailed description of the adoSchema methods, including
|
|
||||||
methods and schema elements that are not described in this
|
|
||||||
tutorial.</p>
|
|
||||||
|
|
||||||
<H3>XML Schema Format:</H3>
|
|
||||||
<P>(See <a href="xmlschema.dtd">xmlschema.dtd</a> for the full specification)</P>
|
|
||||||
<PRE>
|
|
||||||
<?xml version="1.0"?>
|
|
||||||
<schema version="0.2">
|
|
||||||
<table name="tablename" platform="platform1|platform2|...">
|
|
||||||
<descr>Optional description</descr>
|
|
||||||
<field name="fieldname" type="datadict_type" size="size">
|
|
||||||
<KEY/>
|
|
||||||
<NOTNULL/>
|
|
||||||
<AUTOINCREMENT/>
|
|
||||||
<DEFAULT value="value"/>
|
|
||||||
</field>
|
|
||||||
<i> ... more fields</i>
|
|
||||||
<index name="indexname" platform="platform1|platform2|...">
|
|
||||||
<descr>Optional description</descr>
|
|
||||||
<col>fieldname</col>
|
|
||||||
<i> ... more columns</i>
|
|
||||||
</index>
|
|
||||||
<i> ... more indexes</i>
|
|
||||||
</table>
|
|
||||||
<i> ... more tables</i>
|
|
||||||
|
|
||||||
<sql platform="platform1|platform2|...">
|
|
||||||
<descr>Optional description</descr>
|
|
||||||
<query platform="platform1|platform2|...">SQL query</query>
|
|
||||||
<i> ... more queries</i>
|
|
||||||
</sql>
|
|
||||||
<i> ... more SQL</i>
|
|
||||||
</schema>
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h3>Upgrading</h3>
|
<h3>Upgrading</h3>
|
||||||
If your schema version is older, than XSLT is used to transform the schema to the newest version.
|
If your schema version is older, than XSLT is used to transform the
|
||||||
This means that if you are using an older XML schema format, you need to have the XSLT extension installed.
|
schema to the newest version. This means that if you are using an older
|
||||||
If you do not want to require your users to have the XSLT extension installed, make sure you
|
XML schema format, you need to have the XSLT extension installed.
|
||||||
modify your XML schema to conform to the latest version.
|
If you do not want to require your users to have the XSLT extension
|
||||||
<hr />
|
installed, make sure you modify your XML schema to conform to the
|
||||||
|
latest version.
|
||||||
<address>If you have any questions or comments, please email them to Richard at richtl#arscognita.com.
|
<hr>
|
||||||
|
<address>If you have any questions or comments, please email them to
|
||||||
|
Richard at richtl#arscognita.com.
|
||||||
</address>
|
</address>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,239 +1,179 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>ADODB Session Management Manual</title>
|
<title>ADODB Session Management Manual</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type"
|
||||||
<XSTYLE
|
content="text/html; charset=iso-8859-1">
|
||||||
body,td {font-family:Arial,Helvetica,sans-serif;font-size:11pt}
|
<style type="text/css">
|
||||||
pre {font-size:9pt}
|
body, td {
|
||||||
.toplink {font-size:8pt}
|
/*font-family: Arial, Helvetica, sans-serif;*/
|
||||||
/>
|
font-size: 11pt;
|
||||||
</head>
|
}
|
||||||
<body bgcolor="#FFFFFF">
|
pre {
|
||||||
|
font-size: 9pt;
|
||||||
|
background-color: #EEEEEE; padding: .5em; margin: 0px;
|
||||||
|
}
|
||||||
|
.toplink {
|
||||||
|
font-size: 8pt;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body style="background-color: rgb(255, 255, 255);">
|
||||||
<h3>ADODB Session Management Manual</h3>
|
<h3>ADODB Session Management Manual</h3>
|
||||||
<p>
|
<p>
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my)
|
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my)
|
||||||
<p> <font size=1>This software is dual licensed using BSD-Style and LGPL. This
|
</p>
|
||||||
means you can use it in compiled proprietary and commercial products. </font>
|
<p> <font size="1">This software is dual licensed using BSD-Style and
|
||||||
<table border=1><tr><td><font color=red>Kindly note that the ADOdb home page has moved to <a href=http://adodb.sourceforge.net/>http://adodb.sourceforge.net/</a> because of the persistent
|
LGPL. This means you can use it in compiled proprietary and commercial
|
||||||
unreliability of http://php.weblogs.com. <b>Please change your links</b>!</font></td><tr></table>
|
products. </font>
|
||||||
<p>Useful ADOdb links: <a href=http://adodb.sourceforge.net/#download>Download</a> <a href=http://adodb.sourceforge.net/#docs>Other Docs</a>
|
<table border="1">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><font color="red">Kindly note that the ADOdb home page has
|
||||||
|
moved to <a href="http://adodb.sourceforge.net/">http://adodb.sourceforge.net/</a>
|
||||||
|
because of the persistent unreliability of http://php.weblogs.com. <b>Please
|
||||||
|
change your links</b>!</font></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</p>
|
||||||
|
<p>Useful ADOdb links: <a href="http://adodb.sourceforge.net/#download">Download</a>
|
||||||
|
<a href="http://adodb.sourceforge.net/#docs">Other Docs</a>
|
||||||
|
</p>
|
||||||
<h3>Introduction</h3>
|
<h3>Introduction</h3>
|
||||||
<p>
|
<p> We store state information specific to a user or web client in
|
||||||
We store state information specific to a user or web client in session variables. These session variables
|
session variables. These session variables persist throughout a
|
||||||
persist throughout a session, as the user moves from page to page.
|
session, as the user moves from page to page. </p>
|
||||||
<p>
|
<p>To use session variables, call session_start() at the beginning of
|
||||||
To use session variables, call session_start() at the beginning of your web page,
|
your web page, before your HTTP headers are sent. Then for every
|
||||||
before your HTTP headers are sent. Then for every variable you want to keep alive
|
variable you want to keep alive for the duration of the session, call
|
||||||
for the duration of the session, call session_register($variable_name). By default,
|
session_register($variable_name). By default, the session handler will
|
||||||
the session handler will keep track of the session by using a cookie. You can save objects
|
keep track of the session by using a cookie. You can save objects or
|
||||||
or arrays in session variables also.
|
arrays in session variables also.
|
||||||
<p>The default method of storing sessions is to store it in a file. However if
|
</p>
|
||||||
you have special needs such as you:
|
<p>The default method of storing sessions is to store it in a file.
|
||||||
|
However if you have special needs such as you:
|
||||||
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Have multiple web servers that need to share session info</li>
|
<li>Have multiple web servers that need to share session info</li>
|
||||||
<li>Need to do special processing of each session</li>
|
<li>Need to do special processing of each session</li>
|
||||||
<li>Require notification when a session expires</li>
|
<li>Require notification when a session expires</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>Then the ADOdb session handler provides you with the above additional capabilities
|
<p>Then the ADOdb session handler provides you with the above
|
||||||
by storing the session information as records in a database table that can be
|
additional capabilities by storing the session information as records
|
||||||
shared across multiple servers.
|
in a database table that can be shared across multiple servers. </p>
|
||||||
<p><b>Important Upgrade Notice:</b> Since ADOdb 4.05, the session files have been moved to its own folder, adodb/session. This is a rewrite
|
<p><b>Important Upgrade Notice:</b> Since ADOdb 4.05, the session files
|
||||||
of the session code by Ross Smith. The old session code is in adodb/session/old.
|
have been moved to its own folder, adodb/session. This is a rewrite
|
||||||
|
of the session code by Ross Smith. The old session code is in
|
||||||
|
adodb/session/old. </p>
|
||||||
<h4>ADOdb Session Handler Features</h4>
|
<h4>ADOdb Session Handler Features</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Ability to define a notification function that is called when a session expires. Typically
|
<li>Ability to define a notification function that is called when a
|
||||||
used to detect session logout and release global resources.
|
session expires. Typically
|
||||||
<li>Optimization of database writes. We crc32 the session data and only perform an update
|
used to detect session logout and release global resources. </li>
|
||||||
to the session data if there is a data change.
|
<li>Optimization of database writes. We crc32 the session data and
|
||||||
<li>Support for large amounts of session data with CLOBs (see adodb-session-clob.php). Useful
|
only perform an update
|
||||||
for Oracle.
|
to the session data if there is a data change. </li>
|
||||||
<li>Support for encrypted session data, see adodb-cryptsession.inc.php. Enabling encryption
|
<li>Support for large amounts of session data with CLOBs (see
|
||||||
is simply a matter of including adodb-cryptsession.inc.php instead of adodb-session.inc.php.
|
adodb-session-clob.php). Useful
|
||||||
|
for Oracle. </li>
|
||||||
|
<li>Support for encrypted session data, see
|
||||||
|
adodb-cryptsession.inc.php. Enabling encryption is simply a matter of
|
||||||
|
including adodb-cryptsession.inc.php instead of adodb-session.inc.php. </li>
|
||||||
</ul>
|
</ul>
|
||||||
<h3>Setup</h3>
|
<h3>Setup</h3>
|
||||||
<p>There are 3 session management files that you can use:
|
<p>There are 3 session management files that you can use:
|
||||||
<pre>
|
</p>
|
||||||
adodb-session.php : The default
|
<pre>adodb-session.php : The default<br>adodb-session-clob.php : Use this if you are storing DATA in clobs<br>adodb-cryptsession.php : Use this if you want to store encrypted session data in the database<br><br>
|
||||||
adodb-session-clob.php : Use this if you are storing DATA in clobs
|
</pre>
|
||||||
adodb-cryptsession.php : Use this if you want to store encrypted session data in the database
|
<p><strong>Examples</strong>
|
||||||
|
<p><pre>
|
||||||
<strong>Examples</strong>
|
<font
|
||||||
<font color=#004040>
|
color="#004040"> include('adodb/adodb.inc.php');<br> <br><b> $ADODB_SESSION_DRIVER='mysql';<br> $ADODB_SESSION_CONNECT='localhost';<br> $ADODB_SESSION_USER ='scott';<br> $ADODB_SESSION_PWD ='tiger';<br> $ADODB_SESSION_DB ='sessiondb';</b><br> <br> <b>include('adodb/session/adodb-session.php');</b><br> session_start();<br> <br> #<br> # Test session vars, the following should increment on refresh<br> #<br> $_SESSION['AVAR'] += 1;<br> print "<p>\$_SESSION['AVAR']={$_SESSION['AVAR']}</p>";<br></font></pre>
|
||||||
include('adodb/adodb.inc.php');
|
<p>To force non-persistent connections, call adodb_session_open first before session_start():<p>
|
||||||
|
<pre>
|
||||||
<b> $ADODB_SESSION_DRIVER='mysql';
|
<font color="#004040"><br> include('adodb/adodb.inc.php');<br> <br><b> $ADODB_SESSION_DRIVER='mysql';<br> $ADODB_SESSION_CONNECT='localhost';<br> $ADODB_SESSION_USER ='scott';<br> $ADODB_SESSION_PWD ='tiger';<br> $ADODB_SESSION_DB ='sessiondb';</b><br> <br> <b>include('adodb/session/adodb-session.php');<br> adodb_sess_open(false,false,false);</b><br> session_start();<br> </font>
|
||||||
$ADODB_SESSION_CONNECT='localhost';
|
</pre>
|
||||||
$ADODB_SESSION_USER ='scott';
|
<p> To use a encrypted sessions, simply replace the file:</p>
|
||||||
$ADODB_SESSION_PWD ='tiger';
|
<pre> <font
|
||||||
$ADODB_SESSION_DB ='sessiondb';</b>
|
color="#004040"><br> include('adodb/adodb.inc.php');<br> <br><b> $ADODB_SESSION_DRIVER='mysql';<br> $ADODB_SESSION_CONNECT='localhost';<br> $ADODB_SESSION_USER ='scott';<br> $ADODB_SESSION_PWD ='tiger';<br> $ADODB_SESSION_DB ='sessiondb';<br> <br> include('adodb/session/adodb-cryptsession.php');</b><br> session_start();</font><br>
|
||||||
|
</pre>
|
||||||
<b>include('adodb/session/adodb-session.php');</b>
|
<p>And the same technique for adodb-session-clob.php:</p>
|
||||||
session_start();
|
<pre> <font
|
||||||
|
color="#004040"><br> include('adodb/adodb.inc.php');<br> <br><b> $ADODB_SESSION_DRIVER='mysql';<br> $ADODB_SESSION_CONNECT='localhost';<br> $ADODB_SESSION_USER ='scott';<br> $ADODB_SESSION_PWD ='tiger';<br> $ADODB_SESSION_DB ='sessiondb';<br> <br> include('adodb/session/adodb-session-clob.php');</b><br> session_start();</font>
|
||||||
#
|
</pre>
|
||||||
# Test session vars, the following should increment on refresh
|
|
||||||
#
|
|
||||||
$_SESSION['AVAR'] += 1;
|
|
||||||
print "<p>\$_SESSION['AVAR']={$_SESSION['AVAR']}</p>";
|
|
||||||
</font>
|
|
||||||
To force non-persistent connections, call adodb_session_open first before session_start():
|
|
||||||
<font color=#004040>
|
|
||||||
include('adodb/adodb.inc.php');
|
|
||||||
|
|
||||||
<b> $ADODB_SESSION_DRIVER='mysql';
|
|
||||||
$ADODB_SESSION_CONNECT='localhost';
|
|
||||||
$ADODB_SESSION_USER ='scott';
|
|
||||||
$ADODB_SESSION_PWD ='tiger';
|
|
||||||
$ADODB_SESSION_DB ='sessiondb';</b>
|
|
||||||
|
|
||||||
<b>include('adodb/session/adodb-session.php');
|
|
||||||
adodb_sess_open(false,false,false);</b>
|
|
||||||
session_start();
|
|
||||||
</font color=#004040>
|
|
||||||
To use a encrypted sessions, simply replace the file:
|
|
||||||
<font color=#004040>
|
|
||||||
include('adodb/adodb.inc.php');
|
|
||||||
|
|
||||||
<b> $ADODB_SESSION_DRIVER='mysql';
|
|
||||||
$ADODB_SESSION_CONNECT='localhost';
|
|
||||||
$ADODB_SESSION_USER ='scott';
|
|
||||||
$ADODB_SESSION_PWD ='tiger';
|
|
||||||
$ADODB_SESSION_DB ='sessiondb';
|
|
||||||
|
|
||||||
include('adodb/session/adodb-cryptsession.php');</b>
|
|
||||||
session_start();
|
|
||||||
</font>
|
|
||||||
And the same technique for adodb-session-clob.php:
|
|
||||||
<font color=#004040>
|
|
||||||
include('adodb/adodb.inc.php');
|
|
||||||
|
|
||||||
<b> $ADODB_SESSION_DRIVER='mysql';
|
|
||||||
$ADODB_SESSION_CONNECT='localhost';
|
|
||||||
$ADODB_SESSION_USER ='scott';
|
|
||||||
$ADODB_SESSION_PWD ='tiger';
|
|
||||||
$ADODB_SESSION_DB ='sessiondb';
|
|
||||||
|
|
||||||
include('adodb/session/adodb-session-clob.php');</b>
|
|
||||||
session_start();
|
|
||||||
</font>
|
|
||||||
<h4>Installation</h4>
|
<h4>Installation</h4>
|
||||||
1. Create this table in your database (syntax might vary depending on your db):
|
<p>1. Create this table in your database (syntax might vary depending on your db):
|
||||||
<a name=sessiontab></a> <font color=#004040>
|
<p><pre> <a
|
||||||
create table sessions (
|
name="sessiontab"></a> <font color="#004040"><br> create table sessions (<br> SESSKEY char(32) not null,<br> EXPIRY int(11) unsigned not null,<br> EXPIREREF varchar(64),<br> DATA text not null,<br> primary key (sesskey)<br> );</font><br>
|
||||||
SESSKEY char(32) not null,
|
</pre>
|
||||||
EXPIRY int(11) unsigned not null,
|
<p> For the adodb-session-clob.php version, create this:
|
||||||
EXPIREREF varchar(64),
|
<pre>
|
||||||
DATA text not null,
|
<font
|
||||||
primary key (sesskey)
|
color="#004040"><br> create table sessions (<br> SESSKEY char(32) not null,<br> EXPIRY int(11) unsigned not null,<br> EXPIREREF varchar(64),<br> DATA CLOB,<br> primary key (sesskey)<br> );</font>
|
||||||
);</font>
|
</pre>
|
||||||
|
<p>2. Then define the following parameters. You can either modify this file, or define them before this file is included:
|
||||||
For the adodb-session-clob.php version, create this:
|
<pre> <font
|
||||||
<font color=#004040>
|
color="#004040"><br> $ADODB_SESSION_DRIVER='database driver, eg. mysql or ibase';<br> $ADODB_SESSION_CONNECT='server to connect to';<br> $ADODB_SESSION_USER ='user';<br> $ADODB_SESSION_PWD ='password';<br> $ADODB_SESSION_DB ='database';<br> $ADODB_SESSION_TBL = 'sessions'; # setting this is optional<br> </font>
|
||||||
create table sessions (
|
</pre><p>
|
||||||
SESSKEY char(32) not null,
|
When the session is created, $<b>ADODB_SESS_CONN</b> holds the connection object.<br> <br> 3. Recommended is PHP 4.0.6 or later. There are documented session bugs <br> in earlier versions of PHP.
|
||||||
EXPIRY int(11) unsigned not null,
|
<h3>Notifications</h3>
|
||||||
EXPIREREF varchar(64),
|
<p>If you want to receive notification when a session expires, then tag
|
||||||
DATA CLOB,
|
the session record with a <a href="#sessiontab">EXPIREREF</a> tag (see
|
||||||
primary key (sesskey)
|
the definition of the sessions table above). Before any session record
|
||||||
);</font>
|
is deleted, ADOdb will call a notification function, passing in the
|
||||||
|
EXPIREREF.
|
||||||
2. Then define the following parameters. You can either modify
|
</p>
|
||||||
this file, or define them before this file is included:
|
<p>When a session is first created, we check a global variable
|
||||||
<font color=#004040>
|
$ADODB_SESSION_EXPIRE_NOTIFY. This is an array with 2 elements, the
|
||||||
$ADODB_SESSION_DRIVER='database driver, eg. mysql or ibase';
|
first being the name of the session variable you would like to store in
|
||||||
$ADODB_SESSION_CONNECT='server to connect to';
|
the EXPIREREF field, and the 2nd is the notification function's name. </p>
|
||||||
$ADODB_SESSION_USER ='user';
|
<p> Suppose we want to be notified when a user's session has expired,
|
||||||
$ADODB_SESSION_PWD ='password';
|
based on the userid. The user id in the global session variable
|
||||||
$ADODB_SESSION_DB ='database';
|
$USERID. The function name is 'NotifyFn'. So we define: </p>
|
||||||
$ADODB_SESSION_TBL = 'sessions'; # setting this is optional
|
<pre> <font color="#004040"><br> $ADODB_SESSION_EXPIRE_NOTIFY = array('USERID','NotifyFn');<br> </font></pre>
|
||||||
</font>
|
And when the NotifyFn is called (when the session expires), we pass the
|
||||||
When the session is created, $<b>ADODB_SESS_CONN</b> holds the connection object.
|
$USERID as the first parameter, eg. NotifyFn($userid, $sesskey). The
|
||||||
|
session key (which is the primary key of the record in the sessions
|
||||||
3. Recommended is PHP 4.0.6 or later. There are documented session bugs
|
table) is the 2nd parameter.
|
||||||
in earlier versions of PHP.
|
<p> Here is an example of a Notification function that deletes some
|
||||||
|
records in the database and temporary files: </p>
|
||||||
|
<pre><font color="#004040"><br> function NotifyFn($expireref, $sesskey)<br> {<br> global $ADODB_SESS_CONN; # the session connection object<br><br> $user = $ADODB_SESS_CONN->qstr($expireref);<br> $ADODB_SESS_CONN->Execute("delete from shopping_cart where user=$user");<br> system("rm /work/tmpfiles/$expireref/*");<br> }</font><br> </pre>
|
||||||
|
<p> NOTE 1: If you have register_globals disabled in php.ini, then you
|
||||||
|
will have to manually set the EXPIREREF. E.g. </p>
|
||||||
|
<pre> <font color="#004040">
|
||||||
|
$GLOBALS['USERID'] =& $_SESSION['USERID'];
|
||||||
|
$ADODB_SESSION_EXPIRE_NOTIFY = array('USERID','NotifyFn');</font>
|
||||||
</pre>
|
</pre>
|
||||||
|
<p> NOTE 2: If you want to change the EXPIREREF after the session
|
||||||
<h3>Notifications</h3>
|
record has been created, you will need to modify any session variable
|
||||||
<p>If you want to receive notification when a session expires, then
|
to force a database record update.
|
||||||
tag the session record with a <a href="#sessiontab">EXPIREREF</a> tag (see the
|
</p>
|
||||||
definition of the sessions table above). Before any session record is deleted,
|
|
||||||
ADOdb will call a notification function, passing in the EXPIREREF.
|
|
||||||
<p>
|
|
||||||
When a session is first created, we check a global variable $ADODB_SESSION_EXPIRE_NOTIFY.
|
|
||||||
This is an array with 2 elements, the first being the name of the session variable
|
|
||||||
you would like to store in the EXPIREREF field, and the 2nd is the
|
|
||||||
notification function's name.
|
|
||||||
<p>
|
|
||||||
Suppose we want to be notified when a user's session
|
|
||||||
has expired, based on the userid. The user id in the global session variable $USERID.
|
|
||||||
The function name is 'NotifyFn'. So we define:
|
|
||||||
<pre> <font color=#004040>
|
|
||||||
$ADODB_SESSION_EXPIRE_NOTIFY = array('USERID','NotifyFn');
|
|
||||||
</font></pre>
|
|
||||||
And when the NotifyFn is called (when the session expires), we pass the $USERID
|
|
||||||
as the first parameter, eg. NotifyFn($userid, $sesskey). The session key (which is
|
|
||||||
the primary key of the record in the sessions table) is the 2nd parameter.
|
|
||||||
<p>
|
|
||||||
Here is an example of a Notification function that deletes some records in the database
|
|
||||||
and temporary files:
|
|
||||||
<pre><font color=#004040>
|
|
||||||
function NotifyFn($expireref, $sesskey)
|
|
||||||
{
|
|
||||||
global $ADODB_SESS_CONN; # the session connection object
|
|
||||||
|
|
||||||
$user = $ADODB_SESS_CONN->qstr($expireref);
|
|
||||||
$ADODB_SESS_CONN->Execute("delete from shopping_cart where user=$user");
|
|
||||||
system("rm /work/tmpfiles/$expireref/*");
|
|
||||||
}</font>
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
NOTE 1: If you have register_globals disabled in php.ini, then you will have to
|
|
||||||
manually set the EXPIREREF. E.g.
|
|
||||||
<pre> <font color=#004040>
|
|
||||||
$GLOBALS['USERID'] =& $_SESSION['USERID'];
|
|
||||||
$ADODB_SESSION_EXPIRE_NOTIFY = array('USERID','NotifyFn');
|
|
||||||
</font></pre>
|
|
||||||
<p>
|
|
||||||
NOTE 2: If you want to change the EXPIREREF after the session record has been
|
|
||||||
created, you will need to modify any session variable to force a database
|
|
||||||
record update.
|
|
||||||
|
|
||||||
<h4>Neat Notification Tricks</h4>
|
<h4>Neat Notification Tricks</h4>
|
||||||
|
|
||||||
<p><i>ExpireRef</i> normally holds the user id of the current session.
|
<p><i>ExpireRef</i> normally holds the user id of the current session.
|
||||||
<p>
|
</p>
|
||||||
1. You can then write a session monitor, scanning expireref to see
|
<p>1. You can then write a session monitor, scanning expireref to see
|
||||||
who is currently logged on.
|
who is currently logged on.
|
||||||
<p>
|
</p>
|
||||||
2. If you delete the sessions record for a specific user, eg.
|
<p>2. If you delete the sessions record for a specific user, eg.
|
||||||
<pre>
|
</p>
|
||||||
delete from sessions where expireref = '$USER'
|
<pre>delete from sessions where expireref = '$USER'<br></pre>
|
||||||
</pre>
|
|
||||||
then the user is logged out. Useful for ejecting someone from a
|
then the user is logged out. Useful for ejecting someone from a
|
||||||
site.
|
site.
|
||||||
<p>
|
<p>3. You can scan the sessions table to ensure no user
|
||||||
3. You can scan the sessions table to ensure no user
|
|
||||||
can be logged in twice. Useful for security reasons.
|
can be logged in twice. Useful for security reasons.
|
||||||
<p>
|
</p>
|
||||||
|
|
||||||
<h3>Compression/Encryption Schemes</h3>
|
<h3>Compression/Encryption Schemes</h3>
|
||||||
Since ADOdb 4.05, thanks to Ross Smith, multiple encryption and compression schemes are supported.
|
Since ADOdb 4.05, thanks to Ross Smith, multiple encryption and
|
||||||
Currently, supported:
|
compression schemes are supported. Currently, supported are:
|
||||||
<pre>
|
|
||||||
MD5Crypt (crypt.inc.php)
|
|
||||||
MCrypt
|
|
||||||
Secure (Horde's emulation of MCrypt, if MCrypt module is not available.)
|
|
||||||
GZip
|
|
||||||
BZip2
|
|
||||||
</pre>
|
|
||||||
These are stackable. E.g.
|
|
||||||
<pre>
|
|
||||||
ADODB_Session::filter(new ADODB_Compress_Bzip2());
|
|
||||||
ADODB_Session::filter(new ADODB_Encrypt_MD5());
|
|
||||||
</pre>
|
|
||||||
will compress and then encrypt the record in the database.
|
|
||||||
<p>
|
<p>
|
||||||
Also see the <a href=docs-adodb.htm>core ADOdb documentation</a>.
|
<pre> MD5Crypt (crypt.inc.php)<br> MCrypt<br> Secure (Horde's emulation of MCrypt, if MCrypt module is not available.)<br> GZip<br> BZip2<br></pre>
|
||||||
|
<p>These are stackable. E.g.
|
||||||
|
<p><pre>ADODB_Session::filter(new ADODB_Compress_Bzip2());<br>ADODB_Session::filter(new ADODB_Encrypt_MD5());<br></pre>
|
||||||
|
will compress and then encrypt the record in the database.
|
||||||
|
<p>Also see the <a href="docs-adodb.htm">core ADOdb documentation</a>.
|
||||||
|
</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -550,11 +550,15 @@ class ADORecordSet_ado extends ADORecordSet {
|
|||||||
|
|
||||||
if ($this->hideErrors) $olde = error_reporting(E_ERROR|E_CORE_ERROR);// sometimes $f->value be null
|
if ($this->hideErrors) $olde = error_reporting(E_ERROR|E_CORE_ERROR);// sometimes $f->value be null
|
||||||
for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) {
|
for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) {
|
||||||
|
//echo "<p>",$t,' ';var_dump($f->value); echo '</p>';
|
||||||
switch($t) {
|
switch($t) {
|
||||||
case 135: // timestamp
|
case 135: // timestamp
|
||||||
if (!strlen((string)$f->value)) $this->fields[] = false;
|
if (!strlen((string)$f->value)) $this->fields[] = false;
|
||||||
else $this->fields[] = adodb_date('Y-m-d H:i:s',(float)$f->value);
|
else {
|
||||||
|
if (!is_numeric($f->value)) $val = variant_date_to_timestamp($f->value);
|
||||||
|
else $val = $f->value;
|
||||||
|
$this->fields[] = adodb_date('Y-m-d H:i:s',$val);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 133:// A date value (yyyymmdd)
|
case 133:// A date value (yyyymmdd)
|
||||||
if ($val = $f->value) {
|
if ($val = $f->value) {
|
||||||
@ -564,7 +568,13 @@ class ADORecordSet_ado extends ADORecordSet {
|
|||||||
break;
|
break;
|
||||||
case 7: // adDate
|
case 7: // adDate
|
||||||
if (!strlen((string)$f->value)) $this->fields[] = false;
|
if (!strlen((string)$f->value)) $this->fields[] = false;
|
||||||
else $this->fields[] = adodb_date('Y-m-d',(float)$f->value);
|
else {
|
||||||
|
if (!is_numeric($f->value)) $val = variant_date_to_timestamp($f->value);
|
||||||
|
else $val = $f->value;
|
||||||
|
|
||||||
|
if (($val % 86400) == 0) $this->fields[] = adodb_date('Y-m-d',$val);
|
||||||
|
else $this->fields[] = adodb_date('Y-m-d H:i:s',$val);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 1: // null
|
case 1: // null
|
||||||
$this->fields[] = false;
|
$this->fields[] = false;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -34,7 +34,6 @@ class ADODB_ado_mssql extends ADODB_ado {
|
|||||||
var $ansiOuter = true; // for mssql7 or later
|
var $ansiOuter = true; // for mssql7 or later
|
||||||
var $substr = "substring";
|
var $substr = "substring";
|
||||||
var $length = 'len';
|
var $length = 'len';
|
||||||
var $upperCase = 'upper';
|
|
||||||
|
|
||||||
//var $_inTransaction = 1; // always open recordsets, so no transaction problems.
|
//var $_inTransaction = 1; // always open recordsets, so no transaction problems.
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -101,9 +101,8 @@ class ADODB_DB2 extends ADODB_odbc {
|
|||||||
var $fmtTimeStamp = "'Y-m-d-H.i.s'";
|
var $fmtTimeStamp = "'Y-m-d-H.i.s'";
|
||||||
var $ansiOuter = true;
|
var $ansiOuter = true;
|
||||||
var $identitySQL = 'values IDENTITY_VAL_LOCAL()';
|
var $identitySQL = 'values IDENTITY_VAL_LOCAL()';
|
||||||
var $_bindInputArray = false;
|
var $_bindInputArray = true;
|
||||||
var $upperCase = 'upper';
|
var $hasInsertID = true;
|
||||||
|
|
||||||
|
|
||||||
function ADODB_DB2()
|
function ADODB_DB2()
|
||||||
{
|
{
|
||||||
@ -135,13 +134,13 @@ class ADODB_DB2 extends ADODB_odbc {
|
|||||||
return $this->GetOne("select 1 as ignore from $tables where $where for update");
|
return $this->GetOne("select 1 as ignore from $tables where $where for update");
|
||||||
}
|
}
|
||||||
|
|
||||||
function &MetaTables($ttype=false,$showSchema=false)
|
function &MetaTables($ttype=false,$showSchema=false, $qtable="%", $qschema="%")
|
||||||
{
|
{
|
||||||
global $ADODB_FETCH_MODE;
|
global $ADODB_FETCH_MODE;
|
||||||
|
|
||||||
$savem = $ADODB_FETCH_MODE;
|
$savem = $ADODB_FETCH_MODE;
|
||||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||||
$qid = odbc_tables($this->_connectionID);
|
$qid = odbc_tables($this->_connectionID, "", $qschema, $qtable, "");
|
||||||
|
|
||||||
$rs = new ADORecordSet_odbc($qid);
|
$rs = new ADORecordSet_odbc($qid);
|
||||||
|
|
||||||
@ -177,6 +176,7 @@ class ADODB_DB2 extends ADODB_odbc {
|
|||||||
return $arr2;
|
return $arr2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Format date column in sql string given an input format that understands Y M D
|
// Format date column in sql string given an input format that understands Y M D
|
||||||
function SQLDate($fmt, $col=false)
|
function SQLDate($fmt, $col=false)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -58,6 +58,45 @@ class ADODB_ibase extends ADOConnection {
|
|||||||
if (defined('IBASE_DEFAULT')) $this->ibasetrans = IBASE_DEFAULT;
|
if (defined('IBASE_DEFAULT')) $this->ibasetrans = IBASE_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// returns true or false
|
||||||
|
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false)
|
||||||
|
{
|
||||||
|
if (!function_exists('ibase_pconnect')) return null;
|
||||||
|
if ($argDatabasename) $argHostname .= ':'.$argDatabasename;
|
||||||
|
$fn = ($persist) ? 'ibase_pconnect':'ibase_connect';
|
||||||
|
$this->_connectionID = $fn($argHostname,$argUsername,$argPassword,
|
||||||
|
$this->charSet,$this->buffers,$this->dialect);
|
||||||
|
|
||||||
|
if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html
|
||||||
|
$this->replaceQuote = "''";
|
||||||
|
}
|
||||||
|
if ($this->_connectionID === false) {
|
||||||
|
$this->_handleerror();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PHP5 change.
|
||||||
|
if (function_exists('ibase_timefmt')) {
|
||||||
|
ibase_timefmt($this->ibase_datefmt,IBASE_DATE );
|
||||||
|
if ($this->dialect == 1) ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP );
|
||||||
|
else ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP );
|
||||||
|
ibase_timefmt($this->ibase_timefmt,IBASE_TIME );
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ini_set("ibase.timestampformat", $this->ibase_timestampfmt);
|
||||||
|
ini_set("ibase.dateformat", $this->ibase_datefmt);
|
||||||
|
ini_set("ibase.timeformat", $this->ibase_timefmt);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// returns true or false
|
||||||
|
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
|
||||||
|
{
|
||||||
|
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function MetaPrimaryKeys($table,$owner_notused=false,$internalKey=false)
|
function MetaPrimaryKeys($table,$owner_notused=false,$internalKey=false)
|
||||||
{
|
{
|
||||||
if ($internalKey) return array('RDB$DB_KEY');
|
if ($internalKey) return array('RDB$DB_KEY');
|
||||||
@ -257,48 +296,6 @@ class ADODB_ibase extends ADOConnection {
|
|||||||
return $this->_errorMsg;
|
return $this->_errorMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true or false
|
|
||||||
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false)
|
|
||||||
{
|
|
||||||
if (!function_exists('ibase_pconnect')) return null;
|
|
||||||
if ($argDatabasename) $argHostname .= ':'.$argDatabasename;
|
|
||||||
$fn = ($persist) ? 'ibase_pconnect':'ibase_connect';
|
|
||||||
$this->_connectionID = $fn($argHostname,$argUsername,$argPassword,
|
|
||||||
$this->charSet,$this->buffers,$this->dialect);
|
|
||||||
|
|
||||||
if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html
|
|
||||||
$this->replaceQuote = "''";
|
|
||||||
}
|
|
||||||
if ($this->_connectionID === false) {
|
|
||||||
$this->_handleerror();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// PHP5 change.
|
|
||||||
if (function_exists('ibase_timefmt')) {
|
|
||||||
ibase_timefmt($this->ibase_datefmt,IBASE_DATE );
|
|
||||||
if ($this->dialect == 1) ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP );
|
|
||||||
else ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP );
|
|
||||||
ibase_timefmt($this->ibase_timefmt,IBASE_TIME );
|
|
||||||
} else {
|
|
||||||
ini_set("ibase.timestampformat", $this->base_timestampfmt);
|
|
||||||
ini_set("ibase.dateformat", $this->ibase_datefmt);
|
|
||||||
ini_set("ibase.timeformat", $this->ibase_timefmt);
|
|
||||||
}
|
|
||||||
//you can use
|
|
||||||
/*
|
|
||||||
ini_set("ibase.timestampformat", $this->ibase_timestampfmt);
|
|
||||||
ini_set("ibase.dateformat", $this->ibase_datefmt);
|
|
||||||
ini_set("ibase.timeformat", $this->ibase_timefmt);
|
|
||||||
*/
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// returns true or false
|
|
||||||
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
|
|
||||||
{
|
|
||||||
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function Prepare($sql)
|
function Prepare($sql)
|
||||||
{
|
{
|
||||||
$stmt = ibase_prepare($this->_connectionID,$sql);
|
$stmt = ibase_prepare($this->_connectionID,$sql);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim. All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -27,7 +27,6 @@ class ADODB_informix72 extends ADOConnection {
|
|||||||
var $fmtTimeStamp = "'Y-m-d H:i:s'";
|
var $fmtTimeStamp = "'Y-m-d H:i:s'";
|
||||||
var $hasInsertID = true;
|
var $hasInsertID = true;
|
||||||
var $hasAffectedRows = true;
|
var $hasAffectedRows = true;
|
||||||
var $upperCase = 'upper';
|
|
||||||
var $substr = 'substr';
|
var $substr = 'substr';
|
||||||
var $metaTablesSQL="select tabname from systables where tabtype!=' ' and owner!='informix'"; //Don't get informix tables and pseudo-tables
|
var $metaTablesSQL="select tabname from systables where tabtype!=' ' and owner!='informix'"; //Don't get informix tables and pseudo-tables
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -79,7 +79,6 @@ class ADODB_mssql extends ADOConnection {
|
|||||||
var $hasInsertID = true;
|
var $hasInsertID = true;
|
||||||
var $substr = "substring";
|
var $substr = "substring";
|
||||||
var $length = 'len';
|
var $length = 'len';
|
||||||
var $upperCase = 'upper';
|
|
||||||
var $hasAffectedRows = true;
|
var $hasAffectedRows = true;
|
||||||
var $metaDatabasesSQL = "select name from sysdatabases where name <> 'master'";
|
var $metaDatabasesSQL = "select name from sysdatabases where name <> 'master'";
|
||||||
var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE','dtproperties'))";
|
var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE','dtproperties'))";
|
||||||
@ -376,14 +375,25 @@ order by constraint_name, referenced_table_name, keyno";
|
|||||||
|
|
||||||
// "Stein-Aksel Basma" <basma@accelero.no>
|
// "Stein-Aksel Basma" <basma@accelero.no>
|
||||||
// tested with MSSQL 2000
|
// tested with MSSQL 2000
|
||||||
function MetaPrimaryKeys($table)
|
function &MetaPrimaryKeys($table)
|
||||||
{
|
{
|
||||||
$sql = "select k.column_name from information_schema.key_column_usage k,
|
global $ADODB_FETCH_MODE;
|
||||||
|
|
||||||
|
$schema = '';
|
||||||
|
$this->_findschema($table,$schema);
|
||||||
|
if (!$schema) $schema = $this->database;
|
||||||
|
if ($schema) $schema = "and k.table_catalog like '$schema%'";
|
||||||
|
|
||||||
|
$sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k,
|
||||||
information_schema.table_constraints tc
|
information_schema.table_constraints tc
|
||||||
where tc.constraint_name = k.constraint_name and tc.constraint_type =
|
where tc.constraint_name = k.constraint_name and tc.constraint_type =
|
||||||
'PRIMARY KEY' and k.table_name = '$table'";
|
'PRIMARY KEY' and k.table_name = '$table' $schema order by ordinal_position ";
|
||||||
|
|
||||||
|
$savem = $ADODB_FETCH_MODE;
|
||||||
|
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||||
$a = $this->GetCol($sql);
|
$a = $this->GetCol($sql);
|
||||||
|
$ADODB_FETCH_MODE = $savem;
|
||||||
|
|
||||||
if ($a && sizeof($a)>0) return $a;
|
if ($a && sizeof($a)>0) return $a;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -552,6 +562,11 @@ order by constraint_name, referenced_table_name, keyno";
|
|||||||
*/
|
*/
|
||||||
function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
|
function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (strtoupper($blobtype) == 'CLOB') {
|
||||||
|
$sql = "UPDATE $table SET $column='" . $val . "' WHERE $where";
|
||||||
|
return $this->Execute($sql) != false;
|
||||||
|
}
|
||||||
$sql = "UPDATE $table SET $column=0x".bin2hex($val)." WHERE $where";
|
$sql = "UPDATE $table SET $column=0x".bin2hex($val)." WHERE $where";
|
||||||
return $this->Execute($sql) != false;
|
return $this->Execute($sql) != false;
|
||||||
}
|
}
|
||||||
@ -589,10 +604,16 @@ order by constraint_name, referenced_table_name, keyno";
|
|||||||
} else if (is_integer($v)) {
|
} else if (is_integer($v)) {
|
||||||
$decl .= "@P$i INT";
|
$decl .= "@P$i INT";
|
||||||
$params .= "@P$i=".$v;
|
$params .= "@P$i=".$v;
|
||||||
} else {
|
} else if (is_float($v)) {
|
||||||
$decl .= "@P$i FLOAT";
|
$decl .= "@P$i FLOAT";
|
||||||
$params .= "@P$i=".$v;
|
$params .= "@P$i=".$v;
|
||||||
}
|
} else if (is_bool($v)) {
|
||||||
|
$decl .= "@P$i INT"; # Used INT just in case BIT in not supported on the user's MSSQL version. It will cast appropriately.
|
||||||
|
$params .= "@P$i=".(($v)?'1':'0'); # True == 1 in MSSQL BIT fields and acceptable for storing logical true in an int field
|
||||||
|
} else {
|
||||||
|
$decl .= "@P$i CHAR"; # Used char because a type is required even when the value is to be NULL.
|
||||||
|
$params .= "@P$i=NULL";
|
||||||
|
}
|
||||||
$i += 1;
|
$i += 1;
|
||||||
}
|
}
|
||||||
$decl = $this->qstr($decl);
|
$decl = $this->qstr($decl);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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,7 +29,6 @@ class ADODB_mysql extends ADOConnection {
|
|||||||
var $hasLimit = true;
|
var $hasLimit = true;
|
||||||
var $hasMoveFirst = true;
|
var $hasMoveFirst = true;
|
||||||
var $hasGenID = true;
|
var $hasGenID = true;
|
||||||
var $upperCase = 'upper';
|
|
||||||
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()';
|
||||||
@ -42,6 +41,7 @@ class ADODB_mysql extends ADOConnection {
|
|||||||
|
|
||||||
function ADODB_mysql()
|
function ADODB_mysql()
|
||||||
{
|
{
|
||||||
|
if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_';
|
||||||
}
|
}
|
||||||
|
|
||||||
function ServerInfo()
|
function ServerInfo()
|
||||||
@ -166,6 +166,11 @@ class ADODB_mysql extends ADOConnection {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function BeginTrans()
|
||||||
|
{
|
||||||
|
if ($this->debug) ADOConnection::outp("Transactions not supported in 'mysql' driver. Use 'mysqlt' or 'mysqli' driver");
|
||||||
|
}
|
||||||
|
|
||||||
function _affectedrows()
|
function _affectedrows()
|
||||||
{
|
{
|
||||||
return mysql_affected_rows($this->_connectionID);
|
return mysql_affected_rows($this->_connectionID);
|
||||||
@ -239,18 +244,22 @@ class ADODB_mysql extends ADOConnection {
|
|||||||
for ($i=0; $i < $len; $i++) {
|
for ($i=0; $i < $len; $i++) {
|
||||||
$ch = $fmt[$i];
|
$ch = $fmt[$i];
|
||||||
switch($ch) {
|
switch($ch) {
|
||||||
|
|
||||||
|
default:
|
||||||
|
if ($ch == '\\') {
|
||||||
|
$i++;
|
||||||
|
$ch = substr($fmt,$i,1);
|
||||||
|
}
|
||||||
|
/** FALL THROUGH */
|
||||||
|
case '-':
|
||||||
|
case '/':
|
||||||
|
$s .= $ch;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'Y':
|
case 'Y':
|
||||||
case 'y':
|
case 'y':
|
||||||
$s .= '%Y';
|
$s .= '%Y';
|
||||||
break;
|
break;
|
||||||
case 'Q':
|
|
||||||
case 'q':
|
|
||||||
$s .= "'),Quarter($col)";
|
|
||||||
|
|
||||||
if ($len > $i+1) $s .= ",DATE_FORMAT($col,'";
|
|
||||||
else $s .= ",('";
|
|
||||||
$concat = true;
|
|
||||||
break;
|
|
||||||
case 'M':
|
case 'M':
|
||||||
$s .= '%b';
|
$s .= '%b';
|
||||||
break;
|
break;
|
||||||
@ -263,6 +272,15 @@ class ADODB_mysql extends ADOConnection {
|
|||||||
$s .= '%d';
|
$s .= '%d';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'Q':
|
||||||
|
case 'q':
|
||||||
|
$s .= "'),Quarter($col)";
|
||||||
|
|
||||||
|
if ($len > $i+1) $s .= ",DATE_FORMAT($col,'";
|
||||||
|
else $s .= ",('";
|
||||||
|
$concat = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'H':
|
case 'H':
|
||||||
$s .= '%H';
|
$s .= '%H';
|
||||||
break;
|
break;
|
||||||
@ -284,14 +302,7 @@ class ADODB_mysql extends ADOConnection {
|
|||||||
$s .= '%p';
|
$s .= '%p';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
|
|
||||||
if ($ch == '\\') {
|
|
||||||
$i++;
|
|
||||||
$ch = substr($fmt,$i,1);
|
|
||||||
}
|
|
||||||
$s .= $ch;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$s.="')";
|
$s.="')";
|
||||||
@ -449,7 +460,6 @@ class ADODB_mysql extends ADOConnection {
|
|||||||
return $rs;
|
return $rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// returns queryID or false
|
// returns queryID or false
|
||||||
function _query($sql,$inputarr)
|
function _query($sql,$inputarr)
|
||||||
{
|
{
|
||||||
@ -477,8 +487,6 @@ class ADODB_mysql extends ADOConnection {
|
|||||||
else return @mysql_errno($this->_connectionID);
|
else return @mysql_errno($this->_connectionID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// returns true or false
|
// returns true or false
|
||||||
function _close()
|
function _close()
|
||||||
{
|
{
|
||||||
@ -509,6 +517,7 @@ class ADODB_mysql extends ADOConnection {
|
|||||||
Class Name: Recordset
|
Class Name: Recordset
|
||||||
--------------------------------------------------------------------------------------*/
|
--------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
class ADORecordSet_mysql extends ADORecordSet{
|
class ADORecordSet_mysql extends ADORecordSet{
|
||||||
|
|
||||||
var $databaseType = "mysql";
|
var $databaseType = "mysql";
|
||||||
@ -587,29 +596,20 @@ class ADORecordSet_mysql extends ADORecordSet{
|
|||||||
return @mysql_data_seek($this->_queryID,$row);
|
return @mysql_data_seek($this->_queryID,$row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function MoveNext()
|
||||||
// 10% speedup to move MoveNext to child class
|
|
||||||
function MoveNext()
|
|
||||||
{
|
{
|
||||||
//global $ADODB_EXTENSION;if ($ADODB_EXTENSION) return adodb_movenext($this);
|
//return adodb_movenext($this);
|
||||||
|
//if (defined('ADODB_EXTENSION')) return adodb_movenext($this);
|
||||||
if ($this->EOF) return false;
|
if (@$this->fields =& mysql_fetch_array($this->_queryID,$this->fetchMode)) {
|
||||||
|
$this->_currentRow += 1;
|
||||||
$this->_currentRow++;
|
return true;
|
||||||
$this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode);
|
}
|
||||||
if (is_array($this->fields)) return true;
|
if (!$this->EOF) {
|
||||||
|
$this->_currentRow += 1;
|
||||||
$this->EOF = true;
|
$this->EOF = true;
|
||||||
|
|
||||||
/* -- tested raising an error -- appears pointless
|
|
||||||
$conn = $this->connection;
|
|
||||||
if ($conn && $conn->raiseErrorFn && ($errno = $conn->ErrorNo())) {
|
|
||||||
$fn = $conn->raiseErrorFn;
|
|
||||||
$fn($conn->databaseType,'MOVENEXT',$errno,$conn->ErrorMsg().' ('.$this->sql.')',$conn->host,$conn->database);
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _fetch()
|
function _fetch()
|
||||||
{
|
{
|
||||||
@ -676,5 +676,32 @@ class ADORecordSet_mysql extends ADORecordSet{
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ADORecordSet_ext_mysql extends ADORecordSet_mysql {
|
||||||
|
function ADORecordSet_ext_mysql($queryID,$mode=false)
|
||||||
|
{
|
||||||
|
if ($mode === false) {
|
||||||
|
global $ADODB_FETCH_MODE;
|
||||||
|
$mode = $ADODB_FETCH_MODE;
|
||||||
|
}
|
||||||
|
switch ($mode)
|
||||||
|
{
|
||||||
|
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
|
||||||
|
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
|
||||||
|
default:
|
||||||
|
case ADODB_FETCH_DEFAULT:
|
||||||
|
case ADODB_FETCH_BOTH:$this->fetchMode = MYSQL_BOTH; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ADORecordSet($queryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
function MoveNext()
|
||||||
|
{
|
||||||
|
return adodb_movenext($this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -30,7 +30,6 @@ class ADODB_mysqli extends ADOConnection {
|
|||||||
var $hasLimit = true;
|
var $hasLimit = true;
|
||||||
var $hasMoveFirst = true;
|
var $hasMoveFirst = true;
|
||||||
var $hasGenID = true;
|
var $hasGenID = true;
|
||||||
var $upperCase = 'upper';
|
|
||||||
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()';
|
||||||
@ -39,18 +38,75 @@ class ADODB_mysqli extends ADOConnection {
|
|||||||
var $poorAffectedRows = true;
|
var $poorAffectedRows = true;
|
||||||
var $clientFlags = 0;
|
var $clientFlags = 0;
|
||||||
var $substr = "substring";
|
var $substr = "substring";
|
||||||
//var $poorAffectedRows = true;
|
var $port = false;
|
||||||
|
var $socket = false;
|
||||||
|
var $_bindInputArray = false;
|
||||||
var $nameQuote = '`'; /// string to use to quote identifiers and names
|
var $nameQuote = '`'; /// string to use to quote identifiers and names
|
||||||
//var $_bindInputArray = true;
|
|
||||||
|
|
||||||
function ADODB_mysqli()
|
function ADODB_mysqli()
|
||||||
{
|
{
|
||||||
if(!extension_loaded("mysqli"))
|
if(!extension_loaded("mysqli"))
|
||||||
{
|
|
||||||
trigger_error("You must have the MySQLi extension.", E_USER_ERROR);
|
trigger_error("You must have the MySQLi extension.", E_USER_ERROR);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// returns true or false
|
||||||
|
// To add: parameter int $port,
|
||||||
|
// parameter string $socket
|
||||||
|
function _connect($argHostname = NULL,
|
||||||
|
$argUsername = NULL,
|
||||||
|
$argPassword = NULL,
|
||||||
|
$argDatabasename = NULL, $persist=false)
|
||||||
|
{
|
||||||
|
$this->_connectionID = @mysqli_init();
|
||||||
|
|
||||||
|
if (is_null($this->_connectionID)) {
|
||||||
|
// mysqli_init only fails if insufficient memory
|
||||||
|
if ($this->debug)
|
||||||
|
ADOConnection::outp("mysqli_init() failed : " . $this->ErrorMsg());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Set connection options
|
||||||
|
// Not implemented now
|
||||||
|
// mysqli_options($this->_connection,,);
|
||||||
|
if (mysqli_real_connect($this->_connectionID,
|
||||||
|
$argHostname,
|
||||||
|
$argUsername,
|
||||||
|
$argPassword,
|
||||||
|
$argDatabasename,
|
||||||
|
$this->port,
|
||||||
|
$this->socket,
|
||||||
|
$this->clientFlags))
|
||||||
|
{
|
||||||
|
if ($argDatabasename) return $this->SelectDB($argDatabasename);
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($this->debug)
|
||||||
|
ADOConnection::outp("Could't connect : " . $this->ErrorMsg());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns true or false
|
||||||
|
// How to force a persistent connection
|
||||||
|
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
|
||||||
|
{
|
||||||
|
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename, true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// When is this used? Close old connection first?
|
||||||
|
// In _connect(), check $this->forceNewConnect?
|
||||||
|
function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
|
||||||
|
{
|
||||||
|
$this->forceNewConnect = true;
|
||||||
|
$this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
|
||||||
|
}
|
||||||
|
|
||||||
function IfNull( $field, $ifNull )
|
function IfNull( $field, $ifNull )
|
||||||
{
|
{
|
||||||
return " IFNULL($field, $ifNull) "; // if MySQL
|
return " IFNULL($field, $ifNull) "; // if MySQL
|
||||||
@ -329,70 +385,6 @@ class ADODB_mysqli extends ADOConnection {
|
|||||||
return "from_unixtime(unix_timestamp($date)+($dayFraction)*24*3600)";
|
return "from_unixtime(unix_timestamp($date)+($dayFraction)*24*3600)";
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true or false
|
|
||||||
// To add: parameter int $port,
|
|
||||||
// parameter string $socket
|
|
||||||
function _connect($argHostname = NULL,
|
|
||||||
$argUsername = NULL,
|
|
||||||
$argPassword = NULL,
|
|
||||||
$argDatabasename = NULL)
|
|
||||||
{
|
|
||||||
// @ means: error surpression on
|
|
||||||
$this->_connectionID = @mysqli_init();
|
|
||||||
|
|
||||||
if (is_null($this->_connectionID))
|
|
||||||
{
|
|
||||||
// mysqli_init only fails if insufficient memory
|
|
||||||
if ($this->debug)
|
|
||||||
ADOConnection::outp("mysqli_init() failed : " . $this->ErrorMsg());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Set connection options
|
|
||||||
// Not implemented now
|
|
||||||
// mysqli_options($this->_connection,,);
|
|
||||||
if (mysqli_real_connect($this->_connectionID,
|
|
||||||
$argHostname,
|
|
||||||
$argUsername,
|
|
||||||
$argPassword,
|
|
||||||
$argDatabasename))
|
|
||||||
{
|
|
||||||
if ($argDatabasename)
|
|
||||||
{
|
|
||||||
return $this->SelectDB($argDatabasename);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($this->debug)
|
|
||||||
ADOConnection::outp("Could't connect : " . $this->ErrorMsg());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns true or false
|
|
||||||
// How to force a persistent connection
|
|
||||||
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
|
|
||||||
{
|
|
||||||
// not implemented in mysqli (yet)?
|
|
||||||
$this->_connectionID = mysqli_connect($argHostname,
|
|
||||||
$argUsername,
|
|
||||||
$argPassword,
|
|
||||||
$argDatabasename);
|
|
||||||
if ($this->_connectionID === false) return false;
|
|
||||||
// if ($this->autoRollback) $this->RollbackTrans();
|
|
||||||
if ($argDatabasename) return $this->SelectDB($argDatabasename);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// When is this used? Close old connection first?
|
|
||||||
// In _connect(), check $this->forceNewConnect?
|
|
||||||
function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
|
|
||||||
{
|
|
||||||
$this->forceNewConnect = true;
|
|
||||||
$this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
|
|
||||||
}
|
|
||||||
|
|
||||||
function &MetaColumns($table)
|
function &MetaColumns($table)
|
||||||
{
|
{
|
||||||
@ -539,8 +531,11 @@ class ADODB_mysqli extends ADOConnection {
|
|||||||
{
|
{
|
||||||
return $sql;
|
return $sql;
|
||||||
|
|
||||||
$stmt = mysqli_prepare($this->_connectionID,$sql);
|
$stmt = $this->_connectionID->prepare($sql);
|
||||||
if (!$stmt) return false;
|
if (!$stmt) {
|
||||||
|
echo $this->ErrorMsg();
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
return array($sql,$stmt);
|
return array($sql,$stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,18 +544,20 @@ class ADODB_mysqli extends ADOConnection {
|
|||||||
function _query($sql, $inputarr)
|
function _query($sql, $inputarr)
|
||||||
{
|
{
|
||||||
global $ADODB_COUNTRECS;
|
global $ADODB_COUNTRECS;
|
||||||
|
|
||||||
if (is_array($sql)) {
|
if (is_array($sql)) {
|
||||||
$stmt = $sql[1];
|
$stmt = $sql[1];
|
||||||
|
$a = '';
|
||||||
foreach($inputarr as $k => $v) {
|
foreach($inputarr as $k => $v) {
|
||||||
if (is_string($v)) $a[] = MYSQLI_BIND_STRING;
|
if (is_string($v)) $a .= 's';
|
||||||
else if (is_integer($v)) $a[] = MYSQLI_BIND_INT;
|
else if (is_integer($v)) $a .= 'i';
|
||||||
else $a[] = MYSQLI_BIND_DOUBLE;
|
else $a .= 'd';
|
||||||
|
|
||||||
$fnarr =& array_merge( array($stmt,$a) , $inputarr);
|
|
||||||
$ret = call_user_func_array('mysqli_bind_param',$fnarr);
|
|
||||||
}
|
}
|
||||||
$ret = mysqli_execute($stmt);
|
|
||||||
|
$fnarr =& array_merge( array($stmt,$a) , $inputarr);
|
||||||
|
$ret = call_user_func_array('mysqli_stmt_bind_param',$fnarr);
|
||||||
|
|
||||||
|
$ret = mysqli_stmt_execute($stmt);
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
if (!$mysql_res = mysqli_query($this->_connectionID, $sql, ($ADODB_COUNTRECS) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT)) {
|
if (!$mysql_res = mysqli_query($this->_connectionID, $sql, ($ADODB_COUNTRECS) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT)) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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,11 @@ class ADODB_mysqlt extends ADODB_mysql {
|
|||||||
var $hasTransactions = true;
|
var $hasTransactions = true;
|
||||||
var $autoRollback = true; // apparently mysql does not autorollback properly
|
var $autoRollback = true; // apparently mysql does not autorollback properly
|
||||||
|
|
||||||
|
function ADODB_mysqlt()
|
||||||
|
{
|
||||||
|
global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_';
|
||||||
|
}
|
||||||
|
|
||||||
function BeginTrans()
|
function BeginTrans()
|
||||||
{
|
{
|
||||||
if ($this->transOff) return true;
|
if ($this->transOff) return true;
|
||||||
@ -59,21 +64,62 @@ class ADODB_mysqlt extends ADODB_mysql {
|
|||||||
class ADORecordSet_mysqlt extends ADORecordSet_mysql{
|
class ADORecordSet_mysqlt extends ADORecordSet_mysql{
|
||||||
var $databaseType = "mysqlt";
|
var $databaseType = "mysqlt";
|
||||||
|
|
||||||
function ADORecordSet_mysqlt($queryID,$mode=false) {
|
function ADORecordSet_mysqlt($queryID,$mode=false)
|
||||||
return $this->ADORecordSet_mysql($queryID,$mode);
|
{
|
||||||
|
if ($mode === false) {
|
||||||
|
global $ADODB_FETCH_MODE;
|
||||||
|
$mode = $ADODB_FETCH_MODE;
|
||||||
|
}
|
||||||
|
switch ($mode)
|
||||||
|
{
|
||||||
|
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
|
||||||
|
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
|
||||||
|
default:
|
||||||
|
case ADODB_FETCH_DEFAULT:
|
||||||
|
case ADODB_FETCH_BOTH:$this->fetchMode = MYSQL_BOTH; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ADORecordSet($queryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
function MoveNext()
|
function MoveNext()
|
||||||
{
|
{
|
||||||
if ($this->EOF) return false;
|
if (@$this->fields =& mysql_fetch_array($this->_queryID,$this->fetchMode)) {
|
||||||
|
$this->_currentRow += 1;
|
||||||
$this->_currentRow++;
|
return true;
|
||||||
// using & below slows things down by 20%!
|
}
|
||||||
$this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode);
|
if (!$this->EOF) {
|
||||||
if ($this->fields) return true;
|
$this->_currentRow += 1;
|
||||||
$this->EOF = true;
|
$this->EOF = true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
|
||||||
|
|
||||||
|
function ADORecordSet_ext_mysqli($queryID,$mode=false)
|
||||||
|
{
|
||||||
|
if ($mode === false) {
|
||||||
|
global $ADODB_FETCH_MODE;
|
||||||
|
$mode = $ADODB_FETCH_MODE;
|
||||||
|
}
|
||||||
|
switch ($mode)
|
||||||
|
{
|
||||||
|
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
|
||||||
|
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
|
||||||
|
default:
|
||||||
|
case ADODB_FETCH_DEFAULT:
|
||||||
|
case ADODB_FETCH_BOTH:$this->fetchMode = MYSQL_BOTH; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ADORecordSet($queryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
function MoveNext()
|
||||||
|
{
|
||||||
|
return adodb_movenext($this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.
|
||||||
|
|
||||||
First cut at the Netezza Driver by Josh Eldridge joshuae74#hotmail.com
|
First cut at the Netezza Driver by Josh Eldridge joshuae74#hotmail.com
|
||||||
Based on the previous postgres drivers.
|
Based on the previous postgres drivers.
|
||||||
@ -26,7 +26,6 @@ class ADODB_netezza extends ADODB_postgres64 {
|
|||||||
var $_resultid = false;
|
var $_resultid = false;
|
||||||
var $concat_operator='||';
|
var $concat_operator='||';
|
||||||
var $random = 'random';
|
var $random = 'random';
|
||||||
var $upperCase = 'upper';
|
|
||||||
var $metaDatabasesSQL = "select objname from _v_object_data where objtype='database' order by 1";
|
var $metaDatabasesSQL = "select objname from _v_object_data where objtype='database' order by 1";
|
||||||
var $metaTablesSQL = "select objname from _v_object_data where objtype='table' order by 1";
|
var $metaTablesSQL = "select objname from _v_object_data where objtype='table' order by 1";
|
||||||
var $isoDates = true; // accepts dates in ISO format
|
var $isoDates = true; // accepts dates in ISO format
|
||||||
|
@ -91,6 +91,7 @@ class ADODB_oci8 extends ADOConnection {
|
|||||||
function ADODB_oci8()
|
function ADODB_oci8()
|
||||||
{
|
{
|
||||||
$this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200;
|
$this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200;
|
||||||
|
if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Function &MetaColumns($table) added by smondino@users.sourceforge.net*/
|
/* Function &MetaColumns($table) added by smondino@users.sourceforge.net*/
|
||||||
@ -234,8 +235,6 @@ NATSOFT.DOMAIN =
|
|||||||
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,1);
|
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// returns true or false
|
// returns true or false
|
||||||
function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
|
function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
|
||||||
{
|
{
|
||||||
@ -576,7 +575,7 @@ NATSOFT.DOMAIN =
|
|||||||
if ($this->session_sharing_force_blob) $this->Execute('ALTER SESSION SET CURSOR_SHARING=EXACT');
|
if ($this->session_sharing_force_blob) $this->Execute('ALTER SESSION SET CURSOR_SHARING=EXACT');
|
||||||
$commit = $this->autoCommit;
|
$commit = $this->autoCommit;
|
||||||
if ($commit) $this->BeginTrans();
|
if ($commit) $this->BeginTrans();
|
||||||
$rs = ADODB_oci8::Execute($sql,$arr);
|
$rs = $this->_Execute($sql,$arr);
|
||||||
if ($rez = !empty($rs)) $desc->save($val);
|
if ($rez = !empty($rs)) $desc->save($val);
|
||||||
$desc->free();
|
$desc->free();
|
||||||
if ($commit) $this->CommitTrans();
|
if ($commit) $this->CommitTrans();
|
||||||
@ -748,7 +747,7 @@ NATSOFT.DOMAIN =
|
|||||||
return $rez;
|
return $rez;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Param($name)
|
function Param($name,$type=false)
|
||||||
{
|
{
|
||||||
return ':'.$name;
|
return ':'.$name;
|
||||||
}
|
}
|
||||||
@ -898,6 +897,8 @@ NATSOFT.DOMAIN =
|
|||||||
// returns true or false
|
// returns true or false
|
||||||
function _close()
|
function _close()
|
||||||
{
|
{
|
||||||
|
if (!$this->_connectionID) return;
|
||||||
|
|
||||||
if (!$this->autoCommit) OCIRollback($this->_connectionID);
|
if (!$this->autoCommit) OCIRollback($this->_connectionID);
|
||||||
if (count($this -> _refLOBs) > 0) {
|
if (count($this -> _refLOBs) > 0) {
|
||||||
foreach ($this -> _refLOBs as $key => $value) {
|
foreach ($this -> _refLOBs as $key => $value) {
|
||||||
@ -906,6 +907,7 @@ NATSOFT.DOMAIN =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
OCILogoff($this->_connectionID);
|
OCILogoff($this->_connectionID);
|
||||||
|
|
||||||
$this->_stmt = false;
|
$this->_stmt = false;
|
||||||
$this->_connectionID = false;
|
$this->_connectionID = false;
|
||||||
}
|
}
|
||||||
@ -1126,8 +1128,9 @@ class ADORecordset_oci8 extends ADORecordSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
// 10% speedup to move MoveNext to child class
|
// 10% speedup to move MoveNext to child class
|
||||||
function MoveNext()
|
function _MoveNext()
|
||||||
{
|
{
|
||||||
//global $ADODB_EXTENSION;if ($ADODB_EXTENSION) return @adodb_movenext($this);
|
//global $ADODB_EXTENSION;if ($ADODB_EXTENSION) return @adodb_movenext($this);
|
||||||
|
|
||||||
@ -1139,7 +1142,22 @@ class ADORecordset_oci8 extends ADORecordSet {
|
|||||||
$this->EOF = true;
|
$this->EOF = true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} */
|
||||||
|
|
||||||
|
|
||||||
|
function MoveNext()
|
||||||
|
{
|
||||||
|
if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
|
||||||
|
$this->_currentRow += 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!$this->EOF) {
|
||||||
|
$this->_currentRow += 1;
|
||||||
|
$this->EOF = true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */
|
/* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */
|
||||||
function &GetArrayLimit($nrows,$offset=-1)
|
function &GetArrayLimit($nrows,$offset=-1)
|
||||||
@ -1244,4 +1262,29 @@ class ADORecordset_oci8 extends ADORecordSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ADORecordSet_ext_oci8 extends ADORecordSet_oci8 {
|
||||||
|
function ADORecordSet_ext_oci8($queryID,$mode=false)
|
||||||
|
{
|
||||||
|
if ($mode === false) {
|
||||||
|
global $ADODB_FETCH_MODE;
|
||||||
|
$mode = $ADODB_FETCH_MODE;
|
||||||
|
}
|
||||||
|
switch ($mode)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case ADODB_FETCH_NUM: $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
|
||||||
|
case ADODB_FETCH_ASSOC:$this->fetchMode = OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
|
||||||
|
case ADODB_FETCH_DEFAULT:
|
||||||
|
case ADODB_FETCH_BOTH:$this->fetchMode = OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_queryID = $queryID;
|
||||||
|
}
|
||||||
|
|
||||||
|
function MoveNext()
|
||||||
|
{
|
||||||
|
return adodb_movenext($this);
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim. All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -30,7 +30,8 @@ class ADODB_oci8po extends ADODB_oci8 {
|
|||||||
|
|
||||||
function ADODB_oci8po()
|
function ADODB_oci8po()
|
||||||
{
|
{
|
||||||
$this->ADODB_oci8();
|
$this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200;
|
||||||
|
# oci8po does not support adodb extension: adodb_movenext()
|
||||||
}
|
}
|
||||||
|
|
||||||
function Param($name)
|
function Param($name)
|
||||||
@ -77,59 +78,72 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
|
|||||||
|
|
||||||
var $databaseType = 'oci8po';
|
var $databaseType = 'oci8po';
|
||||||
|
|
||||||
function ADORecordset_oci8po($queryID,$mode=false)
|
function ADORecordset_oci8po($queryID,$mode=false)
|
||||||
{
|
{
|
||||||
$this->ADORecordset_oci8($queryID,$mode);
|
$this->ADORecordset_oci8($queryID,$mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Fields($colname)
|
function Fields($colname)
|
||||||
{
|
{
|
||||||
if ($this->fetchMode & OCI_ASSOC) return $this->fields[$colname];
|
if ($this->fetchMode & OCI_ASSOC) return $this->fields[$colname];
|
||||||
|
|
||||||
if (!$this->bind) {
|
|
||||||
$this->bind = array();
|
|
||||||
for ($i=0; $i < $this->_numOfFields; $i++) {
|
|
||||||
$o = $this->FetchField($i);
|
|
||||||
$this->bind[strtoupper($o->name)] = $i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $this->fields[$this->bind[strtoupper($colname)]];
|
|
||||||
}
|
|
||||||
|
|
||||||
// lowercase field names...
|
if (!$this->bind) {
|
||||||
function &_FetchField($fieldOffset = -1)
|
$this->bind = array();
|
||||||
{
|
for ($i=0; $i < $this->_numOfFields; $i++) {
|
||||||
$fld = new ADOFieldObject;
|
$o = $this->FetchField($i);
|
||||||
$fieldOffset += 1;
|
$this->bind[strtoupper($o->name)] = $i;
|
||||||
$fld->name = strtolower(OCIcolumnname($this->_queryID, $fieldOffset));
|
}
|
||||||
$fld->type = OCIcolumntype($this->_queryID, $fieldOffset);
|
|
||||||
$fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);
|
|
||||||
if ($fld->type == 'NUMBER') {
|
|
||||||
//$p = OCIColumnPrecision($this->_queryID, $fieldOffset);
|
|
||||||
$sc = OCIColumnScale($this->_queryID, $fieldOffset);
|
|
||||||
if ($sc == 0) $fld->type = 'INT';
|
|
||||||
}
|
|
||||||
return $fld;
|
|
||||||
}
|
}
|
||||||
|
return $this->fields[$this->bind[strtoupper($colname)]];
|
||||||
|
}
|
||||||
|
|
||||||
|
// lowercase field names...
|
||||||
|
function &_FetchField($fieldOffset = -1)
|
||||||
|
{
|
||||||
|
$fld = new ADOFieldObject;
|
||||||
|
$fieldOffset += 1;
|
||||||
|
$fld->name = strtolower(OCIcolumnname($this->_queryID, $fieldOffset));
|
||||||
|
$fld->type = OCIcolumntype($this->_queryID, $fieldOffset);
|
||||||
|
$fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);
|
||||||
|
if ($fld->type == 'NUMBER') {
|
||||||
|
//$p = OCIColumnPrecision($this->_queryID, $fieldOffset);
|
||||||
|
$sc = OCIColumnScale($this->_queryID, $fieldOffset);
|
||||||
|
if ($sc == 0) $fld->type = 'INT';
|
||||||
|
}
|
||||||
|
return $fld;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
function MoveNext()
|
||||||
|
{
|
||||||
|
if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
|
||||||
|
$this->_currentRow += 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!$this->EOF) {
|
||||||
|
$this->_currentRow += 1;
|
||||||
|
$this->EOF = true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}*/
|
||||||
|
|
||||||
// 10% speedup to move MoveNext to child class
|
// 10% speedup to move MoveNext to child class
|
||||||
function MoveNext()
|
function MoveNext()
|
||||||
{
|
{
|
||||||
|
if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
|
||||||
if (!$this->EOF) {
|
global $ADODB_ANSI_PADDING_OFF;
|
||||||
$this->_currentRow++;
|
$this->_currentRow++;
|
||||||
if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
|
|
||||||
global $ADODB_ANSI_PADDING_OFF;
|
if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
|
||||||
|
if (!empty($ADODB_ANSI_PADDING_OFF)) {
|
||||||
if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
|
foreach($this->fields as $k => $v) {
|
||||||
if (!empty($ADODB_ANSI_PADDING_OFF)) {
|
if (is_string($v)) $this->fields[$k] = rtrim($v);
|
||||||
foreach($this->fields as $k => $v) {
|
|
||||||
if (is_string($v)) $this->fields[$k] = rtrim($v);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!$this->EOF) {
|
||||||
$this->EOF = true;
|
$this->EOF = true;
|
||||||
|
$this->_currentRow++;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -190,4 +204,6 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -37,6 +37,7 @@ class ADODB_odbc extends ADOConnection {
|
|||||||
var $_haserrorfunctions = true;
|
var $_haserrorfunctions = true;
|
||||||
var $_has_stupid_odbc_fetch_api_change = true;
|
var $_has_stupid_odbc_fetch_api_change = true;
|
||||||
var $_lastAffectedRows = 0;
|
var $_lastAffectedRows = 0;
|
||||||
|
var $uCaseTables = true; // for meta* functions, uppercase table names
|
||||||
|
|
||||||
function ADODB_odbc()
|
function ADODB_odbc()
|
||||||
{
|
{
|
||||||
@ -56,7 +57,7 @@ class ADODB_odbc extends ADOConnection {
|
|||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
|
|
||||||
$rez = odbc_data_source($this->_connectionID,
|
$rez = @odbc_data_source($this->_connectionID,
|
||||||
$first ? SQL_FETCH_FIRST : SQL_FETCH_NEXT);
|
$first ? SQL_FETCH_FIRST : SQL_FETCH_NEXT);
|
||||||
$first = false;
|
$first = false;
|
||||||
if (!is_array($rez)) break;
|
if (!is_array($rez)) break;
|
||||||
@ -232,9 +233,13 @@ class ADODB_odbc extends ADOConnection {
|
|||||||
{
|
{
|
||||||
global $ADODB_FETCH_MODE;
|
global $ADODB_FETCH_MODE;
|
||||||
|
|
||||||
|
if ($this->uCaseTables) $table = strtoupper($table);
|
||||||
|
$schema = '';
|
||||||
|
$this->_findschema($table,$schema);
|
||||||
|
|
||||||
$savem = $ADODB_FETCH_MODE;
|
$savem = $ADODB_FETCH_MODE;
|
||||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||||
$qid = @odbc_primarykeys($this->_connectionID,'','',$table);
|
$qid = @odbc_primarykeys($this->_connectionID,'',$schema,$table);
|
||||||
|
|
||||||
if (!$qid) {
|
if (!$qid) {
|
||||||
$ADODB_FETCH_MODE = $savem;
|
$ADODB_FETCH_MODE = $savem;
|
||||||
@ -361,14 +366,14 @@ class ADODB_odbc extends ADOConnection {
|
|||||||
{
|
{
|
||||||
global $ADODB_FETCH_MODE;
|
global $ADODB_FETCH_MODE;
|
||||||
|
|
||||||
$table = strtoupper($table);
|
if ($this->uCaseTables) $table = strtoupper($table);
|
||||||
$schema = false;
|
$schema = '';
|
||||||
$this->_findschema($table,$schema);
|
$this->_findschema($table,$schema);
|
||||||
|
|
||||||
$savem = $ADODB_FETCH_MODE;
|
$savem = $ADODB_FETCH_MODE;
|
||||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||||
|
|
||||||
if (false) { // after testing, confirmed that the following does not work becoz of a bug
|
/*if (false) { // after testing, confirmed that the following does not work becoz of a bug
|
||||||
$qid2 = odbc_tables($this->_connectionID);
|
$qid2 = odbc_tables($this->_connectionID);
|
||||||
$rs = new ADORecordSet_odbc($qid2);
|
$rs = new ADORecordSet_odbc($qid2);
|
||||||
$ADODB_FETCH_MODE = $savem;
|
$ADODB_FETCH_MODE = $savem;
|
||||||
@ -387,12 +392,19 @@ class ADODB_odbc extends ADOConnection {
|
|||||||
$rs->Close();
|
$rs->Close();
|
||||||
|
|
||||||
$qid = odbc_columns($this->_connectionID,$q,$o,strtoupper($table),'%');
|
$qid = odbc_columns($this->_connectionID,$q,$o,strtoupper($table),'%');
|
||||||
} else switch ($this->databaseType) {
|
} */
|
||||||
|
|
||||||
|
switch ($this->databaseType) {
|
||||||
case 'access':
|
case 'access':
|
||||||
case 'vfp':
|
case 'vfp':
|
||||||
case 'db2':
|
$qid = odbc_columns($this->_connectionID);#,'%','',strtoupper($table),'%');
|
||||||
$qid = odbc_columns($this->_connectionID);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case 'db2':
|
||||||
|
$colname = "%";
|
||||||
|
$qid = odbc_columns($this->_connectionID, "", $schema, $table, $colname);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$qid = @odbc_columns($this->_connectionID,'%','%',strtoupper($table),'%');
|
$qid = @odbc_columns($this->_connectionID,'%','%',strtoupper($table),'%');
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -32,7 +32,6 @@ class ADODB_odbc_mssql extends ADODB_odbc {
|
|||||||
var $sysTimeStamp = 'GetDate()';
|
var $sysTimeStamp = 'GetDate()';
|
||||||
var $leftOuter = '*=';
|
var $leftOuter = '*=';
|
||||||
var $rightOuter = '=*';
|
var $rightOuter = '=*';
|
||||||
var $upperCase = 'upper';
|
|
||||||
var $substr = 'substring';
|
var $substr = 'substring';
|
||||||
var $length = 'len';
|
var $length = 'len';
|
||||||
var $ansiOuter = true; // for mssql7 or later
|
var $ansiOuter = true; // for mssql7 or later
|
||||||
@ -146,12 +145,23 @@ order by constraint_name, referenced_table_name, keyno";
|
|||||||
// tested with MSSQL 2000
|
// tested with MSSQL 2000
|
||||||
function &MetaPrimaryKeys($table)
|
function &MetaPrimaryKeys($table)
|
||||||
{
|
{
|
||||||
$sql = "select k.column_name from information_schema.key_column_usage k,
|
global $ADODB_FETCH_MODE;
|
||||||
|
|
||||||
|
$schema = '';
|
||||||
|
$this->_findschema($table,$schema);
|
||||||
|
//if (!$schema) $schema = $this->database;
|
||||||
|
if ($schema) $schema = "and k.table_catalog like '$schema%'";
|
||||||
|
|
||||||
|
$sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k,
|
||||||
information_schema.table_constraints tc
|
information_schema.table_constraints tc
|
||||||
where tc.constraint_name = k.constraint_name and tc.constraint_type =
|
where tc.constraint_name = k.constraint_name and tc.constraint_type =
|
||||||
'PRIMARY KEY' and k.table_name = '$table'";
|
'PRIMARY KEY' and k.table_name = '$table' $schema order by ordinal_position ";
|
||||||
|
|
||||||
|
$savem = $ADODB_FETCH_MODE;
|
||||||
|
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
|
||||||
$a = $this->GetCol($sql);
|
$a = $this->GetCol($sql);
|
||||||
|
$ADODB_FETCH_MODE = $savem;
|
||||||
|
|
||||||
if ($a && sizeof($a)>0) return $a;
|
if ($a && sizeof($a)>0) return $a;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -174,7 +174,6 @@ class ADODB_odbtp extends ADOConnection{
|
|||||||
$this->_canSelectDb = true;
|
$this->_canSelectDb = true;
|
||||||
$this->substr = "substring";
|
$this->substr = "substring";
|
||||||
$this->length = 'len';
|
$this->length = 'len';
|
||||||
$this->upperCase = 'upper';
|
|
||||||
$this->identitySQL = 'select @@IDENTITY';
|
$this->identitySQL = 'select @@IDENTITY';
|
||||||
$this->metaDatabasesSQL = "select name from master..sysdatabases where name <> 'master'";
|
$this->metaDatabasesSQL = "select name from master..sysdatabases where name <> 'master'";
|
||||||
break;
|
break;
|
||||||
@ -202,7 +201,6 @@ class ADODB_odbtp extends ADOConnection{
|
|||||||
$this->replaceQuote = "'+chr(39)+'";
|
$this->replaceQuote = "'+chr(39)+'";
|
||||||
$this->true = '.T.';
|
$this->true = '.T.';
|
||||||
$this->false = '.F.';
|
$this->false = '.F.';
|
||||||
$this->upperCase = 'upper';
|
|
||||||
break;
|
break;
|
||||||
case ODB_DRIVER_ORACLE:
|
case ODB_DRIVER_ORACLE:
|
||||||
$this->fmtDate = "'Y-m-d 00:00:00'";
|
$this->fmtDate = "'Y-m-d 00:00:00'";
|
||||||
@ -222,7 +220,6 @@ class ADODB_odbtp extends ADOConnection{
|
|||||||
$this->rightOuter = '=*';
|
$this->rightOuter = '=*';
|
||||||
$this->hasInsertID = true;
|
$this->hasInsertID = true;
|
||||||
$this->hasTransactions = true;
|
$this->hasTransactions = true;
|
||||||
$this->upperCase = 'upper';
|
|
||||||
$this->identitySQL = 'select @@IDENTITY';
|
$this->identitySQL = 'select @@IDENTITY';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -628,6 +625,4 @@ class ADORecordSet_odbtp extends ADORecordSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -59,5 +59,4 @@ class ADORecordSet_odbtp_unicode extends ADORecordSet_odbtp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
@ -1,15 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
|
||||||
Latest version is available at http://adodb.sourceforge.net
|
Latest version is available at http://adodb.sourceforge.net
|
||||||
|
|
||||||
Oracle data driver. Requires Oracle client. Works on Windows and Unix and Oracle 7 and 8.
|
Oracle data driver. Requires Oracle client. Works on Windows and Unix and Oracle 7.
|
||||||
|
|
||||||
If you are using Oracle 8, use the oci8 driver which is much better and more reliable.
|
If you are using Oracle 8 or later, use the oci8 driver which is much better and more reliable.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// security - hide paths
|
// security - hide paths
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -390,14 +390,14 @@ select viewname,'V' from pg_views where viewname like $mask";
|
|||||||
|
|
||||||
// for schema support, pass in the $table param "$schema.$tabname".
|
// for schema support, pass in the $table param "$schema.$tabname".
|
||||||
// converts field names to lowercase, $upper is ignored
|
// converts field names to lowercase, $upper is ignored
|
||||||
function &MetaColumns($table,$upper=true)
|
function &MetaColumns($table,$normalize=true)
|
||||||
{
|
{
|
||||||
global $ADODB_FETCH_MODE;
|
global $ADODB_FETCH_MODE;
|
||||||
|
|
||||||
$schema = false;
|
$schema = false;
|
||||||
$this->_findschema($table,$schema);
|
$this->_findschema($table,$schema);
|
||||||
|
|
||||||
$table = strtolower($table);
|
if ($normalize) $table = strtolower($table);
|
||||||
|
|
||||||
$save = $ADODB_FETCH_MODE;
|
$save = $ADODB_FETCH_MODE;
|
||||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||||
@ -486,7 +486,7 @@ select viewname,'V' from pg_views where viewname like $mask";
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
|
if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
|
||||||
else $retarr[($upper) ? strtoupper($fld->name) : $fld->name] = $fld;
|
else $retarr[($normalize) ? strtoupper($fld->name) : $fld->name] = $fld;
|
||||||
|
|
||||||
$rs->MoveNext();
|
$rs->MoveNext();
|
||||||
}
|
}
|
||||||
@ -805,7 +805,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
|
|||||||
if (pg_fieldtype($qid,$i) == 'bytea') {
|
if (pg_fieldtype($qid,$i) == 'bytea') {
|
||||||
$this->_blobArr[$i] = pg_fieldname($qid,$i);
|
$this->_blobArr[$i] = pg_fieldname($qid,$i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use associative array to get fields array */
|
/* Use associative array to get fields array */
|
||||||
@ -867,7 +867,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
|
|||||||
if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) {
|
if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) {
|
||||||
$this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
|
$this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
|
||||||
if (is_array($this->fields) && $this->fields) {
|
if (is_array($this->fields) && $this->fields) {
|
||||||
if ($this->fields && isset($this->_blobArr)) $this->_fixblobs();
|
if (isset($this->_blobArr)) $this->_fixblobs();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim. All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -155,7 +155,7 @@ class ADODB_sybase extends ADOConnection {
|
|||||||
if ($offset > 0 && $cnt) $cnt += $offset;
|
if ($offset > 0 && $cnt) $cnt += $offset;
|
||||||
|
|
||||||
$this->Execute("set rowcount $cnt");
|
$this->Execute("set rowcount $cnt");
|
||||||
$rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
|
$rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,0);
|
||||||
$this->Execute("set rowcount 0");
|
$this->Execute("set rowcount 0");
|
||||||
|
|
||||||
return $rs;
|
return $rs;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -27,7 +27,6 @@ class ADODB_vfp extends ADODB_odbc {
|
|||||||
var $true = '.T.';
|
var $true = '.T.';
|
||||||
var $false = '.F.';
|
var $false = '.F.';
|
||||||
var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
|
var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
|
||||||
var $upperCase = 'upper';
|
|
||||||
var $_bindInputArray = false; // strangely enough, setting to true does not work reliably
|
var $_bindInputArray = false; // strangely enough, setting to true does not work reliably
|
||||||
var $sysTimeStamp = 'datetime()';
|
var $sysTimeStamp = 'datetime()';
|
||||||
var $sysDate = 'date()';
|
var $sysDate = 'date()';
|
||||||
@ -45,7 +44,6 @@ class ADODB_vfp extends ADODB_odbc {
|
|||||||
return time();
|
return time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function BeginTrans() { return false;}
|
function BeginTrans() { return false;}
|
||||||
|
|
||||||
// quote string to be sent back to database
|
// quote string to be sent back to database
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -152,12 +152,10 @@ AND b.name = 'sorts (memory)'",
|
|||||||
having count(*) > 100)",'These are sql statements that should be using bind variables'),*/
|
having count(*) > 100)",'These are sql statements that should be using bind variables'),*/
|
||||||
'index cache cost' => array('COST',
|
'index cache cost' => array('COST',
|
||||||
"select value from v\$parameter where name = 'optimizer_index_caching'",
|
"select value from v\$parameter where name = 'optimizer_index_caching'",
|
||||||
'% of indexed data blocks expected in the cache.
|
'=WarnIndexCost'),
|
||||||
Recommended is 20-80. Default is 0. See <a href=http://www.dba-oracle.com/oracle_tips_cbo_part1.htm>optimizer_index_caching</a>.'),
|
|
||||||
|
|
||||||
'random page cost' => array('COST',
|
'random page cost' => array('COST',
|
||||||
"select value from v\$parameter where name = 'optimizer_index_cost_adj'",
|
"select value from v\$parameter where name = 'optimizer_index_cost_adj'",
|
||||||
'Recommended is 10-50 for TP, and 50 for data warehouses. Default is 100. See <a href=http://www.dba-oracle.com/oracle_tips_cost_adj.htm>optimizer_index_cost_adj</a>. '),
|
'=WarnPageCost'),
|
||||||
|
|
||||||
false
|
false
|
||||||
|
|
||||||
@ -172,6 +170,23 @@ having count(*) > 100)",'These are sql statements that should be using bind vari
|
|||||||
$this->conn =& $conn;
|
$this->conn =& $conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function WarnPageCost($val)
|
||||||
|
{
|
||||||
|
if ($val == 100) $s = '<font color=red><b>Too High</b>. </font>';
|
||||||
|
else $s = '';
|
||||||
|
|
||||||
|
return $s.'Recommended is 20-50 for TP, and 50 for data warehouses. Default is 100. See <a href=http://www.dba-oracle.com/oracle_tips_cost_adj.htm>optimizer_index_cost_adj</a>. ';
|
||||||
|
}
|
||||||
|
|
||||||
|
function WarnIndexCost($val)
|
||||||
|
{
|
||||||
|
if ($val == 0) $s = '<font color=red><b>Too Low</b>. </font>';
|
||||||
|
else $s = '';
|
||||||
|
|
||||||
|
return $s.'Percentage of indexed data blocks expected in the cache.
|
||||||
|
Recommended is 20 (fast disk array) to 50 (slower hard disks). Default is 0.
|
||||||
|
See <a href=http://www.dba-oracle.com/oracle_tips_cbo_part1.htm>optimizer_index_caching</a>.';
|
||||||
|
}
|
||||||
|
|
||||||
function PGA()
|
function PGA()
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// $CVSHeader$
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
||||||
Contributed by Ross Smith (adodb@netebb.com).
|
Contributed by Ross Smith (adodb@netebb.com).
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// $CVSHeader$
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// $CVSHeader$
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// $CVSHeader$
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// $CVSHeader$
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
||||||
Contributed by Ross Smith (adodb@netebb.com).
|
Contributed by Ross Smith (adodb@netebb.com).
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// $CVSHeader$
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
||||||
Contributed by Ross Smith (adodb@netebb.com).
|
Contributed by Ross Smith (adodb@netebb.com).
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// $CVSHeader$
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// $CVSHeader$
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
|
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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,11 +18,11 @@ include("$path/../adodb.inc.php");
|
|||||||
echo "<h3>PHP ".PHP_VERSION."</h3>\n";
|
echo "<h3>PHP ".PHP_VERSION."</h3>\n";
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$dbt = 'mysqli';
|
$dbt = 'oci8po';
|
||||||
|
|
||||||
switch($dbt) {
|
switch($dbt) {
|
||||||
case 'oci8':
|
case 'oci8po':
|
||||||
$db = NewADOConnection("oci8");
|
$db = NewADOConnection("oci8po");
|
||||||
$db->Connect('','scott','natsoft');
|
$db->Connect('','scott','natsoft');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -32,23 +32,26 @@ case 'mysql':
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'mysqli':
|
case 'mysqli':
|
||||||
$db = NewADOConnection("mysqli");
|
$db = NewADOConnection("mysqli://root:@localhost/test");
|
||||||
$db->Connect('localhost','root','','test');
|
//$db->Connect('localhost','root','','test');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->debug=1;
|
$db->debug=1;
|
||||||
|
|
||||||
$cnt = $db->GetOne("select count(*) from adoxyz");
|
$cnt = $db->GetOne("select count(*) from adoxyz where ?<id and id<?",array(10,20));
|
||||||
$rs = $db->Execute("select * from adoxyz order by id");
|
$stmt = $db->Prepare("select * from adoxyz where ?<id and id<?");
|
||||||
|
if (!$stmt) echo $db->ErrorMsg(),"\n";
|
||||||
|
$rs = $db->Execute($stmt,array(10,20));
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach($rs as $v) {
|
foreach($rs as $v) {
|
||||||
$i += 1;
|
$i += 1;
|
||||||
echo "$i: "; adodb_pr($v); adodb_pr($rs->fields);
|
echo "rec $i: "; adodb_pr($v); adodb_pr($rs->fields);
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n");
|
if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n");
|
||||||
|
|
||||||
|
|
||||||
@ -60,4 +63,6 @@ $rs = $db->Execute("select bad from badder");
|
|||||||
$e = adodb_backtrace($e->gettrace());
|
$e = adodb_backtrace($e->gettrace());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$rs = $db->Execute("select distinct id, firstname,lastname from adoxyz order by id");
|
||||||
|
echo "Result=\n",$rs;
|
||||||
?>
|
?>
|
@ -18,10 +18,10 @@ $schema = new adoSchema( $db );
|
|||||||
// uncomment the following line:
|
// uncomment the following line:
|
||||||
#$schema->upgradeSchema();
|
#$schema->upgradeSchema();
|
||||||
|
|
||||||
|
print "<b>SQL to build xmlschema.xml</b>:\n<pre>";
|
||||||
// Build the SQL array
|
// Build the SQL array
|
||||||
$sql = $schema->ParseSchema( "xmlschema.xml" );
|
$sql = $schema->ParseSchema( "xmlschema.xml" );
|
||||||
|
|
||||||
print "Here's the SQL to do the build:\n<pre>";
|
|
||||||
print_r( $sql );
|
print_r( $sql );
|
||||||
print "</pre>\n";
|
print "</pre>\n";
|
||||||
|
|
||||||
@ -38,10 +38,12 @@ $db2->Connect('localhost','sa','natsoft','northwind') || die("Fail 2");
|
|||||||
|
|
||||||
$db2->Execute("drop table simple_table");
|
$db2->Execute("drop table simple_table");
|
||||||
|
|
||||||
|
|
||||||
|
print "<b>SQL to build xmlschema-mssql.xml</b>:\n<pre>";
|
||||||
|
|
||||||
$schema = new adoSchema( $db2 );
|
$schema = new adoSchema( $db2 );
|
||||||
$sql = $schema->ParseSchema( "xmlschema-mssql.xml" );
|
$sql = $schema->ParseSchema( "xmlschema-mssql.xml" );
|
||||||
|
|
||||||
print "Here's the SQL to do the build:\n<pre>";
|
|
||||||
print_r( $sql );
|
print_r( $sql );
|
||||||
print "</pre>\n";
|
print "</pre>\n";
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -138,7 +138,7 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to
|
|||||||
print "<br><i>ts4</i> =".($db->UnixTimeStamp("19700101000101")+8*3600);
|
print "<br><i>ts4</i> =".($db->UnixTimeStamp("19700101000101")+8*3600);
|
||||||
print "<br><i>ts5</i> =".$db->DBTimeStamp($db->UnixTimeStamp("20040110092123"));
|
print "<br><i>ts5</i> =".$db->DBTimeStamp($db->UnixTimeStamp("20040110092123"));
|
||||||
print "<br><i>ts6</i> =".$db->UserTimeStamp("20040110092123");
|
print "<br><i>ts6</i> =".$db->UserTimeStamp("20040110092123");
|
||||||
print "<br><i>ts6</i> =".$db->DBTimeStamp("20040110092123");
|
print "<br><i>ts7</i> =".$db->DBTimeStamp("20040110092123");
|
||||||
flush();
|
flush();
|
||||||
// mssql too slow in failing bad connection
|
// mssql too slow in failing bad connection
|
||||||
if (false && $db->databaseType != 'mssql') {
|
if (false && $db->databaseType != 'mssql') {
|
||||||
@ -151,7 +151,7 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to
|
|||||||
}
|
}
|
||||||
error_reporting($e);
|
error_reporting($e);
|
||||||
flush();
|
flush();
|
||||||
|
|
||||||
//$ADODB_COUNTRECS=false;
|
//$ADODB_COUNTRECS=false;
|
||||||
$rs=$db->Execute('select * from adoxyz order by id');
|
$rs=$db->Execute('select * from adoxyz order by id');
|
||||||
|
|
||||||
@ -410,6 +410,43 @@ GO
|
|||||||
$saved = $db->debug;
|
$saved = $db->debug;
|
||||||
$db->debug=true;
|
$db->debug=true;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
CREATE TABLE PHOTOS
|
||||||
|
(
|
||||||
|
ID NUMBER(16),
|
||||||
|
PHOTO BLOB,
|
||||||
|
DESCRIPTION VARCHAR2(4000 BYTE),
|
||||||
|
DESCCLOB CLOB
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO PHOTOS (ID) VALUES(1);
|
||||||
|
*/
|
||||||
|
$s = '';
|
||||||
|
for ($i = 0; $i <= 500; $i++) {
|
||||||
|
$s .= '1234567890';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
print "<h4>Testing Blob: size=".strlen($s)."</h4>";
|
||||||
|
$ok = $db->Updateblob('photos','photo',$s,'id=1');
|
||||||
|
if (!$ok) Err("Blob failed 1");
|
||||||
|
else {
|
||||||
|
$s2= $db->GetOne("select photo from photos where id=1");
|
||||||
|
if ($s !== $s2) Err("updateblob does not match");
|
||||||
|
}
|
||||||
|
|
||||||
|
print "<h4>Testing Clob: size=".strlen($s)."</h4>";
|
||||||
|
$ok = $db->UpdateClob('photos','descclob',$s,'id=1');
|
||||||
|
if (!$ok) Err("Clob failed 1");
|
||||||
|
else {
|
||||||
|
$s2= $db->GetOne("select descclob from photos where id=1");
|
||||||
|
if ($s !== $s2) Err("updateclob does not match");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$s = '';
|
||||||
|
$s2 = '';
|
||||||
print "<h4>Testing Foreign Keys</h4>";
|
print "<h4>Testing Foreign Keys</h4>";
|
||||||
$arr = $db->MetaForeignKeys('emp');
|
$arr = $db->MetaForeignKeys('emp');
|
||||||
print_r($arr);
|
print_r($arr);
|
||||||
@ -417,30 +454,50 @@ GO
|
|||||||
print "<h4>Testing Cursor Variables</h4>";
|
print "<h4>Testing Cursor Variables</h4>";
|
||||||
/*
|
/*
|
||||||
-- TEST PACKAGE
|
-- TEST PACKAGE
|
||||||
CREATE OR REPLACE PACKAGE adodb AS
|
|
||||||
TYPE TabType IS REF CURSOR RETURN tab%ROWTYPE;
|
CREATE OR REPLACE PACKAGE Adodb AS
|
||||||
PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames in varchar);
|
TYPE TabType IS REF CURSOR RETURN TAB%ROWTYPE;
|
||||||
PROCEDURE data_out(input IN varchar, output OUT varchar);
|
PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames IN VARCHAR);
|
||||||
END adodb;
|
PROCEDURE open_tab2 (tabcursor IN OUT TabType,tablenames IN OUT VARCHAR) ;
|
||||||
|
PROCEDURE data_out(input IN VARCHAR, output OUT VARCHAR);
|
||||||
|
|
||||||
|
PROCEDURE myproc (p1 IN NUMBER, p2 OUT NUMBER);
|
||||||
|
END Adodb;
|
||||||
/
|
/
|
||||||
|
|
||||||
CREATE OR REPLACE PACKAGE BODY adodb AS
|
|
||||||
PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames in varchar) IS
|
CREATE OR REPLACE PACKAGE BODY Adodb AS
|
||||||
|
PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames IN VARCHAR) IS
|
||||||
BEGIN
|
BEGIN
|
||||||
OPEN tabcursor FOR SELECT * FROM tab where tname like tablenames;
|
OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames;
|
||||||
END open_tab;
|
END open_tab;
|
||||||
|
|
||||||
|
PROCEDURE open_tab2 (tabcursor IN OUT TabType,tablenames IN OUT VARCHAR) IS
|
||||||
|
BEGIN
|
||||||
|
OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames;
|
||||||
|
tablenames := 'TEST';
|
||||||
|
END open_tab2;
|
||||||
|
|
||||||
PROCEDURE data_out(input IN varchar, output OUT varchar) IS
|
PROCEDURE data_out(input IN VARCHAR, output OUT VARCHAR) IS
|
||||||
BEGIN
|
BEGIN
|
||||||
output := 'Cinta Hati '||input;
|
output := 'Cinta Hati '||input;
|
||||||
END;
|
END;
|
||||||
END adodb;
|
|
||||||
|
PROCEDURE myproc (p1 IN NUMBER, p2 OUT NUMBER) AS
|
||||||
|
BEGIN
|
||||||
|
p2 := p1;
|
||||||
|
END;
|
||||||
|
END Adodb;
|
||||||
/
|
/
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
$rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:RS,'A%'); END;");
|
$rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:zz,'A%'); END;",'zz');
|
||||||
|
|
||||||
if ($rs && !$rs->EOF) {
|
if ($rs && !$rs->EOF) {
|
||||||
print "Test 1 RowCount: ".$rs->RecordCount()."<p>";
|
$v = $db->GetOne("SELECT count(*) FROM tab where tname like 'A%'");
|
||||||
|
if ($v == $rs->RecordCount()) print "Test 1 RowCount: OK<p>";
|
||||||
|
else Err("Test 1 RowCount ".$rs->RecordCount().", actual = $v");
|
||||||
} else {
|
} else {
|
||||||
print "<b>Error in using Cursor Variables 1</b><p>";
|
print "<b>Error in using Cursor Variables 1</b><p>";
|
||||||
}
|
}
|
||||||
@ -488,6 +545,7 @@ END adodb;
|
|||||||
$db->CompleteTrans();
|
$db->CompleteTrans();
|
||||||
$rs = $db->Execute('select * from ADOXYZ order by id');
|
$rs = $db->Execute('select * from ADOXYZ order by id');
|
||||||
if ($rs->RecordCount() != 3) Err("Bad bulk insert");
|
if ($rs->RecordCount() != 3) Err("Bad bulk insert");
|
||||||
|
|
||||||
rs2html($rs);
|
rs2html($rs);
|
||||||
|
|
||||||
$db->Execute('delete from ADOXYZ');
|
$db->Execute('delete from ADOXYZ');
|
||||||
@ -749,8 +807,20 @@ END adodb;
|
|||||||
$db->debug = true;
|
$db->debug = true;
|
||||||
print "<p>SelectLimit Distinct Test 1: Should see Caroline, John and Mary</p>";
|
print "<p>SelectLimit Distinct Test 1: Should see Caroline, John and Mary</p>";
|
||||||
$rs = &$db->SelectLimit('select distinct * from ADOXYZ order by id',3);
|
$rs = &$db->SelectLimit('select distinct * from ADOXYZ order by id',3);
|
||||||
|
|
||||||
|
echo "<p>Date Update Test</p>";
|
||||||
|
$zdate = date('Y-m-d',time()+3600*24);
|
||||||
|
$zdate = $db->DBDate($zdate);
|
||||||
|
$db->Execute("update ADOXYZ set created=$zdate where id=1");
|
||||||
|
$row = $db->GetRow("select created,firstname from ADOXYZ where id=1");
|
||||||
|
print_r($row); echo "<br>";
|
||||||
|
|
||||||
|
//$zdate = date('Y-m-d',time()+3600*24);
|
||||||
|
//$db->Execute("update ADOXYZ set created=? where id=2",$zdate);
|
||||||
|
//$zdate = $db->GetOne("select created from ADOXYZ where id=2");
|
||||||
|
//echo "tomorrow=",$zdate,"<br>";
|
||||||
$db->debug=false;
|
$db->debug=false;
|
||||||
|
|
||||||
if ($rs && !$rs->EOF) {
|
if ($rs && !$rs->EOF) {
|
||||||
if (trim($rs->fields[1]) != 'Caroline') Err("Error 1");
|
if (trim($rs->fields[1]) != 'Caroline') Err("Error 1");
|
||||||
$rs->MoveNext();
|
$rs->MoveNext();
|
||||||
@ -854,10 +924,10 @@ END adodb;
|
|||||||
$save = $ADODB_FETCH_MODE;
|
$save = $ADODB_FETCH_MODE;
|
||||||
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
|
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
|
||||||
if ($db->dataProvider == 'postgres') {
|
if ($db->dataProvider == 'postgres') {
|
||||||
$sql = "select ".$db->Concat('cast(firstname as varchar)',$db->qstr(' '),'lastname')." as fullname,id from ADOXYZ";
|
$sql = "select ".$db->Concat('cast(firstname as varchar)',$db->qstr(' '),'lastname')." as fullname,id,".$db->sysTimeStamp." as d from ADOXYZ";
|
||||||
$rs = &$db->Execute($sql);
|
$rs = &$db->Execute($sql);
|
||||||
} else {
|
} else {
|
||||||
$sql = "select distinct ".$db->Concat('firstname',$db->qstr(' '),'lastname')." as fullname,id from ADOXYZ";
|
$sql = "select distinct ".$db->Concat('firstname',$db->qstr(' '),'lastname')." as fullname,id,".$db->sysTimeStamp." as d from ADOXYZ";
|
||||||
$rs = &$db->Execute($sql);
|
$rs = &$db->Execute($sql);
|
||||||
}
|
}
|
||||||
if ($rs) {
|
if ($rs) {
|
||||||
@ -904,12 +974,12 @@ END adodb;
|
|||||||
//$arr = $db->GetArray("select lastname,firstname from ADOXYZ");
|
//$arr = $db->GetArray("select lastname,firstname from ADOXYZ");
|
||||||
//print_r($arr);
|
//print_r($arr);
|
||||||
print "<hr>";
|
print "<hr>";
|
||||||
$rs =& $db->Execute("select distinct lastname,firstname from ADOXYZ");
|
$rs =& $db->Execute("select distinct lastname,firstname,created from ADOXYZ");
|
||||||
|
|
||||||
if ($rs) {
|
if ($rs) {
|
||||||
$arr = $rs->GetAssoc();
|
$arr = $rs->GetAssoc();
|
||||||
//print_r($arr);
|
//print_r($arr);
|
||||||
if (empty($arr['See']) || trim($arr['See']) != 'Wai Hun') print $arr['See']." <b>ERROR</b><br>";
|
if (empty($arr['See']) || trim(reset($arr['See'])) != 'Wai Hun') print $arr['See']." <b>ERROR</b><br>";
|
||||||
else print " OK 1";
|
else print " OK 1";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1433,7 +1503,7 @@ if (isset($_SERVER['argv'][1])) {
|
|||||||
$HTTP_GET_VARS[$_SERVER['argv'][1]] = 1;
|
$HTTP_GET_VARS[$_SERVER['argv'][1]] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( @$HTTP_SERVER_VARS['COMPUTERNAME'] == 'TIGRESS') {
|
if (@$HTTP_SERVER_VARS['COMPUTERNAME'] == 'TIGRESS') {
|
||||||
CheckWS('mysqlt');
|
CheckWS('mysqlt');
|
||||||
CheckWS('postgres');
|
CheckWS('postgres');
|
||||||
CheckWS('oci8po');
|
CheckWS('oci8po');
|
||||||
@ -1478,7 +1548,7 @@ if (strpos(PHP_VERSION,'5') === 0) {
|
|||||||
|
|
||||||
This script tests the following databases: Interbase, Oracle, Visual FoxPro, Microsoft Access (ODBC and ADO), MySQL, MSSQL (ODBC, native, ADO).
|
This script tests the following databases: Interbase, Oracle, Visual FoxPro, Microsoft Access (ODBC and ADO), MySQL, MSSQL (ODBC, native, ADO).
|
||||||
There is also support for Sybase, PostgreSQL.</p>
|
There is also support for Sybase, PostgreSQL.</p>
|
||||||
For the latest version of ADODB, visit <a href=http://php.weblogs.com/ADODB>php.weblogs.com</a>.</p>
|
For the latest version of ADODB, visit <a href=http://adodb.sourceforge.net/>adodb.sourceforge.net</a>.</p>
|
||||||
|
|
||||||
Test <a href=test4.php>GetInsertSQL/GetUpdateSQL</a>
|
Test <a href=test4.php>GetInsertSQL/GetUpdateSQL</a>
|
||||||
<a href=testsessions.php>Sessions</a>
|
<a href=testsessions.php>Sessions</a>
|
||||||
@ -1489,8 +1559,9 @@ include('./testdatabases.inc.php');
|
|||||||
|
|
||||||
echo "<br>vers=",ADOConnection::Version();
|
echo "<br>vers=",ADOConnection::Version();
|
||||||
|
|
||||||
|
|
||||||
include_once('../adodb-time.inc.php');
|
include_once('../adodb-time.inc.php');
|
||||||
adodb_date_test();
|
if (!isset($_GET['nd'])) adodb_date_test();
|
||||||
?>
|
?>
|
||||||
<p><i>ADODB Database Library (c) 2000-2004 John Lim. All rights reserved. Released under BSD and LGPL.</i></p>
|
<p><i>ADODB Database Library (c) 2000-2004 John Lim. All rights reserved. Released under BSD and LGPL.</i></p>
|
||||||
</body>
|
</body>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -63,7 +63,7 @@ if ($insertSQL != $insertSQL2) echo "<p><b>Walt's new stuff failed</b>: $insertS
|
|||||||
|
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM ADOXYZ WHERE lastname=".$conn->qstr($record['lastname']);
|
FROM ADOXYZ WHERE lastname=".$conn->qstr($record['lastname']). " ORDER BY 1";
|
||||||
// Select a record to update
|
// Select a record to update
|
||||||
|
|
||||||
$rs = $conn->Execute($sql); // Execute the query and get the existing record to update
|
$rs = $conn->Execute($sql); // Execute the query and get the existing record to update
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -57,7 +57,7 @@ if (!empty($testpostgres)) {
|
|||||||
|
|
||||||
$db = &ADONewConnection('postgres');
|
$db = &ADONewConnection('postgres');
|
||||||
print "<h1>Connecting $db->databaseType...</h1>";
|
print "<h1>Connecting $db->databaseType...</h1>";
|
||||||
if (@$db->Connect("localhost","tester","test","test")) {
|
if ($db->Connect("localhost","tester","test","test")) {
|
||||||
testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname varchar,created date)");
|
testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname varchar,created date)");
|
||||||
}else
|
}else
|
||||||
print "ERROR: PostgreSQL requires a database called test on server, user tester, password test.<BR>".$db->ErrorMsg();
|
print "ERROR: PostgreSQL requires a database called test on server, user tester, password test.<BR>".$db->ErrorMsg();
|
||||||
@ -80,7 +80,7 @@ if (!empty($testibase)) {
|
|||||||
//$_GET['nolog'] = true;
|
//$_GET['nolog'] = true;
|
||||||
$db = &ADONewConnection('firebird');
|
$db = &ADONewConnection('firebird');
|
||||||
print "<h1>Connecting $db->databaseType...</h1>";
|
print "<h1>Connecting $db->databaseType...</h1>";
|
||||||
if (@$db->PConnect("localhost:d:\\firebird\\10\\examples\\employee.gdb", "sysdba", "masterkey", ""))
|
if ($db->PConnect("localhost:d:\\firebird\\10\\examples\\employee.gdb", "sysdba", "masterkey", ""))
|
||||||
testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname char(24),price numeric(12,2),created date)");
|
testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname char(24),price numeric(12,2),created date)");
|
||||||
else print "ERROR: Interbase test requires a database called employee.gdb".'<BR>'.$db->ErrorMsg();
|
else print "ERROR: Interbase test requires a database called employee.gdb".'<BR>'.$db->ErrorMsg();
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ if (!empty($testsqlite)) {
|
|||||||
$db = &ADONewConnection('sqlite');
|
$db = &ADONewConnection('sqlite');
|
||||||
print "<h1>Connecting $db->databaseType...</h1>";
|
print "<h1>Connecting $db->databaseType...</h1>";
|
||||||
|
|
||||||
if (@$db->PConnect("d:\\inetpub\\adodb\\sqlite.db", "", "", ""))
|
if ($db->PConnect("d:\\inetpub\\adodb\\sqlite.db", "", "", ""))
|
||||||
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
|
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
|
||||||
else print "ERROR: SQLite";
|
else print "ERROR: SQLite";
|
||||||
|
|
||||||
@ -101,10 +101,12 @@ if (!empty($testsqlite)) {
|
|||||||
if (!empty($testaccess)) {
|
if (!empty($testaccess)) {
|
||||||
$db = &ADONewConnection('access');
|
$db = &ADONewConnection('access');
|
||||||
print "<h1>Connecting $db->databaseType...</h1>";
|
print "<h1>Connecting $db->databaseType...</h1>";
|
||||||
|
$access = 'd:\inetpub\wwwroot\php\NWIND.MDB';
|
||||||
$dsn = "nwind";
|
$dsn = "nwind";
|
||||||
$driver = "Driver={Microsoft Access Driver (*.mdb)};Dbq=d:\inetpub\adodb\northwind.mdb;Uid=Admin;Pwd=;";
|
$dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=$access;Uid=Admin;Pwd=;";
|
||||||
if (@$db->PConnect($dsn, "", "", ""))
|
|
||||||
|
//$dsn = 'Provider=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=' . $access . ';';
|
||||||
|
if ($db->PConnect($dsn, "", "", ""))
|
||||||
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
|
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
|
||||||
else print "ERROR: Access test requires a Windows ODBC DSN=nwind, Access driver";
|
else print "ERROR: Access test requires a Windows ODBC DSN=nwind, Access driver";
|
||||||
|
|
||||||
@ -120,7 +122,7 @@ if (!empty($testaccess) && !empty($testado)) { // ADO ACCESS
|
|||||||
. 'DATA SOURCE=' . $access . ';';
|
. 'DATA SOURCE=' . $access . ';';
|
||||||
//. 'USER ID=;PASSWORD=;';
|
//. 'USER ID=;PASSWORD=;';
|
||||||
|
|
||||||
if (@$db->PConnect($myDSN, "", "", "")) {
|
if ($db->PConnect($myDSN, "", "", "")) {
|
||||||
print "ADO version=".$db->_connectionID->version."<br>";
|
print "ADO version=".$db->_connectionID->version."<br>";
|
||||||
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
|
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
|
||||||
} else print "ERROR: Access test requires a Access database $access".'<BR>'.$db->ErrorMsg();
|
} else print "ERROR: Access test requires a Access database $access".'<BR>'.$db->ErrorMsg();
|
||||||
@ -141,11 +143,14 @@ if (!empty($testvfp)) { // ODBC
|
|||||||
// REQUIRES MySQL server at localhost with database 'test'
|
// REQUIRES MySQL server at localhost with database 'test'
|
||||||
if (!empty($testmysql)) { // MYSQL
|
if (!empty($testmysql)) { // MYSQL
|
||||||
|
|
||||||
$db = &ADONewConnection('mysql');
|
|
||||||
print "<h1>Connecting $db->databaseType...</h1>";
|
|
||||||
if (PHP_VERSION >= 5 || $HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost';
|
if (PHP_VERSION >= 5 || $HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost';
|
||||||
else $server = "mangrove";
|
else $server = "mangrove";
|
||||||
if ($db->PConnect($server, "root", "", "northwind")) {
|
$user = 'root'; $password = ''; $database = 'northwind';
|
||||||
|
$db = &ADONewConnection("mysql://$user:$password@$server/$database?persist");
|
||||||
|
print "<h1>Connecting $db->databaseType...</h1>";
|
||||||
|
|
||||||
|
if (true || $db->PConnect($server, "root", "", "northwind")) {
|
||||||
//$db->debug=1;$db->Execute('drop table ADOXYZ');
|
//$db->debug=1;$db->Execute('drop table ADOXYZ');
|
||||||
testdb($db,
|
testdb($db,
|
||||||
"create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)");
|
"create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)");
|
||||||
@ -195,12 +200,11 @@ if (!empty($testproxy)){
|
|||||||
|
|
||||||
ADOLoadCode('oci805');
|
ADOLoadCode('oci805');
|
||||||
ADOLoadCode("oci8po");
|
ADOLoadCode("oci8po");
|
||||||
if (!empty($testoracle)) {
|
if (!empty($testoracle)) {
|
||||||
|
$dsn = "oci8po://scott:natsoft@panther?persist";
|
||||||
$db = ADONewConnection('oci8po');
|
$db = ADONewConnection($dsn);
|
||||||
print "<h1>Connecting $db->databaseType...</h1>";
|
print "<h1>Connecting $db->databaseType...</h1>";
|
||||||
if ($db->Connect('', "scott", "natsoft",''))
|
if (true || $db->Connect('', "scott", "natsoft",''))
|
||||||
//if ($db->PConnect("", "scott", "tiger", "juris.ecosystem.natsoft.com.my"))
|
|
||||||
testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)");
|
testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)");
|
||||||
else print "ERROR: Oracle test requires an Oracle server setup with scott/natsoft".'<BR>'.$db->ErrorMsg();
|
else print "ERROR: Oracle test requires an Oracle server setup with scott/natsoft".'<BR>'.$db->ErrorMsg();
|
||||||
|
|
||||||
@ -234,10 +238,9 @@ if (!empty($testmssql)) { // MS SQL Server via ODBC
|
|||||||
|
|
||||||
print "<h1>Connecting $db->databaseType...</h1>";
|
print "<h1>Connecting $db->databaseType...</h1>";
|
||||||
|
|
||||||
$dsn = "mssql-northwind";
|
$dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=localhost;Database=northwind;";
|
||||||
$dsn = "Driver={SQL Server};Server=localhost;Database=northwind;";
|
|
||||||
|
|
||||||
if (@$db->PConnect($dsn, "adodb", "natsoft", "")) {
|
if ($db->PConnect($dsn, "adodb", "natsoft", "")) {
|
||||||
testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
|
testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
|
||||||
}
|
}
|
||||||
else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup";
|
else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup";
|
||||||
@ -256,7 +259,7 @@ if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC
|
|||||||
. "SERVER=tigress;DATABASE=NorthWind;UID=adodb;PWD=natsoft;Trusted_Connection=No" ;
|
. "SERVER=tigress;DATABASE=NorthWind;UID=adodb;PWD=natsoft;Trusted_Connection=No" ;
|
||||||
|
|
||||||
|
|
||||||
if (@$db->PConnect($myDSN, "", "", ""))
|
if ($db->PConnect($myDSN, "", "", ""))
|
||||||
testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
|
testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
|
||||||
else print "ERROR: MSSQL test 2 requires MS SQL 7";
|
else print "ERROR: MSSQL test 2 requires MS SQL 7";
|
||||||
|
|
||||||
@ -270,11 +273,8 @@ if (!empty($testmssql)) { // MS SQL Server -- the extension is buggy -- probably
|
|||||||
print "<h1>Connecting $db->databaseType...</h1>";
|
print "<h1>Connecting $db->databaseType...</h1>";
|
||||||
|
|
||||||
$ok = $db->PConnect('tigress','adodb','natsoft','northwind');
|
$ok = $db->PConnect('tigress','adodb','natsoft','northwind');
|
||||||
//$rs = $db->Execute("exec sp_ddate");
|
|
||||||
//print_r($rs->fields);
|
|
||||||
//die();
|
|
||||||
|
|
||||||
if ($ok or @$db->PConnect("mangrove", "sa", "natsoft", "ai")) {
|
if ($ok or $db->PConnect("mangrove", "sa", "natsoft", "ai")) {
|
||||||
AutoDetect_MSSQL_Date_Order($db);
|
AutoDetect_MSSQL_Date_Order($db);
|
||||||
// $db->Execute('drop table adoxyz');
|
// $db->Execute('drop table adoxyz');
|
||||||
testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
|
testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
|
||||||
@ -288,7 +288,6 @@ if (!empty($testmssql) && !empty($testado)) { // ADO ACCESS MSSQL with OLEDB pro
|
|||||||
print "<h1>Connecting DSN-less OLEDB Provider $db->databaseType...</h1>";
|
print "<h1>Connecting DSN-less OLEDB Provider $db->databaseType...</h1>";
|
||||||
//$db->debug=1;
|
//$db->debug=1;
|
||||||
$myDSN="SERVER=tigress;DATABASE=northwind;Trusted_Connection=yes";
|
$myDSN="SERVER=tigress;DATABASE=northwind;Trusted_Connection=yes";
|
||||||
//$myDSN='SERVER=(local)\NetSDK;DATABASE=northwind;';
|
|
||||||
if ($db->PConnect($myDSN, "adodb", "natsoft", 'SQLOLEDB'))
|
if ($db->PConnect($myDSN, "adodb", "natsoft", 'SQLOLEDB'))
|
||||||
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
|
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
|
||||||
else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='mangrove', userid='sa', password='', database='ai'";
|
else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='mangrove', userid='sa', password='', database='ai'";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -14,7 +14,7 @@ error_reporting(63);
|
|||||||
include("../adodb.inc.php");
|
include("../adodb.inc.php");
|
||||||
include("../tohtml.inc.php");
|
include("../tohtml.inc.php");
|
||||||
|
|
||||||
if (1) {
|
if (0) {
|
||||||
$db = ADONewConnection('oci8po');
|
$db = ADONewConnection('oci8po');
|
||||||
|
|
||||||
$db->PConnect('','scott','natsoft');
|
$db->PConnect('','scott','natsoft');
|
||||||
@ -44,7 +44,7 @@ if (1) {
|
|||||||
}
|
}
|
||||||
if (1) {
|
if (1) {
|
||||||
$db = ADONewConnection('oci8');
|
$db = ADONewConnection('oci8');
|
||||||
$db->PConnect('','scott','tiger');
|
$db->PConnect('','scott','natsoft');
|
||||||
$db->debug = true;
|
$db->debug = true;
|
||||||
$db->Execute("delete from emp where ename='John'");
|
$db->Execute("delete from emp where ename='John'");
|
||||||
print $db->Affected_Rows().'<BR>';
|
print $db->Affected_Rows().'<BR>';
|
||||||
@ -53,6 +53,20 @@ if (1) {
|
|||||||
// prepare not quite ready for prime time
|
// prepare not quite ready for prime time
|
||||||
//$rs = $db->Execute($stmt,array('empno'=>3775,'ename'=>'John'));
|
//$rs = $db->Execute($stmt,array('empno'=>3775,'ename'=>'John'));
|
||||||
if (!$rs) die("Empty RS");
|
if (!$rs) die("Empty RS");
|
||||||
|
|
||||||
|
$db->setfetchmode(ADODB_FETCH_NUM);
|
||||||
|
|
||||||
|
$vv = 'A%';
|
||||||
|
$stmt = $db->PrepareSP("BEGIN adodb.open_tab2(:rs,:tt); END;",true);
|
||||||
|
$db->OutParameter($stmt, $cur, 'rs', -1, OCI_B_CURSOR);
|
||||||
|
$db->OutParameter($stmt, $vv, 'tt');
|
||||||
|
$rs = $db->Execute($stmt);
|
||||||
|
while (!$rs->EOF) {
|
||||||
|
adodb_pr($rs->fields);
|
||||||
|
$rs->MoveNext();
|
||||||
|
}
|
||||||
|
echo " val = $vv";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0) {
|
if (0) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
@ -19,12 +19,19 @@ function NotifyExpire($ref,$key)
|
|||||||
|
|
||||||
|
|
||||||
#### CONNECTION
|
#### CONNECTION
|
||||||
|
if (1) {
|
||||||
$ADODB_SESSION_DRIVER='oci8';
|
$ADODB_SESSION_DRIVER='oci8';
|
||||||
$ADODB_SESSION_CONNECT='';
|
$ADODB_SESSION_CONNECT='';
|
||||||
$ADODB_SESSION_USER ='scott';
|
$ADODB_SESSION_USER ='scott';
|
||||||
$ADODB_SESSION_PWD ='natsoft';
|
$ADODB_SESSION_PWD ='natsoft';
|
||||||
$ADODB_SESSION_DB ='';
|
$ADODB_SESSION_DB ='';
|
||||||
|
} else {
|
||||||
|
$ADODB_SESSION_DRIVER='mysql';
|
||||||
|
$ADODB_SESSION_CONNECT='localhost';
|
||||||
|
$ADODB_SESSION_USER ='root';
|
||||||
|
$ADODB_SESSION_PWD ='';
|
||||||
|
$ADODB_SESSION_DB ='xphplens_2';
|
||||||
|
}
|
||||||
|
|
||||||
### TURN DEBUGGING ON
|
### TURN DEBUGGING ON
|
||||||
$ADODB_SESS_DEBUG = true;
|
$ADODB_SESS_DEBUG = true;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
|
V4.51 29 July 2004 (c) 2000-2004 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.
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
<!DOCTYPE adodb_schema [
|
<!DOCTYPE adodb_schema [
|
||||||
<!ELEMENT schema (table*, sql*)>
|
<!ELEMENT schema (table*, sql*)>
|
||||||
<!ATTLIST schema version CDATA #REQUIRED>
|
<!ATTLIST schema version CDATA #REQUIRED>
|
||||||
<!ELEMENT table ((field+|DROP), constraint*, descr?, index*)>
|
<!ELEMENT table ((field+|DROP), constraint*, descr?, index*, data*)>
|
||||||
<!ELEMENT field ((NOTNULL|KEY|PRIMARY)?, (AUTO|AUTOINCREMENT)?, (DEFAULT|DEFDATE|DEFTIMESTAMP)?, NOQUOTE, constraint, descr?)>
|
<!ELEMENT field ((NOTNULL|KEY|PRIMARY)?, (AUTO|AUTOINCREMENT)?, (DEFAULT|DEFDATE|DEFTIMESTAMP)?, NOQUOTE, constraint, descr?)>
|
||||||
|
<!ELEMENT data (row+)>
|
||||||
|
<!ELEMENT row (f+)>
|
||||||
|
<!ELEMENT f (#CDATA)>
|
||||||
<!ELEMENT descr (#CDATA)>
|
<!ELEMENT descr (#CDATA)>
|
||||||
<!ELEMENT NOTNULL EMPTY>
|
<!ELEMENT NOTNULL EMPTY>
|
||||||
<!ELEMENT KEY EMPTY>
|
<!ELEMENT KEY EMPTY>
|
||||||
@ -18,6 +21,8 @@
|
|||||||
<!ELEMENT constraint (#CDATA)>
|
<!ELEMENT constraint (#CDATA)>
|
||||||
<!ATTLIST table name CDATA #REQUIRED platform CDATA #IMPLIED version CDATA #IMPLIED>
|
<!ATTLIST table name CDATA #REQUIRED platform CDATA #IMPLIED version CDATA #IMPLIED>
|
||||||
<!ATTLIST field name CDATA #REQUIRED type (C|C2|X|X2|B|D|T|L|I|F|N) #REQUIRED size CDATA #IMPLIED>
|
<!ATTLIST field name CDATA #REQUIRED type (C|C2|X|X2|B|D|T|L|I|F|N) #REQUIRED size CDATA #IMPLIED>
|
||||||
|
<!ATTLIST data platform CDATA #IMPLIED>
|
||||||
|
<!ATTLIST f name CDATA #IMPLIED>
|
||||||
<!ATTLIST DEFAULT value CDATA #REQUIRED>
|
<!ATTLIST DEFAULT value CDATA #REQUIRED>
|
||||||
<!ELEMENT index ((col+|DROP), CLUSTERED?, BITMAP?, UNIQUE?, FULLTEXT?, HASH?, descr?)>
|
<!ELEMENT index ((col+|DROP), CLUSTERED?, BITMAP?, UNIQUE?, FULLTEXT?, HASH?, descr?)>
|
||||||
<!ELEMENT col (#CDATA)>
|
<!ELEMENT col (#CDATA)>
|
||||||
@ -26,7 +31,7 @@
|
|||||||
<!ELEMENT UNIQUE EMPTY>
|
<!ELEMENT UNIQUE EMPTY>
|
||||||
<!ELEMENT FULLTEXT EMPTY>
|
<!ELEMENT FULLTEXT EMPTY>
|
||||||
<!ELEMENT HASH EMPTY>
|
<!ELEMENT HASH EMPTY>
|
||||||
<!ATTLIST index name CDATA #REQUIRED>
|
<!ATTLIST index name CDATA #REQUIRED platform CDATA #IMPLIED>
|
||||||
<!ELEMENT sql (query+, descr?)>
|
<!ELEMENT sql (query+, descr?)>
|
||||||
<!ELEMENT query (#CDATA)>
|
<!ELEMENT query (#CDATA)>
|
||||||
<!ATTLIST sql name CDATA #IMPLIED platform CDATA #IMPLIED, key CDATA, prefixmethod (AUTO|MANUAL|NONE) >
|
<!ATTLIST sql name CDATA #IMPLIED platform CDATA #IMPLIED, key CDATA, prefixmethod (AUTO|MANUAL|NONE) >
|
||||||
|
54
phpgwapi/inc/adodb/xsl/remove-0.2.xsl
Normal file
54
phpgwapi/inc/adodb/xsl/remove-0.2.xsl
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<xsl:stylesheet version="1.0"
|
||||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
|
>
|
||||||
|
<xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="UTF-8"/>
|
||||||
|
|
||||||
|
<!-- Schema -->
|
||||||
|
<xsl:template match="/">
|
||||||
|
<xsl:comment>
|
||||||
|
ADODB XMLSchema
|
||||||
|
http://adodb-xmlschema.sourceforge.net
|
||||||
|
</xsl:comment>
|
||||||
|
|
||||||
|
<xsl:comment>
|
||||||
|
Uninstallation Schema
|
||||||
|
</xsl:comment>
|
||||||
|
|
||||||
|
<xsl:element name="schema">
|
||||||
|
<xsl:attribute name="version">0.2</xsl:attribute>
|
||||||
|
|
||||||
|
<xsl:apply-templates select="schema/table">
|
||||||
|
<xsl:sort select="position()" data-type="number" order="descending"/>
|
||||||
|
</xsl:apply-templates>
|
||||||
|
</xsl:element>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- Table -->
|
||||||
|
<xsl:template match="table">
|
||||||
|
<xsl:if test="count(DROP) = 0">
|
||||||
|
<xsl:element name="table">
|
||||||
|
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
|
||||||
|
|
||||||
|
<xsl:if test="string-length(@platform) > 0">
|
||||||
|
<xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
|
||||||
|
</xsl:if>
|
||||||
|
|
||||||
|
<xsl:if test="string-length(@version) > 0">
|
||||||
|
<xsl:attribute name="version"><xsl:value-of select="@version"/></xsl:attribute>
|
||||||
|
</xsl:if>
|
||||||
|
|
||||||
|
<xsl:apply-templates select="descr[1]"/>
|
||||||
|
|
||||||
|
<xsl:element name="DROP"/>
|
||||||
|
</xsl:element>
|
||||||
|
</xsl:if>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- Description -->
|
||||||
|
<xsl:template match="descr">
|
||||||
|
<xsl:element name="descr">
|
||||||
|
<xsl:value-of select="normalize-space(text())"/>
|
||||||
|
</xsl:element>
|
||||||
|
</xsl:template>
|
||||||
|
</xsl:stylesheet>
|
Loading…
Reference in New Issue
Block a user