$ADODB_INCLUDED_CSV = 1;\r
\r
/* \r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. See License.txt. \r
$rs->InitArrayFields($arr,$flds);\r
return $rs;\r
}\r
+ \r
+\r
+ /**\r
+ * Save a file $filename and its $contents (normally for caching) with file locking\r
+ */\r
+ function adodb_write_file($filename, $contents,$debug=false)\r
+ { \r
+ # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows\r
+ # So to simulate locking, we assume that rename is an atomic operation.\r
+ # First we delete $filename, then we create a $tempfile write to it and \r
+ # rename to the desired $filename. If the rename works, then we successfully \r
+ # modified the file exclusively.\r
+ # What a stupid need - having to simulate locking.\r
+ # Risks:\r
+ # 1. $tempfile name is not unique -- very very low\r
+ # 2. unlink($filename) fails -- ok, rename will fail\r
+ # 3. adodb reads stale file because unlink fails -- ok, $rs timeout occurs\r
+ # 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated\r
+ if (strncmp(PHP_OS,'WIN',3) === 0) {\r
+ // skip the decimal place\r
+ $mtime = substr(str_replace(' ','_',microtime()),2); \r
+ // getmypid() actually returns 0 on Win98 - never mind!\r
+ $tmpname = $filename.uniqid($mtime).getmypid();\r
+ if (!($fd = fopen($tmpname,'a'))) return false;\r
+ $ok = ftruncate($fd,0); \r
+ if (!fwrite($fd,$contents)) $ok = false;\r
+ fclose($fd);\r
+ chmod($tmpname,0644);\r
+ // the tricky moment\r
+ @unlink($filename);\r
+ if (!@rename($tmpname,$filename)) {\r
+ unlink($tmpname);\r
+ $ok = false;\r
+ }\r
+ if (!$ok) {\r
+ if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed'));\r
+ }\r
+ return $ok;\r
+ }\r
+ if (!($fd = fopen($filename, 'a'))) return false;\r
+ if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) {\r
+ $ok = fwrite( $fd, $contents );\r
+ fclose($fd);\r
+ chmod($filename,0644);\r
+ }else {\r
+ fclose($fd);\r
+ if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename<br>\n");\r
+ $ok = false;\r
+ }\r
+ \r
+ return $ok;\r
+ }\r
?>
\ No newline at end of file
<?php\r
\r
/**\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
/**\r
- * @version V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ * @version V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
* Released under both BSD license and Lesser GPL library license.\r
* Whenever there is any discrepancy between the two licenses,\r
* the BSD license will take precedence.\r
<?php\r
\r
/**\r
- * @version V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ * @version V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
* Released under both BSD license and Lesser GPL library license.\r
* Whenever there is any discrepancy between the two licenses,\r
* the BSD license will take precedence.\r
<?php\r
\r
/*\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
{\r
return call_user_func_array(array($this->rs, $func), $params);\r
}\r
- \r
- function __toString()\r
- {\r
- if (isset($rs->databaseType)) $s = ' for '.$rs->databaseType;\r
- else $s = '';\r
- \r
- return 'ADODB Iterator'.$s;\r
- }\r
+\r
\r
function hasMore()\r
{\r
function getIterator() {\r
return new ADODB_Iterator($this);\r
}\r
+ \r
+ function __toString()\r
+ {\r
+ include_once(ADODB_DIR.'/toexport.inc.php');\r
+ return _adodb_export($this,',',',',false,true);\r
+ }\r
} \r
\r
?>
\ No newline at end of file
if ($uSet && $where) {\r
$update = "UPDATE $table SET $uSet WHERE $where";\r
\r
- $rs = $zthis->Execute($update);\r
+ $rs = $zthis->_Execute($update);\r
if ($rs) {\r
if ($zthis->poorAffectedRows) {\r
/*\r
\r
$cnt = $zthis->GetOne("select count(*) from $table where $where");\r
if ($cnt > 0) return 1; // record already exists\r
- } else\r
- if (($zthis->Affected_Rows()>0)) return 1;\r
+ } else {\r
+ \r
+ if (($zthis->Affected_Rows()>0)) return 1;\r
+ }\r
}\r
}\r
// print "<p>Error=".$this->ErrorNo().'<p>';\r
} \r
}\r
$insert = "INSERT INTO $table ($iCols) VALUES ($iVals)"; \r
- $rs = $zthis->Execute($insert);\r
+ $rs = $zthis->_Execute($insert);\r
return ($rs) ? 2 : 0;\r
}\r
\r
if (preg_match('/\s*UNION\s*/is', $sql)) $rewritesql = $sql;\r
else $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql); \r
\r
- $rstest = &$zthis->Execute($rewritesql,$inputarr);\r
+ $rstest = &$zthis->_Execute($rewritesql,$inputarr);\r
if ($rstest) {\r
$qryRecs = $rstest->RecordCount();\r
if ($qryRecs == -1) { \r
$lastpageno = (int) ceil($qryRecs / $nrows);\r
$zthis->_maxRecordCount = $qryRecs;\r
\r
- // If page number <= 1, then we are at the first page\r
- if (!isset($page) || $page <= 1) { \r
- $page = 1;\r
- $atfirstpage = true;\r
- }\r
+\r
\r
// ***** Here we check whether $page is the last page or \r
// whether we are trying to retrieve \r
$atlastpage = true;\r
}\r
\r
+ // If page number <= 1, then we are at the first page\r
+ if (empty($page) || $page <= 1) { \r
+ $page = 1;\r
+ $atfirstpage = true;\r
+ }\r
+ \r
// We get the data we want\r
$offset = $nrows * ($page-1);\r
if ($secs2cache > 0) \r
// If the recordset field is one\r
// of the fields passed in then process.\r
$upperfname = strtoupper($field->name);\r
- if (adodb_key_exists($upperfname,$arrFields)) {\r
+ if (adodb_key_exists($upperfname,$arrFields,$forcenulls)) {\r
\r
// If the existing field value in the recordset\r
// is different from the value passed in then\r
\r
// Based on the datatype of the field\r
// Format the value properly for the database\r
- $type = $rs->MetaType($field->type);\r
- \r
- // is_null requires php 4.0.4\r
- if (($forcenulls && is_null($arrFields[$upperfname])) || \r
- $arrFields[$upperfname] === 'null') {\r
- $setFields .= $field->name . " = null, ";\r
- } else {\r
- if ($type == 'null') {\r
- $type = 'C';\r
+ $type = $rs->MetaType($field->type);\r
+ \r
+ // is_null requires php 4.0.4\r
+ if (($forcenulls && is_null($arrFields[$upperfname])) || \r
+ $arrFields[$upperfname] === 'null') {\r
+ $setFields .= $field->name . " = null, ";\r
+ } else {\r
+ if ($type == 'null') {\r
+ $type = 'C';\r
+ }\r
+ \r
+ if (strpos($upperfname,' ') !== false)\r
+ $fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;\r
+ else\r
+ $fnameq = $upperfname;\r
+ \r
+ //we do this so each driver can customize the sql for\r
+ //DB specific column types. \r
+ //Oracle needs BLOB types to be handled with a returning clause\r
+ //postgres has special needs as well\r
+ $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,\r
+ $arrFields, $magicq);\r
}\r
- \r
- if (strpos($upperfname,' ') !== false)\r
- $fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;\r
- else\r
- $fnameq = $upperfname;\r
- //we do this so each driver can customize the sql for\r
- //DB specific column types. \r
- //Oracle needs BLOB types to be handled with a returning clause\r
- //postgres has special needs as well\r
- $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,\r
- $arrFields, $magicq);\r
}\r
}\r
}\r
- }\r
\r
// If there were any modified fields then build the rest of the update query.\r
if ($fieldUpdatedCount > 0 || $forceUpdate) {\r
\r
$discard = false;\r
// not a good hack, improvements?\r
- if ($whereClause)\r
- preg_match('/\s(LIMIT\s.*)/is', $whereClause[1], $discard);\r
- else\r
+ if ($whereClause) {\r
+ if (preg_match('/\s(ORDER\s.*)/is', $whereClause[1], $discard));\r
+ else preg_match('/\s(LIMIT\s.*)/is', $whereClause[1], $discard);\r
+ } else\r
$whereClause = array(false,false);\r
\r
if ($discard)\r
// Loop through all of the fields in the recordset\r
foreach( $columns as $field ) { \r
$upperfname = strtoupper($field->name);\r
- if (adodb_key_exists($upperfname,$arrFields)) {\r
+ if (adodb_key_exists($upperfname,$arrFields,$forcenulls)) {\r
\r
// Set the counter for the number of fields that will be inserted.\r
$fieldInsertedCount++;\r
\r
// Get the table name from the existing query.\r
if (!$tableName) {\r
- preg_match("/FROM\s+".ADODB_TABLE_REGEX."/is", $rs->sql, $tableName);\r
+ if (preg_match("/FROM\s+".ADODB_TABLE_REGEX."/is", $rs->sql, $tableName))\r
$tableName = $tableName[1];\r
+ else \r
+ return false;\r
} \r
\r
// Strip off the comma and space on the end of both the fields\r
\r
return $sql;\r
}\r
+\r
+\r
+\r
+function _adodb_debug_execute(&$zthis, $sql, $inputarr)\r
+{\r
+global $HTTP_SERVER_VARS;\r
+\r
+ $ss = '';\r
+ if ($inputarr) {\r
+ foreach($inputarr as $kk=>$vv) {\r
+ if (is_string($vv) && strlen($vv)>64) $vv = substr($vv,0,64).'...';\r
+ $ss .= "($kk=>'$vv') ";\r
+ }\r
+ $ss = "[ $ss ]";\r
+ }\r
+ $sqlTxt = str_replace(',',', ',is_array($sql) ? $sql[0] : $sql);\r
+\r
+ // check if running from browser or command-line\r
+ $inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']);\r
+ \r
+ if ($inBrowser) {\r
+ $ss = htmlspecialchars($ss);\r
+ if ($zthis->debug === -1)\r
+ ADOConnection::outp( "<br>\n($zthis->databaseType): ".htmlspecialchars($sqlTxt)." <code>$ss</code>\n<br>\n",false);\r
+ else \r
+ ADOConnection::outp( "<hr>\n($zthis->databaseType): ".htmlspecialchars($sqlTxt)." <code>$ss</code>\n<hr>\n",false);\r
+ } else {\r
+ ADOConnection::outp("-----\n($zthis->databaseType): ".$sqlTxt."\n-----\n",false);\r
+ }\r
+ \r
+ $qID = $zthis->_query($sql,$inputarr);\r
+ \r
+ /* \r
+ Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql\r
+ because ErrorNo() calls Execute('SELECT @ERROR'), causing recursion\r
+ */\r
+ if ($zthis->databaseType == 'mssql') { \r
+ // ErrorNo is a slow function call in mssql, and not reliable in PHP 4.0.6\r
+ if($emsg = $zthis->ErrorMsg()) {\r
+ if ($err = $zthis->ErrorNo()) ADOConnection::outp($err.': '.$emsg);\r
+ }\r
+ } else if (!$qID) {\r
+ ADOConnection::outp($zthis->ErrorNo() .': '. $zthis->ErrorMsg());\r
+ }\r
+ \r
+ return $qID;\r
+}\r
+\r
+\r
+function _adodb_backtrace($printOrArr=true,$levels=9999)\r
+{\r
+ if (PHPVERSION() < 4.3) return '';\r
+ \r
+ $html = (isset($_SERVER['HTTP_USER_AGENT']));\r
+ $fmt = ($html) ? "</font><font color=#808080 size=-1> %% line %4d, file: <a href=\"file:/%s\">%s</a></font>" : "%% line %4d, file: %s";\r
+\r
+ $MAXSTRLEN = 64;\r
+\r
+ $s = ($html) ? '<pre align=left>' : '';\r
+ \r
+ if (is_array($printOrArr)) $traceArr = $printOrArr;\r
+ else $traceArr = debug_backtrace();\r
+ array_shift($traceArr);\r
+ array_shift($traceArr);\r
+ $tabs = sizeof($traceArr)-2;\r
+ \r
+ foreach ($traceArr as $arr) {\r
+ $levels -= 1;\r
+ if ($levels < 0) break;\r
+ \r
+ $args = array();\r
+ for ($i=0; $i < $tabs; $i++) $s .= ($html) ? ' ' : "\t";\r
+ $tabs -= 1;\r
+ if ($html) $s .= '<font face="Courier New,Courier">';\r
+ if (isset($arr['class'])) $s .= $arr['class'].'.';\r
+ if (isset($arr['args']))\r
+ foreach($arr['args'] as $v) {\r
+ if (is_null($v)) $args[] = 'null';\r
+ else if (is_array($v)) $args[] = 'Array['.sizeof($v).']';\r
+ else if (is_object($v)) $args[] = 'Object:'.get_class($v);\r
+ else if (is_bool($v)) $args[] = $v ? 'true' : 'false';\r
+ else {\r
+ $v = (string) @$v;\r
+ $str = htmlspecialchars(substr($v,0,$MAXSTRLEN));\r
+ if (strlen($v) > $MAXSTRLEN) $str .= '...';\r
+ $args[] = $str;\r
+ }\r
+ }\r
+ $s .= $arr['function'].'('.implode(', ',$args).')';\r
+ \r
+ \r
+ $s .= @sprintf($fmt, $arr['line'],$arr['file'],basename($arr['file']));\r
+ \r
+ $s .= "\n";\r
+ } \r
+ if ($html) $s .= '</pre>';\r
+ if ($printOrArr) print $s;\r
+ \r
+ return $s;\r
+}\r
+\r
?>
\ No newline at end of file
<?php\r
\r
/*\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
if (!$this->db->pageExecuteCountRows) return '';\r
$lastPage = $this->rs->LastPageNo();\r
if ($lastPage == -1) $lastPage = 1; // check for empty rs.\r
+ if ($this->curr_page > $lastPage) $this->curr_page = 1;\r
return "<font size=-1>$this->page ".$this->curr_page."/".$lastPage."</font>";\r
}\r
\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. See License.txt. \r
\r
if (empty($HTTP_GET_VARS['hidem']))\r
echo "<table border=1 width=100% bgcolor=lightyellow><tr><td colspan=2>\r
- <b><a href=http://php.weblogs.com/adodb?perf=1>ADOdb</a> Performance Monitor</b> <font size=1>for $app</font></tr><tr><td>\r
+ <b><a href=http://adodb.sourceforge.net/?perf=1>ADOdb</a> Performance Monitor</b> <font size=1>for $app</font></tr><tr><td>\r
<a href=?do=stats><b>Performance Stats</b></a> <a href=?do=viewsql><b>View SQL</b></a>\r
<a href=?do=tables><b>View Tables</b></a> <a href=?do=poll><b>Poll Stats</b></a>",\r
$allowsql ? ' <a href=?do=dosql><b>Run SQL</b></a>' : '',\r
<?php\r
\r
/*\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
outside the 1901 to 2038 range.\r
\r
\r
-FUNCTION adodb_mktime($hr, $min, $sec, $month, $day, $year)\r
+FUNCTION adodb_mktime($hr, $min, $sec [, $month, $day, $year])\r
\r
Converts a local date to a unix timestamp. Unlike the function mktime(), it supports\r
dates outside the 1901 to 2038 range. Differs from mktime() in that all parameters\r
are currently compulsory.\r
\r
-FUNCTION adodb_gmmktime($hr, $min, $sec, $month, $day, $year)\r
+FUNCTION adodb_gmmktime($hr, $min, $sec [, $month, $day, $year])\r
\r
Converts a gmt date to a unix timestamp. Unlike the function gmmktime(), it supports\r
dates outside the 1901 to 2038 range. Differs from gmmktime() in that all parameters\r
\r
\r
CHANGELOG\r
+- 18 July 2004 0.15\r
+All params in adodb_mktime were formerly compulsory. Now only the hour, min, secs is compulsory. This\r
+brings it more in line with mktime (still not identical).\r
+\r
- 23 June 2004 0.14\r
\r
Allow you to define your own daylights savings function, adodb_daylight_sv.\r
/*\r
Version Number\r
*/\r
-define('ADODB_DATE_VERSION',0.14);\r
+define('ADODB_DATE_VERSION',0.15);\r
\r
/*\r
We check for Windows as only +ve ints are accepted as dates on Windows.\r
// This flag disables calling of PHP native functions, so we can properly test the code\r
if (!defined('ADODB_TEST_DATES')) define('ADODB_TEST_DATES',1);\r
\r
+ $t = adodb_mktime(0,0,0);\r
+ if (!(adodb_date('Y-m-d') == date('Y-m-d'))) print 'Error in '.adodb_mktime(0,0,0).'<br>';\r
+ \r
$t = adodb_mktime(0,0,0,6,1,2102);\r
if (!(adodb_date('Y-m-d',$t) == '2102-06-01')) print 'Error in '.adodb_date('Y-m-d',$t).'<br>';\r
\r
// we generate a timestamp, convert it to a date, and convert it back to a timestamp\r
// and check if the roundtrip broke the original timestamp value.\r
print "Testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: ";\r
- \r
+ $cnt = 0;\r
for ($max += $i; $i < $max; $i += $offset) {\r
$ret = adodb_date('m,d,Y,H,i,s',$i);\r
$arr = explode(',',$ret);\r
$fail = true;\r
break;\r
}\r
+ $cnt += 1;\r
}\r
- \r
+ echo "Tested $cnt dates<br>";\r
if (!$fail) print "<p>Passed !</p>";\r
else print "<p><b>Failed</b> :-(</p>";\r
}\r
*/\r
function adodb_date($fmt,$d=false,$is_gmt=false)\r
{\r
+static $daylight;\r
+\r
if ($d === false) return ($is_gmt)? @gmdate($fmt): @date($fmt);\r
if (!defined('ADODB_TEST_DATES')) {\r
if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range\r
$_day_power = 86400;\r
\r
$arr = _adodb_getdate($d,true,$is_gmt);\r
- if (function_exists('adodb_daylight_sv')) adodb_daylight_sv($arr, $is_gmt);\r
+ if (!isset($daylight)) $daylight = function_exists('adodb_daylight_sv');\r
+ if ($daylight) adodb_daylight_sv($arr, $is_gmt);\r
\r
$year = $arr['year'];\r
$month = $arr['mon'];\r
Returns a timestamp given a GMT/UTC time. \r
Note that $is_dst is not implemented and is ignored.\r
*/\r
-function adodb_gmmktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false)\r
+function adodb_gmmktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false)\r
{\r
return adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst,true);\r
}\r
\r
Not a very fast algorithm - O(n) operation. Could be optimized to O(1).\r
*/\r
-function adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false,$is_gmt=false) \r
+function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false,$is_gmt=false) \r
{\r
if (!defined('ADODB_TEST_DATES')) {\r
// for windows, we don't check 1970 because with timezone differences, \r
// 1 Jan 1970 could generate negative timestamp, which is illegal\r
- if (!defined('ADODB_NO_NEGATIVE_TS') || ($year >= 1971)) \r
- if (1901 < $year && $year < 2038)\r
+ if (1971 < $year && $year < 2038\r
+ || $mon === false\r
+ || !defined('ADODB_NO_NEGATIVE_TS') && (1901 < $year && $year < 2038)\r
+ )\r
return $is_gmt?\r
@gmmktime($hr,$min,$sec,$mon,$day,$year):\r
@mktime($hr,$min,$sec,$mon,$day,$year);\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
- \r
-Redistribution and use in source and binary forms, with or without modification,\r
-are permitted provided that the following conditions are met:\r
-\r
-Redistributions of source code must retain the above copyright notice, this list\r
- of conditions and the following disclaimer.\r
-Redistributions in binary form must reproduce the above copyright notice, this l\r
-ist of conditions and the following disclaimer in the documentation and/or other\r
- materials provided with the distribution.\r
-Neither the name of the ars Cognita, Inc., nor the names of its contributors may be used \r
-to endorse or promote products derived from this software without specific prior\r
-written permission.\r
-\r
-DISCLAIMER:\r
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WA\r
-RRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
- IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIREC\r
-T, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR P\r
-ROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWI\r
-SE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE P\r
-OSSIBILITY OF SUCH DAMAGE.\r
-\r
*******************************************************************************/\r
/**\r
* xmlschema is a class that allows the user to quickly and easily\r
*/\r
if( !defined( '_ADODB_LAYER' ) ) {\r
require( 'adodb.inc.php' );\r
+ require( 'adodb-datadict.inc.php' );\r
}\r
\r
/**\r
\r
switch( $this->currentElement ) {\r
case 'INDEX':\r
- xml_set_object( $parser, $this->addIndex( $attributes ) );\r
+ if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {\r
+ xml_set_object( $parser, $this->addIndex( $attributes ) );\r
+ }\r
+ break;\r
+ case 'DATA':\r
+ if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {\r
+ xml_set_object( $parser, $this->addData( $attributes ) );\r
+ }\r
break;\r
case 'DROP':\r
$this->drop();\r
\r
$this->addField( $fieldName, $fieldType, $fieldSize, $fieldOpts );\r
break;\r
- case 'KEY': \r
+ case 'KEY':\r
case 'NOTNULL':\r
case 'AUTOINCREMENT':\r
// Add a field option\r
\r
$this->addFieldOpt( $this->current_field, $this->currentElement, $attributes['VALUE'] );\r
break;\r
+ case 'DEFDATE':\r
+ case 'DEFTIMESTAMP':\r
+ // Add a field option to the table object\r
+ $this->addFieldOpt( $this->current_field, $this->currentElement );\r
+ break;\r
default:\r
// print_r( array( $tag, $attributes ) );\r
}\r
switch( $this->currentElement ) {\r
// Table constraint\r
case 'CONSTRAINT':\r
+ if( isset( $this->current_field ) ) {\r
+ $this->addFieldOpt( $this->current_field, $this->currentElement, $cdata );\r
+ } else {\r
+ $this->addTableOpt( $cdata );\r
+ }\r
+ break;\r
// Table option\r
case 'OPT':\r
$this->addTableOpt( $cdata );\r
xml_set_object( $parser, $this->parent );\r
$this->destroy();\r
break;\r
+ case 'FIELD':\r
+ unset($this->current_field);\r
+ break;\r
+\r
}\r
}\r
\r
return $this->indexes[$name];\r
}\r
\r
+ /**\r
+ * Adds data to a table object\r
+ *\r
+ * @param array $attributes Data attributes\r
+ * @return object dbData object\r
+ */\r
+ function &addData( $attributes ) {\r
+ if( !isset( $this->data ) ) {\r
+ $this->data =& new dbData( $this, $attributes );\r
+ }\r
+ return $this->data;\r
+ }\r
+ \r
/**\r
* Adds a field to a table object\r
*\r
\r
// Set the field options\r
if( isset( $opts ) ) {\r
- $this->fields[$field_id]['OPTS'] = $opts;\r
+ $this->fields[$field_id]['OPTS'][] = $opts;\r
}\r
}\r
\r
if( is_array( $opt ) ) {\r
$key = key( $opt );\r
$value = $opt[key( $opt )];\r
- $fldarray[$field_id][$key] = $value;\r
+ @$fldarray[$field_id][$key] .= $value;\r
// Option doesn't have arguments\r
} else {\r
$fldarray[$field_id][$opt] = $opt;\r
$sql[] = $index->create( $xmls );\r
}\r
\r
+ if( isset( $this->data ) ) {\r
+ $sql[] = $this->data->create( $xmls );\r
+ }\r
+ \r
return $sql;\r
}\r
\r
}\r
}\r
\r
+/**\r
+* Creates a data object in ADOdb's datadict format\r
+*\r
+* This class stores information about table data.\r
+*\r
+* @package axmls\r
+* @access private\r
+*/\r
+class dbData extends dbObject {\r
+ \r
+ var $data = array();\r
+ \r
+ var $row;\r
+ \r
+ /**\r
+ * Initializes the new dbIndex object.\r
+ *\r
+ * @param object $parent Parent object\r
+ * @param array $attributes Attributes\r
+ *\r
+ * @internal\r
+ */\r
+ function dbData( &$parent, $attributes = NULL ) {\r
+ $this->parent =& $parent;\r
+ }\r
+ \r
+ /**\r
+ * XML Callback to process start elements\r
+ *\r
+ * Processes XML opening tags. \r
+ * Elements currently processed are: DROP, CLUSTERED, BITMAP, UNIQUE, FULLTEXT & HASH. \r
+ *\r
+ * @access private\r
+ */\r
+ function _tag_open( &$parser, $tag, $attributes ) {\r
+ $this->currentElement = strtoupper( $tag );\r
+ \r
+ switch( $this->currentElement ) {\r
+ case 'ROW':\r
+ $this->row = count( $this->data );\r
+ $this->data[$this->row] = array();\r
+ break;\r
+ case 'F':\r
+ $this->addField($attributes);\r
+ default:\r
+ // print_r( array( $tag, $attributes ) );\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * XML Callback to process CDATA elements\r
+ *\r
+ * Processes XML cdata.\r
+ *\r
+ * @access private\r
+ */\r
+ function _tag_cdata( &$parser, $cdata ) {\r
+ switch( $this->currentElement ) {\r
+ // Index field name\r
+ case 'F':\r
+ $this->addData( $cdata );\r
+ break;\r
+ default:\r
+ \r
+ }\r
+ }\r
+ \r
+ /**\r
+ * XML Callback to process end elements\r
+ *\r
+ * @access private\r
+ */\r
+ function _tag_close( &$parser, $tag ) {\r
+ $this->currentElement = '';\r
+ \r
+ switch( strtoupper( $tag ) ) {\r
+ case 'DATA':\r
+ xml_set_object( $parser, $this->parent );\r
+ break;\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * Adds a field to the index\r
+ *\r
+ * @param string $name Field name\r
+ * @return string Field list\r
+ */\r
+ function addField( $attributes ) {\r
+ if( isset( $attributes['NAME'] ) ) {\r
+ $name = $attributes['NAME'];\r
+ } else {\r
+ $name = count($this->data[$this->row]);\r
+ }\r
+ \r
+ // Set the field index so we know where we are\r
+ $this->current_field = $this->FieldID( $name );\r
+ }\r
+ \r
+ /**\r
+ * Adds options to the index\r
+ *\r
+ * @param string $opt Comma-separated list of index options.\r
+ * @return string Option list\r
+ */\r
+ function addData( $cdata ) {\r
+ if( !isset( $this->data[$this->row] ) ) {\r
+ $this->data[$this->row] = array();\r
+ }\r
+ \r
+ if( !isset( $this->data[$this->row][$this->current_field] ) ) {\r
+ $this->data[$this->row][$this->current_field] = '';\r
+ }\r
+ \r
+ $this->data[$this->row][$this->current_field] .= $cdata;\r
+ }\r
+ \r
+ /**\r
+ * Generates the SQL that will create the index in the database\r
+ *\r
+ * @param object $xmls adoSchema object\r
+ * @return array Array containing index creation SQL\r
+ */\r
+ function create( &$xmls ) {\r
+ $table = $xmls->dict->TableName($this->parent->name);\r
+ $table_field_count = count($this->parent->fields);\r
+ $sql = array();\r
+ \r
+ // eliminate any columns that aren't in the table\r
+ foreach( $this->data as $row ) {\r
+ $table_fields = $this->parent->fields;\r
+ $fields = array();\r
+ \r
+ foreach( $row as $field_id => $field_data ) {\r
+ if( !array_key_exists( $field_id, $table_fields ) ) {\r
+ if( is_numeric( $field_id ) ) {\r
+ $field_id = reset( array_keys( $table_fields ) );\r
+ } else {\r
+ continue;\r
+ }\r
+ }\r
+ \r
+ $name = $table_fields[$field_id]['NAME'];\r
+ \r
+ switch( $table_fields[$field_id]['TYPE'] ) {\r
+ case 'C':\r
+ case 'C2':\r
+ case 'X':\r
+ case 'X2':\r
+ $fields[$name] = $xmls->db->qstr( $field_data );\r
+ break;\r
+ case 'I':\r
+ case 'I1':\r
+ case 'I2':\r
+ case 'I4':\r
+ case 'I8':\r
+ $fields[$name] = intval($field_data);\r
+ break;\r
+ default:\r
+ $fields[$name] = $field_data;\r
+ }\r
+ \r
+ unset($table_fields[$field_id]);\r
+ }\r
+ \r
+ // check that at least 1 column is specified\r
+ if( empty( $fields ) ) {\r
+ continue;\r
+ }\r
+ \r
+ // check that no required columns are missing\r
+ if( count( $fields ) < $table_field_count ) {\r
+ foreach( $table_fields as $field ) {\r
+ if( ( in_array( 'NOTNULL', $field['OPTS'] ) || in_array( 'KEY', $field['OPTS'] ) ) && !in_array( 'AUTOINCREMENT', $field['OPTS'] ) ) {\r
+ continue(2);\r
+ }\r
+ }\r
+ }\r
+ \r
+ $sql[] = 'INSERT INTO '. $table .' ('. implode( ',', array_keys( $fields ) ) .') VALUES ('. implode( ',', $fields ) .')';\r
+ }\r
+ \r
+ return $sql;\r
+ }\r
+}\r
+\r
/**\r
* Creates the SQL to execute a list of provided SQL queries\r
*\r
case 'NONE':\r
$this->prefixMethod = 'NONE';\r
break;\r
- default:\r
- $this->prefixMethod = 'AUTO';\r
}\r
}\r
\r
* @return string SQL query string.\r
*/\r
function buildQuery( $sql = NULL ) {\r
- if( !isset( $this->query ) ) {\r
- return FALSE;\r
- }\r
- \r
- if( empty( $sql ) ) {\r
+ if( !isset( $this->query ) OR empty( $sql ) ) {\r
return FALSE;\r
}\r
\r
- if( !empty( $this->query ) ) {\r
- $this->query .= ' ';\r
- }\r
- \r
- $this->query .= trim( $sql );\r
+ $this->query .= $sql;\r
\r
return $this->query;\r
}\r
return FALSE;\r
}\r
\r
- $this->queries[] = $this->query;\r
- $return = $this->query;\r
+ $this->queries[] = $return = trim($this->query);\r
\r
unset( $this->query );\r
\r
\r
// Process object prefix.\r
// Evaluate SQL statements to prepend prefix to objects\r
- $query = $this->prefixQuery( '/^\s*((?is)INSERT\s+(INTO\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query );\r
- $query = $this->prefixQuery( '/^\s*((?is)UPDATE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query );\r
- $query = $this->prefixQuery( '/^\s*((?is)DELETE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query );\r
+ $query = $this->prefixQuery( '/^\s*((?is)INSERT\s+(INTO\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );\r
+ $query = $this->prefixQuery( '/^\s*((?is)UPDATE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );\r
+ $query = $this->prefixQuery( '/^\s*((?is)DELETE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );\r
\r
// SELECT statements aren't working yet\r
#$data = preg_replace( '/(?ias)(^\s*SELECT\s+.*\s+FROM)\s+(\W\s*,?\s*)+((?i)\s+WHERE.*$)/', "\1 $prefix\2 \3", $data );\r
$this->mgq = get_magic_quotes_runtime();\r
set_magic_quotes_runtime(0);\r
\r
- $this->debug = $this->db->debug;\r
$this->db =& $db;\r
+ $this->debug = $this->db->debug;\r
$this->dict = NewDataDictionary( $this->db );\r
$this->sqlArray = array();\r
$this->schemaVersion = XMLS_SCHEMA_VERSION;\r
* @see ParseSchemaString()\r
*\r
* @param string $file Name of XML schema file.\r
+ * @param bool $returnSchema Return schema rather than parsing.\r
* @return array Array of SQL queries, ready to execute\r
*/\r
- function ParseSchema( $filename ) {\r
- return $this->ParseSchemaString( $this->ConvertSchemaFile ( $filename ) );\r
+ function ParseSchema( $filename, $returnSchema = FALSE ) {\r
+ return $this->ParseSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );\r
}\r
\r
/**\r
* and generate the SQL necessary to create the database described by the schema.\r
*\r
* @param string $file Name of XML schema file.\r
+ * @param bool $returnSchema Return schema rather than parsing.\r
* @return array Array of SQL queries, ready to execute.\r
*\r
* @deprecated Replaced by adoSchema::ParseSchema() and adoSchema::ParseSchemaString()\r
* @see ParseSchema(), ParseSchemaString()\r
*/\r
- function ParseSchemaFile( $filename ) {\r
+ function ParseSchemaFile( $filename, $returnSchema = FALSE ) {\r
// Open the file\r
if( !($fp = fopen( $filename, 'r' )) ) {\r
// die( 'Unable to open file' );\r
return FALSE;\r
}\r
\r
+ if ( $returnSchema )\r
+ {\r
+ return $xmlstring;\r
+ }\r
+ \r
+ $this->success = 2;\r
+ \r
$xmlParser = $this->create_parser();\r
\r
// Process the file\r
* @see ParseSchema()\r
*\r
* @param string $xmlstring XML schema string.\r
+ * @param bool $returnSchema Return schema rather than parsing.\r
* @return array Array of SQL queries, ready to execute.\r
*/\r
- function ParseSchemaString( $xmlstring ) {\r
+ function ParseSchemaString( $xmlstring, $returnSchema = FALSE ) {\r
if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {\r
return FALSE;\r
}\r
return FALSE;\r
}\r
\r
- $xmlParser = $this->create_parser();\r
+ if ( $returnSchema )\r
+ {\r
+ return $xmlstring;\r
+ }\r
\r
$this->success = 2;\r
\r
+ $xmlParser = $this->create_parser();\r
+ \r
if( !xml_parse( $xmlParser, $xmlstring, TRUE ) ) {\r
die( sprintf(\r
"XML error: %s at line %d",\r
}\r
\r
xml_parser_free( $xmlParser );\r
+ \r
return $this->sqlArray;\r
}\r
\r
+ /**\r
+ * Loads an XML schema from a file and converts it to uninstallation SQL.\r
+ *\r
+ * Call this method to load the specified schema (see the DTD for the proper format) from\r
+ * the filesystem and generate the SQL necessary to remove the database described.\r
+ * @see RemoveSchemaString()\r
+ *\r
+ * @param string $file Name of XML schema file.\r
+ * @param bool $returnSchema Return schema rather than parsing.\r
+ * @return array Array of SQL queries, ready to execute\r
+ */\r
+ function RemoveSchema( $filename, $returnSchema = FALSE ) {\r
+ return $this->RemoveSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );\r
+ }\r
+ \r
+ /**\r
+ * Converts an XML schema string to uninstallation SQL.\r
+ *\r
+ * Call this method to parse a string containing an XML schema (see the DTD for the proper format)\r
+ * and generate the SQL necessary to uninstall the database described by the schema. \r
+ * @see RemoveSchema()\r
+ *\r
+ * @param string $schema XML schema string.\r
+ * @param bool $returnSchema Return schema rather than parsing.\r
+ * @return array Array of SQL queries, ready to execute.\r
+ */\r
+ function RemoveSchemaString( $schema, $returnSchema = FALSE ) {\r
+ \r
+ // grab current version\r
+ if( !( $version = $this->SchemaStringVersion( $schema ) ) ) {\r
+ return FALSE;\r
+ }\r
+ \r
+ return $this->ParseSchemaString( $this->TransformSchema( $schema, 'remove-' . $version), $returnSchema );\r
+ }\r
+ \r
/**\r
* Applies the current XML schema to the database (post execution).\r
*\r
if( $version == $newVersion ) {\r
$result = $schema;\r
} else {\r
- // Fail if XSLT extension is not available\r
- if( ! function_exists( 'xslt_create' ) ) {\r
- return FALSE;\r
- }\r
- \r
- $xsl_file = dirname( __FILE__ ) . '/xsl/convert-' . $version . '-' . $newVersion . '.xsl';\r
- \r
- // look for xsl\r
- if( !is_readable( $xsl_file ) ) {\r
- return FALSE;\r
- }\r
- \r
- $arguments = array (\r
- '/_xml' => $schema,\r
- '/_xsl' => file_get_contents ($xsl_file)\r
- );\r
- \r
- // create an XSLT processor\r
- $xh = xslt_create ();\r
- \r
- // set error handler\r
- xslt_set_error_handler ($xh, array (&$this, 'xslt_error_handler'));\r
- \r
- // process the schema\r
- $result = xslt_process ($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments); \r
- \r
- xslt_free ($xh);\r
+ $result = $this->TransformSchema( $schema, 'convert-' . $version . '-' . $newVersion);\r
}\r
\r
- if( is_string ($newFile) AND ( $fp = fopen( $newFile, 'w' ) ) ) {\r
- fwrite ($fp, $result);\r
- fclose ($fp);\r
+ if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) {\r
+ fwrite( $fp, $result );\r
+ fclose( $fp );\r
}\r
\r
return $result;\r
$result = substr( $result, 3 );\r
}\r
} else {\r
- // Fail if XSLT extension is not available\r
- if( ! function_exists( 'xslt_create' ) ) {\r
- return FALSE;\r
- }\r
- \r
- $xsl_file = dirname( __FILE__ ) . '/xsl/convert-' . $version . '-' . $newVersion . '.xsl';\r
- \r
- // look for xsl\r
- if( !is_readable( $xsl_file ) ) {\r
- return FALSE;\r
- }\r
- \r
- $arguments = array (\r
- '/_xml' => file_get_contents ($filename),\r
- '/_xsl' => file_get_contents ($xsl_file)\r
- );\r
- \r
- // create an XSLT processor\r
- $xh = xslt_create ();\r
- \r
- // set error handler\r
- xslt_set_error_handler ($xh, array (&$this, 'xslt_error_handler'));\r
- \r
- // process the schema\r
- $result = xslt_process ($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments); \r
- \r
- xslt_free ($xh);\r
+ $result = $this->TransformSchema( $filename, 'convert-' . $version . '-' . $newVersion, 'file' );\r
}\r
\r
- if( is_string ($newFile) AND ( $fp = fopen( $newFile, 'w' ) ) ) {\r
- fwrite ($fp, $result);\r
- fclose ($fp);\r
+ if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) {\r
+ fwrite( $fp, $result );\r
+ fclose( $fp );\r
}\r
\r
return $result;\r
}\r
\r
+ function TransformSchema( $schema, $xsl, $schematype='string' )\r
+ {\r
+ // Fail if XSLT extension is not available\r
+ if( ! function_exists( 'xslt_create' ) ) {\r
+ return FALSE;\r
+ }\r
+ \r
+ $xsl_file = dirname( __FILE__ ) . '/xsl/' . $xsl . '.xsl';\r
+ \r
+ // look for xsl\r
+ if( !is_readable( $xsl_file ) ) {\r
+ return FALSE;\r
+ }\r
+ \r
+ switch( $schematype )\r
+ {\r
+ case 'file':\r
+ if( !is_readable( $schema ) ) {\r
+ return FALSE;\r
+ }\r
+ \r
+ $schema = file_get_contents( $schema );\r
+ break;\r
+ case 'string':\r
+ default:\r
+ if( !is_string( $schema ) ) {\r
+ return FALSE;\r
+ }\r
+ }\r
+ \r
+ $arguments = array (\r
+ '/_xml' => $schema,\r
+ '/_xsl' => file_get_contents( $xsl_file )\r
+ );\r
+ \r
+ // create an XSLT processor\r
+ $xh = xslt_create ();\r
+ \r
+ // set error handler\r
+ xslt_set_error_handler ($xh, array (&$this, 'xslt_error_handler'));\r
+ \r
+ // process the schema\r
+ $result = xslt_process ($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments); \r
+ \r
+ xslt_free ($xh);\r
+ \r
+ return $result;\r
+ }\r
+ \r
/**\r
* Processes XSLT transformation errors\r
*\r
}\r
\r
if( $details->primary_key ) {\r
- $content[] = '<PRIMARY/>';\r
+ $content[] = '<KEY/>';\r
} elseif( $details->not_null ) {\r
$content[] = '<NOTNULL/>';\r
}\r
$schema .= ' <data>' . "\n";\r
\r
while( $row = $rs->FetchRow() ) {\r
+ foreach( $row as $key => $val ) {\r
+ $row[$key] = htmlentities($row);\r
+ }\r
+ \r
$schema .= ' <row><f>' . implode( '</f><f>', $row ) . '</f></row>' . "\n";\r
}\r
\r
// prefix too long\r
case strlen( $prefix ) > XMLS_PREFIX_MAXLEN:\r
// prefix contains invalid characters\r
- case !preg_match( '/^[a-z][a-z0-9]+$/i', $prefix ):\r
+ case !preg_match( '/^[a-z][a-z0-9_]+$/i', $prefix ):\r
logMsg( 'Invalid prefix: ' . $prefix );\r
return FALSE;\r
}\r
*\r
* @access private\r
*/\r
-function logMsg( $msg, $title = NULL ) {\r
- if( XMLS_DEBUG ) {\r
+function logMsg( $msg, $title = NULL, $force = FALSE ) {\r
+ if( XMLS_DEBUG or $force ) {\r
echo '<pre>';\r
\r
if( isset( $title ) ) {\r
var $substr = 'substr'; /// substring operator\r
var $length = 'length'; /// string length operator\r
var $random = 'rand()'; /// random function\r
- var $upperCase = false; /// uppercase function\r
+ var $upperCase = 'upper'; /// uppercase function\r
var $fmtDate = "'Y-m-d'"; /// used by DBDate() as the default date format used by the database\r
var $fmtTimeStamp = "'Y-m-d, h:i:s A'"; /// used by DBTimeStamp as the default timestamp fmt.\r
var $true = '1'; /// string that represents TRUE for a database\r
\r
if ($newline) $msg .= "<br>\n";\r
\r
- if (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) echo $msg;\r
+ if (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) || !$newline) echo $msg;\r
else echo strip_tags($msg);\r
+ \r
+ \r
if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // do not flush if output buffering enabled - useless - thx to Jesse Mullan \r
\r
}\r
\r
function Time()\r
{\r
- $rs =& $this->Execute("select $this->sysTimeStamp");\r
+ $rs =& $this->_Execute("select $this->sysTimeStamp");\r
if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields));\r
\r
return false;\r
For databases that require positioned params, eg $1, $2, $3 for postgresql,\r
pass in Param(false) before setting the first parameter.\r
*/\r
- function Param($name)\r
+ function Param($name,$type='C')\r
{\r
return '?';\r
}\r
$ret =& $fn($this,$sql,$inputarr);\r
if (isset($ret)) return $ret;\r
}\r
- if ($inputarr && is_array($inputarr)) {\r
+ if ($inputarr) {\r
+ if (!is_array($inputarr)) $inputarr = array($inputarr);\r
+ \r
$element0 = reset($inputarr);\r
# is_object check because oci8 descriptors can be passed in\r
$array_2d = is_array($element0) && !is_object(reset($element0));\r
if ($i+1 != sizeof($sqlarr)) \r
ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql));\r
\r
- $ret =& $this->_Execute($sql,false);\r
+ $ret =& $this->_Execute($sql);\r
if (!$ret) return $ret;\r
} \r
} else {\r
return $ret;\r
}\r
\r
+ \r
function& _Execute($sql,$inputarr=false)\r
{\r
\r
if ($this->debug) {\r
- global $HTTP_SERVER_VARS;\r
- \r
- $ss = '';\r
- if ($inputarr) {\r
- foreach($inputarr as $kk=>$vv) {\r
- if (is_string($vv) && strlen($vv)>64) $vv = substr($vv,0,64).'...';\r
- $ss .= "($kk=>'$vv') ";\r
- }\r
- $ss = "[ $ss ]";\r
- }\r
- $sqlTxt = str_replace(',',', ',is_array($sql) ?$sql[0] : $sql);\r
- \r
- // check if running from browser or command-line\r
- $inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']);\r
- \r
- if ($inBrowser) {\r
- if ($this->debug === -1)\r
- ADOConnection::outp( "<br>\n($this->databaseType): ".htmlspecialchars($sqlTxt)." <code>$ss</code>\n<br>\n",false);\r
- else \r
- ADOConnection::outp( "<hr>\n($this->databaseType): ".htmlspecialchars($sqlTxt)." <code>$ss</code>\n<hr>\n",false);\r
- } else {\r
- ADOConnection::outp("-----\n($this->databaseType): ".($sqlTxt)." \n-----\n",false);\r
- }\r
- $this->_queryID = $this->_query($sql,$inputarr);\r
- /* \r
- Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql\r
- because ErrorNo() calls Execute('SELECT @ERROR'), causing recursion\r
- */\r
- if ($this->databaseType == 'mssql') { \r
- // ErrorNo is a slow function call in mssql, and not reliable in PHP 4.0.6\r
- if($emsg = $this->ErrorMsg()) {\r
- if ($err = $this->ErrorNo()) ADOConnection::outp($err.': '.$emsg);\r
- }\r
- } else if (!$this->_queryID) {\r
- ADOConnection::outp($this->ErrorNo() .': '. $this->ErrorMsg());\r
- } \r
+ global $ADODB_INCLUDED_LIB;\r
+ if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');\r
+ $this->_queryID = _adodb_debug_execute($this, $sql,$inputarr);\r
} else {\r
- //****************************\r
- // non-debug version of query\r
- //****************************\r
- \r
- $this->_queryID =@$this->_query($sql,$inputarr);\r
+ $this->_queryID = @$this->_query($sql,$inputarr);\r
}\r
\r
/************************\r
// OK, query executed\r
*************************/\r
\r
- if ($this->_queryID === false) {\r
- // error handling if query fails\r
+ if ($this->_queryID === false) { // error handling if query fails\r
if ($this->debug == 99) adodb_backtrace(true,5); \r
$fn = $this->raiseErrorFn;\r
if ($fn) {\r
return false;\r
} \r
\r
- \r
- if ($this->_queryID === true) {\r
- // return simplified empty recordset for inserts/updates/deletes with lower overhead\r
+ if ($this->_queryID === true) { // return simplified recordset for inserts/updates/deletes with lower overhead\r
$rs =& new ADORecordSet_empty();\r
- #if (is_array($sql)) $rs->sql = $sql[0];\r
- #else $rs->sql = $sql;\r
return $rs;\r
}\r
\r
if ($rs->_numOfRows <= 0) {\r
global $ADODB_COUNTRECS;\r
if ($ADODB_COUNTRECS) {\r
- if (!$rs->EOF){ \r
+ if (!$rs->EOF) { \r
$rs = &$this->_rs2rs($rs,-1,-1,!is_array($sql));\r
$rs->_queryID = $this->_queryID;\r
} else\r
if ($rs) { \r
if (!$rs->EOF) $ret = reset($rs->fields);\r
$rs->Close();\r
- } \r
+ }\r
$ADODB_COUNTRECS = $crecs;\r
return $ret;\r
}\r
}\r
return;\r
} \r
+ \r
+ global $ADODB_INCLUDED_CSV;\r
+ if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php');\r
+ \r
$f = $this->_gencachename($sql.serialize($inputarr),false);\r
adodb_write_file($f,''); // is adodb_write_file needed?\r
if (!@unlink($f)) {\r
$forcenulls = defined('ADODB_FORCE_NULLS') ? true : false;\r
}\r
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');\r
- return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq);\r
+ return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq,$forcenulls);\r
}\r
\r
\r
$forcenulls = defined('ADODB_FORCE_NULLS') ? true : false;\r
}\r
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');\r
- return _adodb_getinsertsql($this,$rs,$arrFields,$magicq);\r
+ return _adodb_getinsertsql($this,$rs,$arrFields,$magicq,$forcenulls);\r
}\r
\r
\r
* @return an associative array indexed by the first column of the array, \r
* or false if the data has less than 2 cols.\r
*/\r
- function &GetAssoc($force_array = false, $first2cols = false) {\r
+ function &GetAssoc($force_array = false, $first2cols = false) \r
+ {\r
+ global $ADODB_EXTENSION;\r
+ \r
$cols = $this->_numOfFields;\r
if ($cols < 2) {\r
return false;\r
$results = array();\r
\r
if (!$first2cols && ($cols > 2 || $force_array)) {\r
- if ($numIndex) {\r
- while (!$this->EOF) {\r
- $results[trim($this->fields[0])] = array_slice($this->fields, 1);\r
- $this->MoveNext();\r
+ if ($ADODB_EXTENSION) {\r
+ if ($numIndex) {\r
+ while (!$this->EOF) {\r
+ $results[trim($this->fields[0])] = array_slice($this->fields, 1);\r
+ adodb_movenext($this);\r
+ }\r
+ } else {\r
+ while (!$this->EOF) {\r
+ $results[trim(reset($this->fields))] = array_slice($this->fields, 1);\r
+ adodb_movenext($this);\r
+ }\r
}\r
} else {\r
- while (!$this->EOF) {\r
- $results[trim(reset($this->fields))] = array_slice($this->fields, 1);\r
- $this->MoveNext();\r
+ if ($numIndex) {\r
+ while (!$this->EOF) {\r
+ $results[trim($this->fields[0])] = array_slice($this->fields, 1);\r
+ $this->MoveNext();\r
+ }\r
+ } else {\r
+ while (!$this->EOF) {\r
+ $results[trim(reset($this->fields))] = array_slice($this->fields, 1);\r
+ $this->MoveNext();\r
+ }\r
}\r
}\r
} else {\r
- // return scalar values\r
- if ($numIndex) {\r
- while (!$this->EOF) {\r
- // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string\r
- $results[trim(($this->fields[0]))] = $this->fields[1];\r
- $this->MoveNext();\r
+ if ($ADODB_EXTENSION) {\r
+ // return scalar values\r
+ if ($numIndex) {\r
+ while (!$this->EOF) {\r
+ // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string\r
+ $results[trim(($this->fields[0]))] = $this->fields[1];\r
+ adodb_movenext($this);\r
+ }\r
+ } else {\r
+ while (!$this->EOF) {\r
+ // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string\r
+ $v1 = trim(reset($this->fields));\r
+ $v2 = ''.next($this->fields); \r
+ $results[$v1] = $v2;\r
+ adodb_movenext($this);\r
+ }\r
}\r
} else {\r
- while (!$this->EOF) {\r
- // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string\r
- $v1 = trim(reset($this->fields));\r
- $v2 = ''.next($this->fields); \r
- $results[$v1] = $v2;\r
- $this->MoveNext();\r
+ if ($numIndex) {\r
+ while (!$this->EOF) {\r
+ // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string\r
+ $results[trim(($this->fields[0]))] = $this->fields[1];\r
+ $this->MoveNext();\r
+ }\r
+ } else {\r
+ while (!$this->EOF) {\r
+ // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string\r
+ $v1 = trim(reset($this->fields));\r
+ $v2 = ''.next($this->fields); \r
+ $results[$v1] = $v2;\r
+ $this->MoveNext();\r
+ }\r
}\r
}\r
}\r
}\r
*/\r
return false;\r
- } \r
+ }\r
+ \r
\r
/**\r
* Random access to a specific row in the recordset. Some databases do not support\r
*/\r
function &FetchNextObj()\r
{\r
- return $this->FetchNextObject(false);\r
+ $o = $this->FetchNextObject(false);\r
+ return $o;\r
}\r
\r
\r
if (!$dbType) return false;\r
$db = strtolower($dbType);\r
switch ($db) {\r
+ case 'ifx':\r
case 'maxsql': $db = 'mysqlt'; break;\r
case 'postgres':\r
case 'pgsql': $db = 'postgres7'; break;\r
if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2);\r
$errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false;\r
\r
- if (!empty($ADODB_NEWCONNECTION)) {\r
- $obj = $ADODB_NEWCONNECTION($db);\r
- if ($obj) {\r
- if ($errorfn) $obj->raiseErrorFn = $errorfn;\r
- return $obj;\r
+ if (strpos($db,'://')) {\r
+ $origdsn = $db;\r
+ $dsna = @parse_url($db);\r
+ if (!$dsna) {\r
+ // special handling of oracle, which might not have host\r
+ $db = str_replace('@/','@adodb-fakehost/',$db);\r
+ $dsna = parse_url($db);\r
+ if (!$dsna) return false;\r
+ $dsna['host'] = '';\r
}\r
+ $db = @$dsna['scheme'];\r
+ if (!$db) return false;\r
+ $dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : '';\r
+ $dsna['user'] = isset($dsna['user']) ? rawurldecode($dsna['user']) : '';\r
+ $dsna['pass'] = isset($dsna['pass']) ? rawurldecode($dsna['pass']) : '';\r
+ $dsna['path'] = isset($dsna['path']) ? rawurldecode(substr($dsna['path'],1)) : '';\r
+ \r
+ if (isset($dsna['query'])) {\r
+ $opt1 = explode('&',$dsna['query']);\r
+ foreach($opt1 as $k => $v) {\r
+ $arr = explode('=',$v);\r
+ $opt[$arr[0]] = isset($arr[1]) ? rawurldecode($arr[1]) : 1;\r
+ }\r
+ } else $opt = array();\r
}\r
\r
- if (!isset($ADODB_LASTDB)) $ADODB_LASTDB = '';\r
- if (empty($db)) $db = $ADODB_LASTDB;\r
- \r
- if ($db != $ADODB_LASTDB) $db = ADOLoadCode($db);\r
+ /*\r
+ * phptype: Database backend used in PHP (mysql, odbc etc.)\r
+ * dbsyntax: Database used with regards to SQL syntax etc.\r
+ * protocol: Communication protocol to use (tcp, unix etc.)\r
+ * hostspec: Host specification (hostname[:port])\r
+ * database: Database to use on the DBMS server\r
+ * username: User name for login\r
+ * password: Password for login\r
+ */\r
+ if (!empty($ADODB_NEWCONNECTION)) {\r
+ $obj = $ADODB_NEWCONNECTION($db);\r
+\r
+ } else {\r
\r
- if (!$db) {\r
- if ($errorfn) {\r
- // raise an error\r
- $ignore = false;\r
- $errorfn('ADONewConnection', 'ADONewConnection', -998,\r
- "could not load the database driver for '$db",\r
- $db,false,$ignore);\r
- } else\r
- ADOConnection::outp( "<p>ADONewConnection: Unable to load database driver '$db'</p>",false);\r
- \r
- return false;\r
+ if (!isset($ADODB_LASTDB)) $ADODB_LASTDB = '';\r
+ if (empty($db)) $db = $ADODB_LASTDB;\r
+ \r
+ if ($db != $ADODB_LASTDB) $db = ADOLoadCode($db);\r
+ \r
+ if (!$db) {\r
+ if (isset($origdsn)) $db = $origdsn;\r
+ if ($errorfn) {\r
+ // raise an error\r
+ $ignore = false;\r
+ $errorfn('ADONewConnection', 'ADONewConnection', -998,\r
+ "could not load the database driver for '$db'",\r
+ $db,false,$ignore);\r
+ } else\r
+ ADOConnection::outp( "<p>ADONewConnection: Unable to load database driver '$db'</p>",false);\r
+ \r
+ return false;\r
+ }\r
+ \r
+ $cls = 'ADODB_'.$db;\r
+ if (!class_exists($cls)) {\r
+ adodb_backtrace();\r
+ return false;\r
+ }\r
+ \r
+ $obj =& new $cls();\r
}\r
\r
- $cls = 'ADODB_'.$db;\r
- if (!class_exists($cls)) {\r
- adodb_backtrace();\r
- return false;\r
+ # constructor should not fail\r
+ if ($obj) {\r
+ if ($errorfn) $obj->raiseErrorFn = $errorfn;\r
+ if (isset($dsna)) {\r
+ \r
+ foreach($opt as $k => $v) {\r
+ switch(strtolower($k)) {\r
+ case 'persist':\r
+ case 'persistent': $persist = $v; break;\r
+ case 'debug': $obj->debug = (integer) $v; break;\r
+ #ibase\r
+ case 'dialect': $obj->dialect = (integer) $v; break;\r
+ case 'charset': $obj->charset = $v; break;\r
+ case 'buffers': $obj->buffers = $v; break;\r
+ case 'fetchmode': $obj->SetFetchMode($v); break;\r
+ #ado\r
+ case 'charpage': $obj->charPage = $v; break;\r
+ #mysql, mysqli\r
+ case 'clientflags': $obj->clientFlags = $v; break;\r
+ #mysqli\r
+ case 'port': $obj->port = $v; break;\r
+ case 'socket': $obj->socket = $v; break;\r
+ }\r
+ }\r
+ if (empty($persist))\r
+ $ok = $obj->Connect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);\r
+ else\r
+ $ok = $obj->PConnect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);\r
+ \r
+ if (!$ok) return false;\r
+ }\r
}\r
- \r
- $obj =& new $cls();\r
- if ($errorfn) $obj->raiseErrorFn = $errorfn;\r
- \r
return $obj;\r
}\r
\r
+ \r
+ \r
// $perf == true means called by NewPerfMonitor()\r
function _adodb_getdriver($provider,$drivername,$perf=false)\r
{\r
}\r
\r
\r
- /**\r
- * Save a file $filename and its $contents (normally for caching) with file locking\r
- */\r
- function adodb_write_file($filename, $contents,$debug=false)\r
- { \r
- # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows\r
- # So to simulate locking, we assume that rename is an atomic operation.\r
- # First we delete $filename, then we create a $tempfile write to it and \r
- # rename to the desired $filename. If the rename works, then we successfully \r
- # modified the file exclusively.\r
- # What a stupid need - having to simulate locking.\r
- # Risks:\r
- # 1. $tempfile name is not unique -- very very low\r
- # 2. unlink($filename) fails -- ok, rename will fail\r
- # 3. adodb reads stale file because unlink fails -- ok, $rs timeout occurs\r
- # 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated\r
- if (strncmp(PHP_OS,'WIN',3) === 0) {\r
- // skip the decimal place\r
- $mtime = substr(str_replace(' ','_',microtime()),2); \r
- // getmypid() actually returns 0 on Win98 - never mind!\r
- $tmpname = $filename.uniqid($mtime).getmypid();\r
- if (!($fd = fopen($tmpname,'a'))) return false;\r
- $ok = ftruncate($fd,0); \r
- if (!fwrite($fd,$contents)) $ok = false;\r
- fclose($fd);\r
- chmod($tmpname,0644);\r
- // the tricky moment\r
- @unlink($filename);\r
- if (!@rename($tmpname,$filename)) {\r
- unlink($tmpname);\r
- $ok = false;\r
- }\r
- if (!$ok) {\r
- if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed'));\r
- }\r
- return $ok;\r
- }\r
- if (!($fd = fopen($filename, 'a'))) return false;\r
- if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) {\r
- $ok = fwrite( $fd, $contents );\r
- fclose($fd);\r
- chmod($filename,0644);\r
- }else {\r
- fclose($fd);\r
- if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename<br>\n");\r
- $ok = false;\r
- }\r
- \r
- return $ok;\r
- }\r
\r
/*\r
Perform a print_r, with pre tags for better formatting.\r
*/\r
function adodb_backtrace($printOrArr=true,$levels=9999)\r
{\r
- $s = '';\r
- if (PHPVERSION() < 4.3) return;\r
- \r
- $html = (isset($_SERVER['HTTP_USER_AGENT']));\r
- $fmt = ($html) ? "</font><font color=#808080 size=-1> %% line %4d, file: <a href=\"file:/%s\">%s</a></font>" : "%% line %4d, file: %s";\r
-\r
- $MAXSTRLEN = 64;\r
- \r
- $s = ($html) ? '<pre align=left>' : '';\r
- \r
- if (is_array($printOrArr)) $traceArr = $printOrArr;\r
- else $traceArr = debug_backtrace();\r
- array_shift($traceArr);\r
- $tabs = sizeof($traceArr)-1;\r
- \r
- foreach ($traceArr as $arr) {\r
- $levels -= 1;\r
- if ($levels < 0) break;\r
- \r
- $args = array();\r
- for ($i=0; $i < $tabs; $i++) $s .= ($html) ? ' ' : "\t";\r
- $tabs -= 1;\r
- if ($html) $s .= '<font face="Courier New,Courier">';\r
- if (isset($arr['class'])) $s .= $arr['class'].'.';\r
- if (isset($arr['args']))\r
- foreach($arr['args'] as $v) {\r
- if (is_null($v)) $args[] = 'null';\r
- else if (is_array($v)) $args[] = 'Array['.sizeof($v).']';\r
- else if (is_object($v)) $args[] = 'Object:'.get_class($v);\r
- else if (is_bool($v)) $args[] = $v ? 'true' : 'false';\r
- else {\r
- $v = (string) @$v;\r
- $str = htmlspecialchars(substr($v,0,$MAXSTRLEN));\r
- if (strlen($v) > $MAXSTRLEN) $str .= '...';\r
- $args[] = $str;\r
- }\r
- }\r
- $s .= $arr['function'].'('.implode(', ',$args).')';\r
- \r
- \r
- $s .= @sprintf($fmt, $arr['line'],$arr['file'],basename($arr['file']));\r
- \r
- $s .= "\n";\r
- } \r
- if ($html) $s .= '</pre>';\r
- if ($printOrArr) print $s;\r
- \r
- return $s;\r
+ global $ADODB_INCLUDED_LIB;\r
+ if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');\r
+ return _adodb_backtrace($printOrArr,$levels);\r
}\r
\r
} // defined\r
<?php\r
\r
/**\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
\r
/**\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
\r
/**\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
\r
/**\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
\r
/**\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
\r
/**\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
\r
/**\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
\r
/**\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
\r
/**\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
\r
/**\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
\r
/**\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. See License.txt. \r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
\r
if ($this->hideErrors) $olde = error_reporting(E_ERROR|E_CORE_ERROR);// sometimes $f->value be null\r
for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) {\r
-\r
+ //echo "<p>",$t,' ';var_dump($f->value); echo '</p>';\r
switch($t) {\r
case 135: // timestamp\r
if (!strlen((string)$f->value)) $this->fields[] = false;\r
- else $this->fields[] = adodb_date('Y-m-d H:i:s',(float)$f->value);\r
+ else {\r
+ if (!is_numeric($f->value)) $val = variant_date_to_timestamp($f->value);\r
+ else $val = $f->value;\r
+ $this->fields[] = adodb_date('Y-m-d H:i:s',$val);\r
+ }\r
break; \r
case 133:// A date value (yyyymmdd) \r
if ($val = $f->value) {\r
break;\r
case 7: // adDate\r
if (!strlen((string)$f->value)) $this->fields[] = false;\r
- else $this->fields[] = adodb_date('Y-m-d',(float)$f->value);\r
+ else {\r
+ if (!is_numeric($f->value)) $val = variant_date_to_timestamp($f->value);\r
+ else $val = $f->value;\r
+ \r
+ if (($val % 86400) == 0) $this->fields[] = adodb_date('Y-m-d',$val);\r
+ else $this->fields[] = adodb_date('Y-m-d H:i:s',$val);\r
+ }\r
break;\r
case 1: // null\r
$this->fields[] = false;\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. See License.txt. \r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
var $ansiOuter = true; // for mssql7 or later\r
var $substr = "substring";\r
var $length = 'len';\r
- var $upperCase = 'upper';\r
\r
//var $_inTransaction = 1; // always open recordsets, so no transaction problems.\r
\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
<?php\r
/*\r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
var $fmtTimeStamp = "'Y-m-d-H.i.s'";\r
var $ansiOuter = true;\r
var $identitySQL = 'values IDENTITY_VAL_LOCAL()';\r
- var $_bindInputArray = false;\r
- var $upperCase = 'upper';\r
- \r
+ var $_bindInputArray = true;\r
+ var $hasInsertID = true;\r
\r
function ADODB_DB2()\r
{\r
return $this->GetOne("select 1 as ignore from $tables where $where for update");\r
}\r
\r
- function &MetaTables($ttype=false,$showSchema=false)\r
+ function &MetaTables($ttype=false,$showSchema=false, $qtable="%", $qschema="%")\r
{\r
global $ADODB_FETCH_MODE;\r
\r
$savem = $ADODB_FETCH_MODE;\r
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;\r
- $qid = odbc_tables($this->_connectionID);\r
+ $qid = odbc_tables($this->_connectionID, "", $qschema, $qtable, "");\r
\r
$rs = new ADORecordSet_odbc($qid);\r
\r
return $arr2;\r
}\r
\r
+ \r
// Format date column in sql string given an input format that understands Y M D\r
function SQLDate($fmt, $col=false)\r
{ \r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
<?php\r
/*\r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved. \r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved. \r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
if (defined('IBASE_DEFAULT')) $this->ibasetrans = IBASE_DEFAULT;\r
}\r
\r
+ \r
+ // returns true or false\r
+ function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false)\r
+ { \r
+ if (!function_exists('ibase_pconnect')) return null;\r
+ if ($argDatabasename) $argHostname .= ':'.$argDatabasename;\r
+ $fn = ($persist) ? 'ibase_pconnect':'ibase_connect';\r
+ $this->_connectionID = $fn($argHostname,$argUsername,$argPassword,\r
+ $this->charSet,$this->buffers,$this->dialect);\r
+ \r
+ if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html\r
+ $this->replaceQuote = "''";\r
+ }\r
+ if ($this->_connectionID === false) {\r
+ $this->_handleerror();\r
+ return false;\r
+ }\r
+ \r
+ // PHP5 change.\r
+ if (function_exists('ibase_timefmt')) {\r
+ ibase_timefmt($this->ibase_datefmt,IBASE_DATE );\r
+ if ($this->dialect == 1) ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP );\r
+ else ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP );\r
+ ibase_timefmt($this->ibase_timefmt,IBASE_TIME );\r
+ \r
+ } else {\r
+ ini_set("ibase.timestampformat", $this->ibase_timestampfmt);\r
+ ini_set("ibase.dateformat", $this->ibase_datefmt);\r
+ ini_set("ibase.timeformat", $this->ibase_timefmt);\r
+ }\r
+ return true;\r
+ }\r
+ // returns true or false\r
+ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)\r
+ {\r
+ return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,true);\r
+ } \r
+ \r
+ \r
function MetaPrimaryKeys($table,$owner_notused=false,$internalKey=false)\r
{ \r
if ($internalKey) return array('RDB$DB_KEY');\r
return $this->_errorMsg;\r
}\r
\r
- // returns true or false\r
- function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false)\r
- { \r
- if (!function_exists('ibase_pconnect')) return null;\r
- if ($argDatabasename) $argHostname .= ':'.$argDatabasename;\r
- $fn = ($persist) ? 'ibase_pconnect':'ibase_connect';\r
- $this->_connectionID = $fn($argHostname,$argUsername,$argPassword,\r
- $this->charSet,$this->buffers,$this->dialect);\r
- \r
- if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html\r
- $this->replaceQuote = "''";\r
- }\r
- if ($this->_connectionID === false) {\r
- $this->_handleerror();\r
- return false;\r
- }\r
- \r
- // PHP5 change.\r
- if (function_exists('ibase_timefmt')) {\r
- ibase_timefmt($this->ibase_datefmt,IBASE_DATE );\r
- if ($this->dialect == 1) ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP );\r
- else ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP );\r
- ibase_timefmt($this->ibase_timefmt,IBASE_TIME );\r
- } else {\r
- ini_set("ibase.timestampformat", $this->base_timestampfmt);\r
- ini_set("ibase.dateformat", $this->ibase_datefmt);\r
- ini_set("ibase.timeformat", $this->ibase_timefmt);\r
- }\r
- //you can use\r
- /*\r
- ini_set("ibase.timestampformat", $this->ibase_timestampfmt);\r
- ini_set("ibase.dateformat", $this->ibase_datefmt);\r
- ini_set("ibase.timeformat", $this->ibase_timefmt);\r
- */\r
- return true;\r
- }\r
- // returns true or false\r
- function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)\r
- {\r
- return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,true);\r
- } \r
- \r
function Prepare($sql)\r
{\r
$stmt = ibase_prepare($this->_connectionID,$sql);\r
<?php\r
/*\r
-V4.50 6 July 2004 (c) 2000-2004 John Lim. All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim. All rights reserved.\r
Released under both BSD license and Lesser GPL library license.\r
Whenever there is any discrepancy between the two licenses,\r
the BSD license will take precedence.\r
var $fmtTimeStamp = "'Y-m-d H:i:s'";\r
var $hasInsertID = true;\r
var $hasAffectedRows = true;\r
- var $upperCase = 'upper';\r
var $substr = 'substr';\r
var $metaTablesSQL="select tabname from systables where tabtype!=' ' and owner!='informix'"; //Don't get informix tables and pseudo-tables\r
\r
<?php\r
/*\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
var $hasInsertID = true;\r
var $substr = "substring";\r
var $length = 'len';\r
- var $upperCase = 'upper';\r
var $hasAffectedRows = true;\r
var $metaDatabasesSQL = "select name from sysdatabases where name <> 'master'";\r
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'))";\r
\r
// "Stein-Aksel Basma" <basma@accelero.no>\r
// tested with MSSQL 2000\r
- function MetaPrimaryKeys($table)\r
+ function &MetaPrimaryKeys($table)\r
{\r
- $sql = "select k.column_name from information_schema.key_column_usage k,\r
+ global $ADODB_FETCH_MODE;\r
+ \r
+ $schema = '';\r
+ $this->_findschema($table,$schema);\r
+ if (!$schema) $schema = $this->database;\r
+ if ($schema) $schema = "and k.table_catalog like '$schema%'"; \r
+\r
+ $sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k,\r
information_schema.table_constraints tc \r
where tc.constraint_name = k.constraint_name and tc.constraint_type =\r
- 'PRIMARY KEY' and k.table_name = '$table'";\r
+ 'PRIMARY KEY' and k.table_name = '$table' $schema order by ordinal_position ";\r
\r
+ $savem = $ADODB_FETCH_MODE;\r
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;\r
$a = $this->GetCol($sql);\r
+ $ADODB_FETCH_MODE = $savem;\r
+ \r
if ($a && sizeof($a)>0) return $a;\r
return false; \r
}\r
*/\r
function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')\r
{\r
+ \r
+ if (strtoupper($blobtype) == 'CLOB') {\r
+ $sql = "UPDATE $table SET $column='" . $val . "' WHERE $where";\r
+ return $this->Execute($sql) != false;\r
+ }\r
$sql = "UPDATE $table SET $column=0x".bin2hex($val)." WHERE $where";\r
return $this->Execute($sql) != false;\r
}\r
} else if (is_integer($v)) {\r
$decl .= "@P$i INT";\r
$params .= "@P$i=".$v;\r
- } else {\r
+ } else if (is_float($v)) {\r
$decl .= "@P$i FLOAT";\r
$params .= "@P$i=".$v;\r
- }\r
+ } else if (is_bool($v)) {\r
+ $decl .= "@P$i INT"; # Used INT just in case BIT in not supported on the user's MSSQL version. It will cast appropriately.\r
+ $params .= "@P$i=".(($v)?'1':'0'); # True == 1 in MSSQL BIT fields and acceptable for storing logical true in an int field\r
+ } else {\r
+ $decl .= "@P$i CHAR"; # Used char because a type is required even when the value is to be NULL.\r
+ $params .= "@P$i=NULL";\r
+ }\r
$i += 1;\r
}\r
$decl = $this->qstr($decl);\r
<?php\r
/*\r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
var $hasLimit = true;\r
var $hasMoveFirst = true;\r
var $hasGenID = true;\r
- var $upperCase = 'upper';\r
var $isoDates = true; // accepts dates in ISO format\r
var $sysDate = 'CURDATE()';\r
var $sysTimeStamp = 'NOW()';\r
\r
function ADODB_mysql() \r
{ \r
+ if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_';\r
}\r
\r
function ServerInfo()\r
return false;\r
}\r
\r
+ function BeginTrans()\r
+ {\r
+ if ($this->debug) ADOConnection::outp("Transactions not supported in 'mysql' driver. Use 'mysqlt' or 'mysqli' driver");\r
+ }\r
+ \r
function _affectedrows()\r
{\r
return mysql_affected_rows($this->_connectionID);\r
for ($i=0; $i < $len; $i++) {\r
$ch = $fmt[$i];\r
switch($ch) {\r
+ \r
+ default:\r
+ if ($ch == '\\') {\r
+ $i++;\r
+ $ch = substr($fmt,$i,1);\r
+ }\r
+ /** FALL THROUGH */\r
+ case '-':\r
+ case '/':\r
+ $s .= $ch;\r
+ break;\r
+ \r
case 'Y':\r
case 'y':\r
$s .= '%Y';\r
break;\r
- case 'Q':\r
- case 'q':\r
- $s .= "'),Quarter($col)";\r
- \r
- if ($len > $i+1) $s .= ",DATE_FORMAT($col,'";\r
- else $s .= ",('";\r
- $concat = true;\r
- break;\r
case 'M':\r
$s .= '%b';\r
break;\r
$s .= '%d';\r
break;\r
\r
+ case 'Q':\r
+ case 'q':\r
+ $s .= "'),Quarter($col)";\r
+ \r
+ if ($len > $i+1) $s .= ",DATE_FORMAT($col,'";\r
+ else $s .= ",('";\r
+ $concat = true;\r
+ break;\r
+ \r
case 'H': \r
$s .= '%H';\r
break;\r
$s .= '%p';\r
break;\r
\r
- default:\r
- \r
- if ($ch == '\\') {\r
- $i++;\r
- $ch = substr($fmt,$i,1);\r
- }\r
- $s .= $ch;\r
- break;\r
+\r
}\r
}\r
$s.="')";\r
return $rs;\r
}\r
\r
- \r
// returns queryID or false\r
function _query($sql,$inputarr)\r
{\r
else return @mysql_errno($this->_connectionID);\r
}\r
\r
-\r
- \r
// returns true or false\r
function _close()\r
{\r
Class Name: Recordset\r
--------------------------------------------------------------------------------------*/\r
\r
+\r
class ADORecordSet_mysql extends ADORecordSet{ \r
\r
var $databaseType = "mysql";\r
return @mysql_data_seek($this->_queryID,$row);\r
}\r
\r
- \r
- // 10% speedup to move MoveNext to child class\r
- function MoveNext() \r
+ function MoveNext()\r
{\r
- //global $ADODB_EXTENSION;if ($ADODB_EXTENSION) return adodb_movenext($this);\r
- \r
- if ($this->EOF) return false;\r
- \r
- $this->_currentRow++;\r
- $this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode);\r
- if (is_array($this->fields)) return true;\r
- \r
- $this->EOF = true;\r
- \r
- /* -- tested raising an error -- appears pointless\r
- $conn = $this->connection;\r
- if ($conn && $conn->raiseErrorFn && ($errno = $conn->ErrorNo())) {\r
- $fn = $conn->raiseErrorFn;\r
- $fn($conn->databaseType,'MOVENEXT',$errno,$conn->ErrorMsg().' ('.$this->sql.')',$conn->host,$conn->database);\r
+ //return adodb_movenext($this);\r
+ //if (defined('ADODB_EXTENSION')) return adodb_movenext($this);\r
+ if (@$this->fields =& mysql_fetch_array($this->_queryID,$this->fetchMode)) {\r
+ $this->_currentRow += 1;\r
+ return true;\r
+ }\r
+ if (!$this->EOF) {\r
+ $this->_currentRow += 1;\r
+ $this->EOF = true;\r
}\r
- */\r
return false;\r
- } \r
+ }\r
\r
function _fetch()\r
{\r
}\r
\r
}\r
+\r
+class ADORecordSet_ext_mysql extends ADORecordSet_mysql { \r
+ function ADORecordSet_ext_mysql($queryID,$mode=false) \r
+ {\r
+ if ($mode === false) { \r
+ global $ADODB_FETCH_MODE;\r
+ $mode = $ADODB_FETCH_MODE;\r
+ }\r
+ switch ($mode)\r
+ {\r
+ case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;\r
+ case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;\r
+ default:\r
+ case ADODB_FETCH_DEFAULT:\r
+ case ADODB_FETCH_BOTH:$this->fetchMode = MYSQL_BOTH; break;\r
+ }\r
+ \r
+ $this->ADORecordSet($queryID); \r
+ }\r
+ \r
+ function MoveNext()\r
+ {\r
+ return adodb_movenext($this);\r
+ }\r
+}\r
+\r
+\r
}\r
?>
\ No newline at end of file
<?php\r
/*\r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
var $hasLimit = true;\r
var $hasMoveFirst = true;\r
var $hasGenID = true;\r
- var $upperCase = 'upper';\r
var $isoDates = true; // accepts dates in ISO format\r
var $sysDate = 'CURDATE()';\r
var $sysTimeStamp = 'NOW()';\r
var $poorAffectedRows = true;\r
var $clientFlags = 0;\r
var $substr = "substring";\r
- //var $poorAffectedRows = true;\r
+ var $port = false;\r
+ var $socket = false;\r
+ var $_bindInputArray = false;\r
var $nameQuote = '`'; /// string to use to quote identifiers and names\r
- //var $_bindInputArray = true;\r
\r
function ADODB_mysqli() \r
{ \r
if(!extension_loaded("mysqli"))\r
- {\r
trigger_error("You must have the MySQLi extension.", E_USER_ERROR);\r
+ \r
+ }\r
+ \r
+\r
+ // returns true or false\r
+ // To add: parameter int $port,\r
+ // parameter string $socket\r
+ function _connect($argHostname = NULL, \r
+ $argUsername = NULL, \r
+ $argPassword = NULL, \r
+ $argDatabasename = NULL, $persist=false)\r
+ {\r
+ $this->_connectionID = @mysqli_init();\r
+ \r
+ if (is_null($this->_connectionID)) {\r
+ // mysqli_init only fails if insufficient memory\r
+ if ($this->debug) \r
+ ADOConnection::outp("mysqli_init() failed : " . $this->ErrorMsg());\r
+ return false;\r
}\r
+ // Set connection options\r
+ // Not implemented now\r
+ // mysqli_options($this->_connection,,);\r
+ if (mysqli_real_connect($this->_connectionID,\r
+ $argHostname,\r
+ $argUsername,\r
+ $argPassword,\r
+ $argDatabasename,\r
+ $this->port,\r
+ $this->socket,\r
+ $this->clientFlags))\r
+ {\r
+ if ($argDatabasename) return $this->SelectDB($argDatabasename);\r
+ \r
+ \r
+ return true;\r
+ }\r
+ else {\r
+ if ($this->debug) \r
+ ADOConnection::outp("Could't connect : " . $this->ErrorMsg());\r
+ return false;\r
+ }\r
+ }\r
+ \r
+ // returns true or false\r
+ // How to force a persistent connection\r
+ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)\r
+ {\r
+ return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename, true);\r
+\r
}\r
\r
+ // When is this used? Close old connection first?\r
+ // In _connect(), check $this->forceNewConnect? \r
+ function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)\r
+ {\r
+ $this->forceNewConnect = true;\r
+ $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);\r
+ }\r
+ \r
function IfNull( $field, $ifNull ) \r
{\r
return " IFNULL($field, $ifNull) "; // if MySQL\r
return "from_unixtime(unix_timestamp($date)+($dayFraction)*24*3600)";\r
}\r
\r
- // returns true or false\r
- // To add: parameter int $port,\r
- // parameter string $socket\r
- function _connect($argHostname = NULL, \r
- $argUsername = NULL, \r
- $argPassword = NULL, \r
- $argDatabasename = NULL)\r
- {\r
- // @ means: error surpression on\r
- $this->_connectionID = @mysqli_init();\r
- \r
- if (is_null($this->_connectionID))\r
- {\r
- // mysqli_init only fails if insufficient memory\r
- if ($this->debug) \r
- ADOConnection::outp("mysqli_init() failed : " . $this->ErrorMsg());\r
- return false;\r
- }\r
- // Set connection options\r
- // Not implemented now\r
- // mysqli_options($this->_connection,,);\r
- if (mysqli_real_connect($this->_connectionID,\r
- $argHostname,\r
- $argUsername,\r
- $argPassword,\r
- $argDatabasename))\r
- {\r
- if ($argDatabasename) \r
- {\r
- return $this->SelectDB($argDatabasename);\r
- }\r
- \r
- return true;\r
- }\r
- else\r
- {\r
- if ($this->debug) \r
- ADOConnection::outp("Could't connect : " . $this->ErrorMsg());\r
- return false;\r
- }\r
- }\r
- \r
- // returns true or false\r
- // How to force a persistent connection\r
- function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)\r
- {\r
- // not implemented in mysqli (yet)?\r
- $this->_connectionID = mysqli_connect($argHostname,\r
- $argUsername,\r
- $argPassword,\r
- $argDatabasename);\r
- if ($this->_connectionID === false) return false;\r
- // if ($this->autoRollback) $this->RollbackTrans();\r
- if ($argDatabasename) return $this->SelectDB($argDatabasename);\r
- return true; \r
- }\r
- \r
- // When is this used? Close old connection first?\r
- // In _connect(), check $this->forceNewConnect? \r
- function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)\r
- {\r
- $this->forceNewConnect = true;\r
- $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);\r
- }\r
\r
function &MetaColumns($table) \r
{\r
{\r
return $sql;\r
\r
- $stmt = mysqli_prepare($this->_connectionID,$sql);\r
- if (!$stmt) return false;\r
+ $stmt = $this->_connectionID->prepare($sql);\r
+ if (!$stmt) {\r
+ echo $this->ErrorMsg();\r
+ return $sql;\r
+ }\r
return array($sql,$stmt);\r
}\r
\r
function _query($sql, $inputarr)\r
{\r
global $ADODB_COUNTRECS;\r
- \r
+ \r
if (is_array($sql)) {\r
$stmt = $sql[1];\r
+ $a = '';\r
foreach($inputarr as $k => $v) {\r
- if (is_string($v)) $a[] = MYSQLI_BIND_STRING;\r
- else if (is_integer($v)) $a[] = MYSQLI_BIND_INT; \r
- else $a[] = MYSQLI_BIND_DOUBLE;\r
- \r
- $fnarr =& array_merge( array($stmt,$a) , $inputarr);\r
- $ret = call_user_func_array('mysqli_bind_param',$fnarr);\r
+ if (is_string($v)) $a .= 's';\r
+ else if (is_integer($v)) $a .= 'i'; \r
+ else $a .= 'd';\r
}\r
- $ret = mysqli_execute($stmt);\r
+ \r
+ $fnarr =& array_merge( array($stmt,$a) , $inputarr);\r
+ $ret = call_user_func_array('mysqli_stmt_bind_param',$fnarr);\r
+\r
+ $ret = mysqli_stmt_execute($stmt);\r
return $ret;\r
}\r
if (!$mysql_res = mysqli_query($this->_connectionID, $sql, ($ADODB_COUNTRECS) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT)) {\r
<?php\r
\r
/*\r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
var $hasTransactions = true;\r
var $autoRollback = true; // apparently mysql does not autorollback properly \r
\r
+ function ADODB_mysqlt() \r
+ { \r
+ global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_';\r
+ }\r
+ \r
function BeginTrans()\r
{ \r
if ($this->transOff) return true;\r
class ADORecordSet_mysqlt extends ADORecordSet_mysql{ \r
var $databaseType = "mysqlt";\r
\r
- function ADORecordSet_mysqlt($queryID,$mode=false) {\r
- return $this->ADORecordSet_mysql($queryID,$mode);\r
+ function ADORecordSet_mysqlt($queryID,$mode=false) \r
+ {\r
+ if ($mode === false) { \r
+ global $ADODB_FETCH_MODE;\r
+ $mode = $ADODB_FETCH_MODE;\r
+ }\r
+ switch ($mode)\r
+ {\r
+ case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;\r
+ case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;\r
+ default:\r
+ case ADODB_FETCH_DEFAULT:\r
+ case ADODB_FETCH_BOTH:$this->fetchMode = MYSQL_BOTH; break;\r
+ }\r
+ \r
+ $this->ADORecordSet($queryID); \r
}\r
\r
- function MoveNext() \r
- { \r
- if ($this->EOF) return false;\r
-\r
- $this->_currentRow++;\r
- // using & below slows things down by 20%!\r
- $this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode);\r
- if ($this->fields) return true;\r
- $this->EOF = true;\r
- \r
+ function MoveNext()\r
+ {\r
+ if (@$this->fields =& mysql_fetch_array($this->_queryID,$this->fetchMode)) {\r
+ $this->_currentRow += 1;\r
+ return true;\r
+ }\r
+ if (!$this->EOF) {\r
+ $this->_currentRow += 1;\r
+ $this->EOF = true;\r
+ }\r
return false;\r
- } \r
+ }\r
+}\r
+\r
+class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt { \r
+\r
+ function ADORecordSet_ext_mysqli($queryID,$mode=false) \r
+ {\r
+ if ($mode === false) { \r
+ global $ADODB_FETCH_MODE;\r
+ $mode = $ADODB_FETCH_MODE;\r
+ }\r
+ switch ($mode)\r
+ {\r
+ case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;\r
+ case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;\r
+ default:\r
+ case ADODB_FETCH_DEFAULT:\r
+ case ADODB_FETCH_BOTH:$this->fetchMode = MYSQL_BOTH; break;\r
+ }\r
+ \r
+ $this->ADORecordSet($queryID); \r
+ }\r
+ \r
+ function MoveNext()\r
+ {\r
+ return adodb_movenext($this);\r
+ }\r
}\r
+\r
?>
\ No newline at end of file
<?php\r
/*\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.\r
\r
First cut at the Netezza Driver by Josh Eldridge joshuae74#hotmail.com\r
Based on the previous postgres drivers.\r
var $_resultid = false;\r
var $concat_operator='||';\r
var $random = 'random';\r
- var $upperCase = 'upper';\r
var $metaDatabasesSQL = "select objname from _v_object_data where objtype='database' order by 1";\r
var $metaTablesSQL = "select objname from _v_object_data where objtype='table' order by 1";\r
var $isoDates = true; // accepts dates in ISO format\r
function ADODB_oci8() \r
{\r
$this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200;\r
+ if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_';\r
}\r
\r
/* Function &MetaColumns($table) added by smondino@users.sourceforge.net*/\r
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,1);\r
}\r
\r
- \r
- \r
// returns true or false\r
function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)\r
{\r
if ($this->session_sharing_force_blob) $this->Execute('ALTER SESSION SET CURSOR_SHARING=EXACT');\r
$commit = $this->autoCommit;\r
if ($commit) $this->BeginTrans();\r
- $rs = ADODB_oci8::Execute($sql,$arr);\r
+ $rs = $this->_Execute($sql,$arr);\r
if ($rez = !empty($rs)) $desc->save($val);\r
$desc->free();\r
if ($commit) $this->CommitTrans();\r
return $rez;\r
}\r
\r
- function Param($name)\r
+ function Param($name,$type=false)\r
{\r
return ':'.$name;\r
}\r
// returns true or false\r
function _close()\r
{\r
+ if (!$this->_connectionID) return;\r
+ \r
if (!$this->autoCommit) OCIRollback($this->_connectionID);\r
if (count($this -> _refLOBs) > 0) {\r
foreach ($this -> _refLOBs as $key => $value) {\r
}\r
}\r
OCILogoff($this->_connectionID);\r
+ \r
$this->_stmt = false;\r
$this->_connectionID = false;\r
}\r
}\r
\r
\r
+ /*\r
// 10% speedup to move MoveNext to child class\r
- function MoveNext() \r
+ function _MoveNext() \r
{\r
//global $ADODB_EXTENSION;if ($ADODB_EXTENSION) return @adodb_movenext($this);\r
\r
$this->EOF = true;\r
\r
return false;\r
- } \r
+ } */\r
+ \r
+ \r
+ function MoveNext()\r
+ {\r
+ if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {\r
+ $this->_currentRow += 1;\r
+ return true;\r
+ }\r
+ if (!$this->EOF) {\r
+ $this->_currentRow += 1;\r
+ $this->EOF = true;\r
+ }\r
+ return false;\r
+ }\r
+ \r
\r
/* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */\r
function &GetArrayLimit($nrows,$offset=-1) \r
}\r
}\r
}\r
+\r
+class ADORecordSet_ext_oci8 extends ADORecordSet_oci8 { \r
+ function ADORecordSet_ext_oci8($queryID,$mode=false) \r
+ {\r
+ if ($mode === false) { \r
+ global $ADODB_FETCH_MODE;\r
+ $mode = $ADODB_FETCH_MODE;\r
+ }\r
+ switch ($mode)\r
+ {\r
+ default:\r
+ case ADODB_FETCH_NUM: $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;\r
+ case ADODB_FETCH_ASSOC:$this->fetchMode = OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;\r
+ case ADODB_FETCH_DEFAULT:\r
+ case ADODB_FETCH_BOTH:$this->fetchMode = OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;\r
+ }\r
+\r
+ $this->_queryID = $queryID;\r
+ }\r
+ \r
+ function MoveNext()\r
+ {\r
+ return adodb_movenext($this);\r
+ }\r
+}\r
?>
\ No newline at end of file
<?php\r
/*\r
-V4.50 6 July 2004 (c) 2000-2004 John Lim. All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim. All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
\r
function ADODB_oci8po()\r
{\r
- $this->ADODB_oci8();\r
+ $this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200;\r
+ # oci8po does not support adodb extension: adodb_movenext()\r
}\r
\r
function Param($name)\r
\r
var $databaseType = 'oci8po';\r
\r
- function ADORecordset_oci8po($queryID,$mode=false)\r
- {\r
- $this->ADORecordset_oci8($queryID,$mode);\r
- }\r
+ function ADORecordset_oci8po($queryID,$mode=false)\r
+ {\r
+ $this->ADORecordset_oci8($queryID,$mode);\r
+ }\r
\r
- function Fields($colname)\r
- {\r
- if ($this->fetchMode & OCI_ASSOC) return $this->fields[$colname];\r
- \r
- if (!$this->bind) {\r
- $this->bind = array();\r
- for ($i=0; $i < $this->_numOfFields; $i++) {\r
- $o = $this->FetchField($i);\r
- $this->bind[strtoupper($o->name)] = $i;\r
- }\r
+ function Fields($colname)\r
+ {\r
+ if ($this->fetchMode & OCI_ASSOC) return $this->fields[$colname];\r
+ \r
+ if (!$this->bind) {\r
+ $this->bind = array();\r
+ for ($i=0; $i < $this->_numOfFields; $i++) {\r
+ $o = $this->FetchField($i);\r
+ $this->bind[strtoupper($o->name)] = $i;\r
}\r
- return $this->fields[$this->bind[strtoupper($colname)]];\r
}\r
- \r
- // lowercase field names...\r
- function &_FetchField($fieldOffset = -1)\r
- {\r
- $fld = new ADOFieldObject;\r
- $fieldOffset += 1;\r
- $fld->name = strtolower(OCIcolumnname($this->_queryID, $fieldOffset));\r
- $fld->type = OCIcolumntype($this->_queryID, $fieldOffset);\r
- $fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);\r
- if ($fld->type == 'NUMBER') {\r
- //$p = OCIColumnPrecision($this->_queryID, $fieldOffset);\r
- $sc = OCIColumnScale($this->_queryID, $fieldOffset);\r
- if ($sc == 0) $fld->type = 'INT';\r
- }\r
- return $fld;\r
+ return $this->fields[$this->bind[strtoupper($colname)]];\r
+ }\r
+ \r
+ // lowercase field names...\r
+ function &_FetchField($fieldOffset = -1)\r
+ {\r
+ $fld = new ADOFieldObject;\r
+ $fieldOffset += 1;\r
+ $fld->name = strtolower(OCIcolumnname($this->_queryID, $fieldOffset));\r
+ $fld->type = OCIcolumntype($this->_queryID, $fieldOffset);\r
+ $fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);\r
+ if ($fld->type == 'NUMBER') {\r
+ //$p = OCIColumnPrecision($this->_queryID, $fieldOffset);\r
+ $sc = OCIColumnScale($this->_queryID, $fieldOffset);\r
+ if ($sc == 0) $fld->type = 'INT';\r
+ }\r
+ return $fld;\r
+ }\r
+ /*\r
+ function MoveNext()\r
+ {\r
+ if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {\r
+ $this->_currentRow += 1;\r
+ return true;\r
+ }\r
+ if (!$this->EOF) {\r
+ $this->_currentRow += 1;\r
+ $this->EOF = true;\r
}\r
+ return false;\r
+ }*/\r
\r
// 10% speedup to move MoveNext to child class\r
function MoveNext() \r
{\r
- \r
- if (!$this->EOF) { \r
+ if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {\r
+ global $ADODB_ANSI_PADDING_OFF;\r
$this->_currentRow++;\r
- if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {\r
- global $ADODB_ANSI_PADDING_OFF;\r
- \r
- if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();\r
- if (!empty($ADODB_ANSI_PADDING_OFF)) {\r
- foreach($this->fields as $k => $v) {\r
- if (is_string($v)) $this->fields[$k] = rtrim($v);\r
- }\r
+ \r
+ if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();\r
+ if (!empty($ADODB_ANSI_PADDING_OFF)) {\r
+ foreach($this->fields as $k => $v) {\r
+ if (is_string($v)) $this->fields[$k] = rtrim($v);\r
}\r
- return true;\r
}\r
+ return true;\r
+ }\r
+ if (!$this->EOF) {\r
$this->EOF = true;\r
+ $this->_currentRow++;\r
}\r
return false;\r
} \r
}\r
\r
}\r
+\r
+\r
?>
\ No newline at end of file
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
var $_haserrorfunctions = true;\r
var $_has_stupid_odbc_fetch_api_change = true;\r
var $_lastAffectedRows = 0;\r
+ var $uCaseTables = true; // for meta* functions, uppercase table names\r
\r
function ADODB_odbc() \r
{ \r
\r
while(true) {\r
\r
- $rez = odbc_data_source($this->_connectionID,\r
+ $rez = @odbc_data_source($this->_connectionID,\r
$first ? SQL_FETCH_FIRST : SQL_FETCH_NEXT);\r
$first = false;\r
if (!is_array($rez)) break;\r
{\r
global $ADODB_FETCH_MODE;\r
\r
+ if ($this->uCaseTables) $table = strtoupper($table);\r
+ $schema = '';\r
+ $this->_findschema($table,$schema);\r
+\r
$savem = $ADODB_FETCH_MODE;\r
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;\r
- $qid = @odbc_primarykeys($this->_connectionID,'','',$table);\r
+ $qid = @odbc_primarykeys($this->_connectionID,'',$schema,$table);\r
\r
if (!$qid) {\r
$ADODB_FETCH_MODE = $savem;\r
{\r
global $ADODB_FETCH_MODE;\r
\r
- $table = strtoupper($table);\r
- $schema = false;\r
+ if ($this->uCaseTables) $table = strtoupper($table);\r
+ $schema = '';\r
$this->_findschema($table,$schema);\r
\r
$savem = $ADODB_FETCH_MODE;\r
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;\r
\r
- if (false) { // after testing, confirmed that the following does not work becoz of a bug\r
+ /*if (false) { // after testing, confirmed that the following does not work becoz of a bug\r
$qid2 = odbc_tables($this->_connectionID);\r
$rs = new ADORecordSet_odbc($qid2); \r
$ADODB_FETCH_MODE = $savem;\r
$rs->Close();\r
\r
$qid = odbc_columns($this->_connectionID,$q,$o,strtoupper($table),'%');\r
- } else switch ($this->databaseType) {\r
+ } */\r
+ \r
+ switch ($this->databaseType) {\r
case 'access':\r
case 'vfp':\r
- case 'db2':\r
- $qid = odbc_columns($this->_connectionID);\r
+ $qid = odbc_columns($this->_connectionID);#,'%','',strtoupper($table),'%');\r
break;\r
+ \r
+ \r
+ case 'db2':\r
+ $colname = "%";\r
+ $qid = odbc_columns($this->_connectionID, "", $schema, $table, $colname);\r
+ break;\r
\r
default:\r
$qid = @odbc_columns($this->_connectionID,'%','%',strtoupper($table),'%');\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
var $sysTimeStamp = 'GetDate()';\r
var $leftOuter = '*=';\r
var $rightOuter = '=*';\r
- var $upperCase = 'upper';\r
var $substr = 'substring';\r
var $length = 'len';\r
var $ansiOuter = true; // for mssql7 or later\r
// tested with MSSQL 2000\r
function &MetaPrimaryKeys($table)\r
{\r
- $sql = "select k.column_name from information_schema.key_column_usage k,\r
+ global $ADODB_FETCH_MODE;\r
+ \r
+ $schema = '';\r
+ $this->_findschema($table,$schema);\r
+ //if (!$schema) $schema = $this->database;\r
+ if ($schema) $schema = "and k.table_catalog like '$schema%'"; \r
+ \r
+ $sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k,\r
information_schema.table_constraints tc \r
where tc.constraint_name = k.constraint_name and tc.constraint_type =\r
- 'PRIMARY KEY' and k.table_name = '$table'";\r
+ 'PRIMARY KEY' and k.table_name = '$table' $schema order by ordinal_position ";\r
\r
+ $savem = $ADODB_FETCH_MODE;\r
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;\r
$a = $this->GetCol($sql);\r
+ $ADODB_FETCH_MODE = $savem;\r
+ \r
if ($a && sizeof($a)>0) return $a;\r
return false; \r
}\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
<?php\r
/*\r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license.\r
Whenever there is any discrepancy between the two licenses,\r
the BSD license will take precedence. See License.txt.\r
$this->_canSelectDb = true;\r
$this->substr = "substring";\r
$this->length = 'len';\r
- $this->upperCase = 'upper';\r
$this->identitySQL = 'select @@IDENTITY';\r
$this->metaDatabasesSQL = "select name from master..sysdatabases where name <> 'master'";\r
break;\r
$this->replaceQuote = "'+chr(39)+'";\r
$this->true = '.T.';\r
$this->false = '.F.';\r
- $this->upperCase = 'upper';\r
break;\r
case ODB_DRIVER_ORACLE:\r
$this->fmtDate = "'Y-m-d 00:00:00'";\r
$this->rightOuter = '=*';\r
$this->hasInsertID = true;\r
$this->hasTransactions = true;\r
- $this->upperCase = 'upper';\r
$this->identitySQL = 'select @@IDENTITY';\r
break;\r
default:\r
}\r
}\r
\r
-?>\r
-\r
-\r
+?>
\ No newline at end of file
<?php\r
/*\r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license.\r
Whenever there is any discrepancy between the two licenses,\r
the BSD license will take precedence. See License.txt.\r
}\r
}\r
}\r
-?>\r
-\r
+?>
\ No newline at end of file
<?php\r
/*\r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
\r
Latest version is available at http://adodb.sourceforge.net\r
\r
- Oracle data driver. Requires Oracle client. Works on Windows and Unix and Oracle 7 and 8.\r
+ Oracle data driver. Requires Oracle client. Works on Windows and Unix and Oracle 7.\r
\r
- If you are using Oracle 8, use the oci8 driver which is much better and more reliable.\r
+ If you are using Oracle 8 or later, use the oci8 driver which is much better and more reliable.\r
*/\r
\r
// security - hide paths\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
<?php\r
/*\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
/*\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
\r
// for schema support, pass in the $table param "$schema.$tabname".\r
// converts field names to lowercase, $upper is ignored\r
- function &MetaColumns($table,$upper=true) \r
+ function &MetaColumns($table,$normalize=true) \r
{\r
global $ADODB_FETCH_MODE;\r
\r
$schema = false;\r
$this->_findschema($table,$schema);\r
\r
- $table = strtolower($table);\r
+ if ($normalize) $table = strtolower($table);\r
\r
$save = $ADODB_FETCH_MODE;\r
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;\r
}\r
\r
if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; \r
- else $retarr[($upper) ? strtoupper($fld->name) : $fld->name] = $fld;\r
+ else $retarr[($normalize) ? strtoupper($fld->name) : $fld->name] = $fld;\r
\r
$rs->MoveNext();\r
}\r
// cache types for blob decode check\r
for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { \r
if (pg_fieldtype($qid,$i) == 'bytea') {\r
- $this->_blobArr[$i] = pg_fieldname($qid,$off);\r
+ $this->_blobArr[$i] = pg_fieldname($qid,$i);\r
}\r
- } \r
+ }\r
}\r
\r
/* Use associative array to get fields array */\r
if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) {\r
$this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);\r
if (is_array($this->fields) && $this->fields) {\r
- if ($this->fields && isset($this->_blobArr)) $this->_fixblobs();\r
+ if (isset($this->_blobArr)) $this->_fixblobs();\r
return true;\r
}\r
}\r
<?php\r
/*\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
/*\r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
<?php\r
/*\r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
/*\r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license.\r
Whenever there is any discrepancy between the two licenses,\r
the BSD license will take precedence.\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim. All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim. All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
if ($offset > 0 && $cnt) $cnt += $offset;\r
\r
$this->Execute("set rowcount $cnt"); \r
- $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);\r
+ $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,0);\r
$this->Execute("set rowcount 0"); \r
\r
return $rs;\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
var $true = '.T.';\r
var $false = '.F.';\r
var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE\r
- var $upperCase = 'upper';\r
var $_bindInputArray = false; // strangely enough, setting to true does not work reliably\r
var $sysTimeStamp = 'datetime()';\r
var $sysDate = 'date()';\r
return time();\r
}\r
\r
- \r
function BeginTrans() { return false;}\r
\r
// quote string to be sent back to database\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. See License.txt. \r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. See License.txt. \r
<?php\r
\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. See License.txt. \r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. See License.txt. \r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. See License.txt. \r
having count(*) > 100)",'These are sql statements that should be using bind variables'),*/\r
'index cache cost' => array('COST',\r
"select value from v\$parameter where name = 'optimizer_index_caching'",\r
- '% of indexed data blocks expected in the cache.\r
- Recommended is 20-80. Default is 0. See <a href=http://www.dba-oracle.com/oracle_tips_cbo_part1.htm>optimizer_index_caching</a>.'),\r
- \r
+ '=WarnIndexCost'),\r
'random page cost' => array('COST',\r
"select value from v\$parameter where name = 'optimizer_index_cost_adj'",\r
- '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>. '), \r
+ '=WarnPageCost'),\r
\r
false\r
\r
$this->conn =& $conn;\r
}\r
\r
+ function WarnPageCost($val)\r
+ {\r
+ if ($val == 100) $s = '<font color=red><b>Too High</b>. </font>';\r
+ else $s = '';\r
+ \r
+ 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>. ';\r
+ }\r
+ \r
+ function WarnIndexCost($val)\r
+ {\r
+ if ($val == 0) $s = '<font color=red><b>Too Low</b>. </font>';\r
+ else $s = '';\r
+ \r
+ return $s.'Percentage of indexed data blocks expected in the cache.\r
+ Recommended is 20 (fast disk array) to 50 (slower hard disks). Default is 0.\r
+ See <a href=http://www.dba-oracle.com/oracle_tips_cbo_part1.htm>optimizer_index_caching</a>.';\r
+ }\r
\r
function PGA()\r
{\r
<?php\r
\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. See License.txt. \r
<?php\r
\r
-// $CVSHeader$\r
-\r
/*\r
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Contributed by Ross Smith (adodb@netebb.com). \r
<?php\r
\r
-// $CVSHeader$\r
\r
/*\r
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
<?php\r
\r
-// $CVSHeader$\r
\r
/*\r
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
<?php\r
\r
-// $CVSHeader$\r
\r
/*\r
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
<?php\r
\r
-// $CVSHeader$\r
-\r
/*\r
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Contributed by Ross Smith (adodb@netebb.com). \r
<?php\r
\r
-// $CVSHeader$\r
-\r
/*\r
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Contributed by Ross Smith (adodb@netebb.com). \r
<?php\r
\r
-// $CVSHeader$\r
\r
/*\r
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
<?php\r
\r
-// $CVSHeader$\r
\r
/*\r
V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
<body>\r
<?php \r
/*\r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
/*\r
\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
/*\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
echo "<h3>PHP ".PHP_VERSION."</h3>\n";\r
try {\r
\r
-$dbt = 'mysqli';\r
+$dbt = 'oci8po';\r
\r
switch($dbt) {\r
-case 'oci8':\r
- $db = NewADOConnection("oci8");\r
+case 'oci8po':\r
+ $db = NewADOConnection("oci8po");\r
$db->Connect('','scott','natsoft');\r
break;\r
default:\r
break;\r
\r
case 'mysqli':\r
- $db = NewADOConnection("mysqli");\r
- $db->Connect('localhost','root','','test');\r
+ $db = NewADOConnection("mysqli://root:@localhost/test");\r
+ //$db->Connect('localhost','root','','test');\r
break;\r
}\r
\r
$db->debug=1;\r
\r
-$cnt = $db->GetOne("select count(*) from adoxyz");\r
-$rs = $db->Execute("select * from adoxyz order by id");\r
+$cnt = $db->GetOne("select count(*) from adoxyz where ?<id and id<?",array(10,20));\r
+$stmt = $db->Prepare("select * from adoxyz where ?<id and id<?");\r
+if (!$stmt) echo $db->ErrorMsg(),"\n";\r
+$rs = $db->Execute($stmt,array(10,20));\r
\r
$i = 0;\r
foreach($rs as $v) {\r
$i += 1;\r
- echo "$i: "; adodb_pr($v); adodb_pr($rs->fields);\r
+ echo "rec $i: "; adodb_pr($v); adodb_pr($rs->fields);\r
flush();\r
}\r
\r
+\r
if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n");\r
\r
\r
$e = adodb_backtrace($e->gettrace());\r
}\r
\r
+$rs = $db->Execute("select distinct id, firstname,lastname from adoxyz order by id");\r
+echo "Result=\n",$rs;\r
?>
\ No newline at end of file
// uncomment the following line:\r
#$schema->upgradeSchema();\r
\r
+print "<b>SQL to build xmlschema.xml</b>:\n<pre>";\r
// Build the SQL array\r
$sql = $schema->ParseSchema( "xmlschema.xml" );\r
\r
-print "Here's the SQL to do the build:\n<pre>";\r
print_r( $sql );\r
print "</pre>\n";\r
\r
\r
$db2->Execute("drop table simple_table");\r
\r
+\r
+print "<b>SQL to build xmlschema-mssql.xml</b>:\n<pre>";\r
+\r
$schema = new adoSchema( $db2 );\r
$sql = $schema->ParseSchema( "xmlschema-mssql.xml" );\r
\r
-print "Here's the SQL to do the build:\n<pre>";\r
print_r( $sql );\r
print "</pre>\n";\r
\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
print "<br><i>ts4</i> =".($db->UnixTimeStamp("19700101000101")+8*3600);\r
print "<br><i>ts5</i> =".$db->DBTimeStamp($db->UnixTimeStamp("20040110092123"));\r
print "<br><i>ts6</i> =".$db->UserTimeStamp("20040110092123");\r
- print "<br><i>ts6</i> =".$db->DBTimeStamp("20040110092123");\r
+ print "<br><i>ts7</i> =".$db->DBTimeStamp("20040110092123");\r
flush();\r
// mssql too slow in failing bad connection\r
if (false && $db->databaseType != 'mssql') {\r
}\r
error_reporting($e);\r
flush();\r
- \r
+\r
//$ADODB_COUNTRECS=false;\r
$rs=$db->Execute('select * from adoxyz order by id');\r
\r
$saved = $db->debug;\r
$db->debug=true;\r
\r
+\r
+ /*\r
+ CREATE TABLE PHOTOS\r
+ (\r
+ ID NUMBER(16),\r
+ PHOTO BLOB,\r
+ DESCRIPTION VARCHAR2(4000 BYTE),\r
+ DESCCLOB CLOB\r
+ );\r
+ \r
+ INSERT INTO PHOTOS (ID) VALUES(1);\r
+ */\r
+ $s = '';\r
+ for ($i = 0; $i <= 500; $i++) {\r
+ $s .= '1234567890';\r
+ }\r
+ \r
+ \r
+ print "<h4>Testing Blob: size=".strlen($s)."</h4>";\r
+ $ok = $db->Updateblob('photos','photo',$s,'id=1');\r
+ if (!$ok) Err("Blob failed 1");\r
+ else {\r
+ $s2= $db->GetOne("select photo from photos where id=1");\r
+ if ($s !== $s2) Err("updateblob does not match");\r
+ }\r
+ \r
+ print "<h4>Testing Clob: size=".strlen($s)."</h4>";\r
+ $ok = $db->UpdateClob('photos','descclob',$s,'id=1');\r
+ if (!$ok) Err("Clob failed 1");\r
+ else {\r
+ $s2= $db->GetOne("select descclob from photos where id=1");\r
+ if ($s !== $s2) Err("updateclob does not match");\r
+ }\r
+ \r
+ \r
+ $s = '';\r
+ $s2 = '';\r
print "<h4>Testing Foreign Keys</h4>";\r
$arr = $db->MetaForeignKeys('emp');\r
print_r($arr);\r
print "<h4>Testing Cursor Variables</h4>";\r
/*\r
-- TEST PACKAGE\r
-CREATE OR REPLACE PACKAGE adodb AS\r
-TYPE TabType IS REF CURSOR RETURN tab%ROWTYPE;\r
-PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames in varchar);\r
-PROCEDURE data_out(input IN varchar, output OUT varchar); \r
-END adodb;\r
+\r
+CREATE OR REPLACE PACKAGE Adodb AS\r
+TYPE TabType IS REF CURSOR RETURN TAB%ROWTYPE;\r
+PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames IN VARCHAR);\r
+PROCEDURE open_tab2 (tabcursor IN OUT TabType,tablenames IN OUT VARCHAR) ;\r
+PROCEDURE data_out(input IN VARCHAR, output OUT VARCHAR);\r
+\r
+PROCEDURE myproc (p1 IN NUMBER, p2 OUT NUMBER);\r
+END Adodb;\r
/\r
\r
-CREATE OR REPLACE PACKAGE BODY adodb AS\r
-PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames in varchar) IS\r
+\r
+CREATE OR REPLACE PACKAGE BODY Adodb AS\r
+PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames IN VARCHAR) IS\r
BEGIN\r
- OPEN tabcursor FOR SELECT * FROM tab where tname like tablenames;\r
+ OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames;\r
END open_tab;\r
+\r
+ PROCEDURE open_tab2 (tabcursor IN OUT TabType,tablenames IN OUT VARCHAR) IS\r
+ BEGIN\r
+ OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames;\r
+ tablenames := 'TEST';\r
+ END open_tab2;\r
\r
-PROCEDURE data_out(input IN varchar, output OUT varchar) IS\r
+PROCEDURE data_out(input IN VARCHAR, output OUT VARCHAR) IS\r
BEGIN\r
output := 'Cinta Hati '||input;\r
END;\r
-END adodb;\r
+\r
+PROCEDURE myproc (p1 IN NUMBER, p2 OUT NUMBER) AS\r
+BEGIN\r
+p2 := p1;\r
+END;\r
+END Adodb;\r
/\r
+\r
+\r
*/\r
- $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:RS,'A%'); END;");\r
+ $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:zz,'A%'); END;",'zz');\r
\r
if ($rs && !$rs->EOF) {\r
- print "Test 1 RowCount: ".$rs->RecordCount()."<p>";\r
+ $v = $db->GetOne("SELECT count(*) FROM tab where tname like 'A%'");\r
+ if ($v == $rs->RecordCount()) print "Test 1 RowCount: OK<p>";\r
+ else Err("Test 1 RowCount ".$rs->RecordCount().", actual = $v");\r
} else {\r
print "<b>Error in using Cursor Variables 1</b><p>";\r
}\r
$db->CompleteTrans();\r
$rs = $db->Execute('select * from ADOXYZ order by id');\r
if ($rs->RecordCount() != 3) Err("Bad bulk insert");\r
+ \r
rs2html($rs);\r
\r
$db->Execute('delete from ADOXYZ');\r
$db->debug = true;\r
print "<p>SelectLimit Distinct Test 1: Should see Caroline, John and Mary</p>";\r
$rs = &$db->SelectLimit('select distinct * from ADOXYZ order by id',3);\r
+ \r
+ echo "<p>Date Update Test</p>";\r
+ $zdate = date('Y-m-d',time()+3600*24);\r
+ $zdate = $db->DBDate($zdate);\r
+ $db->Execute("update ADOXYZ set created=$zdate where id=1");\r
+ $row = $db->GetRow("select created,firstname from ADOXYZ where id=1");\r
+ print_r($row); echo "<br>";\r
+ \r
+ //$zdate = date('Y-m-d',time()+3600*24);\r
+ //$db->Execute("update ADOXYZ set created=? where id=2",$zdate);\r
+ //$zdate = $db->GetOne("select created from ADOXYZ where id=2");\r
+ //echo "tomorrow=",$zdate,"<br>";\r
$db->debug=false;\r
-\r
+ \r
if ($rs && !$rs->EOF) {\r
if (trim($rs->fields[1]) != 'Caroline') Err("Error 1");\r
$rs->MoveNext();\r
$save = $ADODB_FETCH_MODE;\r
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;\r
if ($db->dataProvider == 'postgres') {\r
- $sql = "select ".$db->Concat('cast(firstname as varchar)',$db->qstr(' '),'lastname')." as fullname,id from ADOXYZ";\r
+ $sql = "select ".$db->Concat('cast(firstname as varchar)',$db->qstr(' '),'lastname')." as fullname,id,".$db->sysTimeStamp." as d from ADOXYZ";\r
$rs = &$db->Execute($sql);\r
} else {\r
- $sql = "select distinct ".$db->Concat('firstname',$db->qstr(' '),'lastname')." as fullname,id from ADOXYZ";\r
+ $sql = "select distinct ".$db->Concat('firstname',$db->qstr(' '),'lastname')." as fullname,id,".$db->sysTimeStamp." as d from ADOXYZ";\r
$rs = &$db->Execute($sql);\r
}\r
if ($rs) {\r
//$arr = $db->GetArray("select lastname,firstname from ADOXYZ");\r
//print_r($arr);\r
print "<hr>";\r
- $rs =& $db->Execute("select distinct lastname,firstname from ADOXYZ");\r
+ $rs =& $db->Execute("select distinct lastname,firstname,created from ADOXYZ");\r
\r
if ($rs) {\r
$arr = $rs->GetAssoc();\r
//print_r($arr);\r
- if (empty($arr['See']) || trim($arr['See']) != 'Wai Hun') print $arr['See']." <b>ERROR</b><br>";\r
+ if (empty($arr['See']) || trim(reset($arr['See'])) != 'Wai Hun') print $arr['See']." <b>ERROR</b><br>";\r
else print " OK 1";\r
}\r
\r
$HTTP_GET_VARS[$_SERVER['argv'][1]] = 1;\r
}\r
\r
-if ( @$HTTP_SERVER_VARS['COMPUTERNAME'] == 'TIGRESS') {\r
+if (@$HTTP_SERVER_VARS['COMPUTERNAME'] == 'TIGRESS') {\r
CheckWS('mysqlt');\r
CheckWS('postgres');\r
CheckWS('oci8po');\r
\r
This script tests the following databases: Interbase, Oracle, Visual FoxPro, Microsoft Access (ODBC and ADO), MySQL, MSSQL (ODBC, native, ADO). \r
There is also support for Sybase, PostgreSQL.</p>\r
-For the latest version of ADODB, visit <a href=http://php.weblogs.com/ADODB>php.weblogs.com</a>.</p>\r
+For the latest version of ADODB, visit <a href=http://adodb.sourceforge.net/>adodb.sourceforge.net</a>.</p>\r
\r
Test <a href=test4.php>GetInsertSQL/GetUpdateSQL</a> \r
<a href=testsessions.php>Sessions</a> \r
\r
echo "<br>vers=",ADOConnection::Version();\r
\r
+\r
include_once('../adodb-time.inc.php');\r
-adodb_date_test();\r
+if (!isset($_GET['nd'])) adodb_date_test();\r
?>\r
<p><i>ADODB Database Library (c) 2000-2004 John Lim. All rights reserved. Released under BSD and LGPL.</i></p>\r
</body>\r
<body>\r
<?php\r
/*\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
<?php\r
/*\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
\r
$sql = "\r
SELECT * \r
-FROM ADOXYZ WHERE lastname=".$conn->qstr($record['lastname']); \r
+FROM ADOXYZ WHERE lastname=".$conn->qstr($record['lastname']). " ORDER BY 1"; \r
// Select a record to update \r
\r
$rs = $conn->Execute($sql); // Execute the query and get the existing record to update\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
<body>\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
<?php\r
\r
/*\r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
\r
$db = &ADONewConnection('postgres');\r
print "<h1>Connecting $db->databaseType...</h1>";\r
- if (@$db->Connect("localhost","tester","test","test")) {\r
+ if ($db->Connect("localhost","tester","test","test")) {\r
testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname varchar,created date)");\r
}else\r
print "ERROR: PostgreSQL requires a database called test on server, user tester, password test.<BR>".$db->ErrorMsg();\r
//$_GET['nolog'] = true;\r
$db = &ADONewConnection('firebird');\r
print "<h1>Connecting $db->databaseType...</h1>";\r
- if (@$db->PConnect("localhost:d:\\firebird\\10\\examples\\employee.gdb", "sysdba", "masterkey", ""))\r
+ if ($db->PConnect("localhost:d:\\firebird\\10\\examples\\employee.gdb", "sysdba", "masterkey", ""))\r
testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname char(24),price numeric(12,2),created date)");\r
else print "ERROR: Interbase test requires a database called employee.gdb".'<BR>'.$db->ErrorMsg();\r
\r
$db = &ADONewConnection('sqlite');\r
print "<h1>Connecting $db->databaseType...</h1>";\r
\r
- if (@$db->PConnect("d:\\inetpub\\adodb\\sqlite.db", "", "", ""))\r
+ if ($db->PConnect("d:\\inetpub\\adodb\\sqlite.db", "", "", ""))\r
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");\r
else print "ERROR: SQLite";\r
\r
if (!empty($testaccess)) {\r
$db = &ADONewConnection('access');\r
print "<h1>Connecting $db->databaseType...</h1>";\r
- \r
+ $access = 'd:\inetpub\wwwroot\php\NWIND.MDB';\r
$dsn = "nwind";\r
- $driver = "Driver={Microsoft Access Driver (*.mdb)};Dbq=d:\inetpub\adodb\northwind.mdb;Uid=Admin;Pwd=;";\r
- if (@$db->PConnect($dsn, "", "", ""))\r
+ $dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=$access;Uid=Admin;Pwd=;";\r
+ \r
+ //$dsn = 'Provider=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=' . $access . ';';\r
+ if ($db->PConnect($dsn, "", "", ""))\r
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");\r
else print "ERROR: Access test requires a Windows ODBC DSN=nwind, Access driver";\r
\r
. 'DATA SOURCE=' . $access . ';';\r
//. 'USER ID=;PASSWORD=;';\r
\r
- if (@$db->PConnect($myDSN, "", "", "")) {\r
+ if ($db->PConnect($myDSN, "", "", "")) {\r
print "ADO version=".$db->_connectionID->version."<br>";\r
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");\r
} else print "ERROR: Access test requires a Access database $access".'<BR>'.$db->ErrorMsg();\r
// REQUIRES MySQL server at localhost with database 'test'\r
if (!empty($testmysql)) { // MYSQL\r
\r
- $db = &ADONewConnection('mysql');\r
- print "<h1>Connecting $db->databaseType...</h1>";\r
+\r
if (PHP_VERSION >= 5 || $HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost';\r
else $server = "mangrove";\r
- if ($db->PConnect($server, "root", "", "northwind")) {\r
+ $user = 'root'; $password = ''; $database = 'northwind';\r
+ $db = &ADONewConnection("mysql://$user:$password@$server/$database?persist");\r
+ print "<h1>Connecting $db->databaseType...</h1>";\r
+ \r
+ if (true || $db->PConnect($server, "root", "", "northwind")) {\r
//$db->debug=1;$db->Execute('drop table ADOXYZ');\r
testdb($db,\r
"create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)");\r
\r
ADOLoadCode('oci805');\r
ADOLoadCode("oci8po");\r
-if (!empty($testoracle)) { \r
- \r
- $db = ADONewConnection('oci8po');\r
+if (!empty($testoracle)) {\r
+ $dsn = "oci8po://scott:natsoft@panther?persist";\r
+ $db = ADONewConnection($dsn);\r
print "<h1>Connecting $db->databaseType...</h1>";\r
- if ($db->Connect('', "scott", "natsoft",''))\r
- //if ($db->PConnect("", "scott", "tiger", "juris.ecosystem.natsoft.com.my"))\r
+ if (true || $db->Connect('', "scott", "natsoft",''))\r
testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)");\r
else print "ERROR: Oracle test requires an Oracle server setup with scott/natsoft".'<BR>'.$db->ErrorMsg();\r
\r
\r
print "<h1>Connecting $db->databaseType...</h1>";\r
\r
- $dsn = "mssql-northwind";\r
- $dsn = "Driver={SQL Server};Server=localhost;Database=northwind;";\r
+ $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=localhost;Database=northwind;";\r
\r
- if (@$db->PConnect($dsn, "adodb", "natsoft", "")) {\r
+ if ($db->PConnect($dsn, "adodb", "natsoft", "")) {\r
testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");\r
}\r
else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup";\r
. "SERVER=tigress;DATABASE=NorthWind;UID=adodb;PWD=natsoft;Trusted_Connection=No" ;\r
\r
\r
- if (@$db->PConnect($myDSN, "", "", ""))\r
+ if ($db->PConnect($myDSN, "", "", ""))\r
testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");\r
else print "ERROR: MSSQL test 2 requires MS SQL 7";\r
\r
print "<h1>Connecting $db->databaseType...</h1>";\r
\r
$ok = $db->PConnect('tigress','adodb','natsoft','northwind');\r
- //$rs = $db->Execute("exec sp_ddate");\r
- //print_r($rs->fields);\r
- //die();\r
\r
- if ($ok or @$db->PConnect("mangrove", "sa", "natsoft", "ai")) {\r
+ if ($ok or $db->PConnect("mangrove", "sa", "natsoft", "ai")) {\r
AutoDetect_MSSQL_Date_Order($db);\r
// $db->Execute('drop table adoxyz');\r
testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");\r
print "<h1>Connecting DSN-less OLEDB Provider $db->databaseType...</h1>";\r
//$db->debug=1;\r
$myDSN="SERVER=tigress;DATABASE=northwind;Trusted_Connection=yes";\r
- //$myDSN='SERVER=(local)\NetSDK;DATABASE=northwind;';\r
if ($db->PConnect($myDSN, "adodb", "natsoft", 'SQLOLEDB'))\r
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");\r
else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='mangrove', userid='sa', password='', database='ai'";\r
<body>\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
include("../adodb.inc.php");\r
include("../tohtml.inc.php");\r
\r
-if (1) {\r
+if (0) {\r
$db = ADONewConnection('oci8po');\r
\r
$db->PConnect('','scott','natsoft');\r
}\r
if (1) {\r
$db = ADONewConnection('oci8');\r
- $db->PConnect('','scott','tiger');\r
+ $db->PConnect('','scott','natsoft');\r
$db->debug = true;\r
$db->Execute("delete from emp where ename='John'");\r
print $db->Affected_Rows().'<BR>';\r
// prepare not quite ready for prime time\r
//$rs = $db->Execute($stmt,array('empno'=>3775,'ename'=>'John'));\r
if (!$rs) die("Empty RS");\r
+ \r
+ $db->setfetchmode(ADODB_FETCH_NUM);\r
+ \r
+ $vv = 'A%';\r
+ $stmt = $db->PrepareSP("BEGIN adodb.open_tab2(:rs,:tt); END;",true);\r
+ $db->OutParameter($stmt, $cur, 'rs', -1, OCI_B_CURSOR);\r
+ $db->OutParameter($stmt, $vv, 'tt');\r
+ $rs = $db->Execute($stmt);\r
+ while (!$rs->EOF) {\r
+ adodb_pr($rs->fields);\r
+ $rs->MoveNext();\r
+ }\r
+ echo " val = $vv";\r
+\r
}\r
\r
if (0) {\r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
<?php\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
<?php\r
\r
/* \r
-V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence. \r
\r
\r
#### CONNECTION\r
+if (1) {\r
$ADODB_SESSION_DRIVER='oci8';\r
$ADODB_SESSION_CONNECT='';\r
$ADODB_SESSION_USER ='scott';\r
$ADODB_SESSION_PWD ='natsoft';\r
$ADODB_SESSION_DB ='';\r
- \r
+} else {\r
+ $ADODB_SESSION_DRIVER='mysql';\r
+ $ADODB_SESSION_CONNECT='localhost';\r
+ $ADODB_SESSION_USER ='root';\r
+ $ADODB_SESSION_PWD ='';\r
+ $ADODB_SESSION_DB ='xphplens_2';\r
+}\r
\r
### TURN DEBUGGING ON\r
$ADODB_SESS_DEBUG = true;\r
<?php \r
/*\r
- V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
+ V4.51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
Released under both BSD license and Lesser GPL library license. \r
Whenever there is any discrepancy between the two licenses, \r
the BSD license will take precedence.\r
-<?xml version="1.0"?>
-<!DOCTYPE adodb_schema [
-<!ELEMENT schema (table*, sql*)>
-<!ATTLIST schema version CDATA #REQUIRED>
-<!ELEMENT table ((field+|DROP), constraint*, descr?, index*)>
-<!ELEMENT field ((NOTNULL|KEY|PRIMARY)?, (AUTO|AUTOINCREMENT)?, (DEFAULT|DEFDATE|DEFTIMESTAMP)?, NOQUOTE, constraint, descr?)>
-<!ELEMENT descr (#CDATA)>
-<!ELEMENT NOTNULL EMPTY>
-<!ELEMENT KEY EMPTY>
-<!ELEMENT PRIMARY EMPTY>
-<!ELEMENT AUTO EMPTY>
-<!ELEMENT AUTOINCREMENT EMPTY>
-<!ELEMENT DEFAULT EMPTY>
-<!ELEMENT DEFDATE EMPTY>
-<!ELEMENT DEFTIMESTAMP EMPTY>
-<!ELEMENT NOQUOTE EMPTY>
-<!ELEMENT DROP EMPTY>
-<!ELEMENT constraint (#CDATA)>
-<!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 DEFAULT value CDATA #REQUIRED>
-<!ELEMENT index ((col+|DROP), CLUSTERED?, BITMAP?, UNIQUE?, FULLTEXT?, HASH?, descr?)>
-<!ELEMENT col (#CDATA)>
-<!ELEMENT CLUSTERED EMPTY>
-<!ELEMENT BITMAP EMPTY>
-<!ELEMENT UNIQUE EMPTY>
-<!ELEMENT FULLTEXT EMPTY>
-<!ELEMENT HASH EMPTY>
-<!ATTLIST index name CDATA #REQUIRED>
-<!ELEMENT sql (query+, descr?)>
-<!ELEMENT query (#CDATA)>
-<!ATTLIST sql name CDATA #IMPLIED platform CDATA #IMPLIED, key CDATA, prefixmethod (AUTO|MANUAL|NONE) >
-] >
+<?xml version="1.0"?>\r
+<!DOCTYPE adodb_schema [\r
+<!ELEMENT schema (table*, sql*)>\r
+<!ATTLIST schema version CDATA #REQUIRED>\r
+<!ELEMENT table ((field+|DROP), constraint*, descr?, index*, data*)>\r
+<!ELEMENT field ((NOTNULL|KEY|PRIMARY)?, (AUTO|AUTOINCREMENT)?, (DEFAULT|DEFDATE|DEFTIMESTAMP)?, NOQUOTE, constraint, descr?)>\r
+<!ELEMENT data (row+)>\r
+<!ELEMENT row (f+)>\r
+<!ELEMENT f (#CDATA)>\r
+<!ELEMENT descr (#CDATA)>\r
+<!ELEMENT NOTNULL EMPTY>\r
+<!ELEMENT KEY EMPTY>\r
+<!ELEMENT PRIMARY EMPTY>\r
+<!ELEMENT AUTO EMPTY>\r
+<!ELEMENT AUTOINCREMENT EMPTY>\r
+<!ELEMENT DEFAULT EMPTY>\r
+<!ELEMENT DEFDATE EMPTY>\r
+<!ELEMENT DEFTIMESTAMP EMPTY>\r
+<!ELEMENT NOQUOTE EMPTY>\r
+<!ELEMENT DROP EMPTY>\r
+<!ELEMENT constraint (#CDATA)>\r
+<!ATTLIST table name CDATA #REQUIRED platform CDATA #IMPLIED version CDATA #IMPLIED>\r
+<!ATTLIST field name CDATA #REQUIRED type (C|C2|X|X2|B|D|T|L|I|F|N) #REQUIRED size CDATA #IMPLIED>\r
+<!ATTLIST data platform CDATA #IMPLIED>\r
+<!ATTLIST f name CDATA #IMPLIED>\r
+<!ATTLIST DEFAULT value CDATA #REQUIRED>\r
+<!ELEMENT index ((col+|DROP), CLUSTERED?, BITMAP?, UNIQUE?, FULLTEXT?, HASH?, descr?)>\r
+<!ELEMENT col (#CDATA)>\r
+<!ELEMENT CLUSTERED EMPTY>\r
+<!ELEMENT BITMAP EMPTY>\r
+<!ELEMENT UNIQUE EMPTY>\r
+<!ELEMENT FULLTEXT EMPTY>\r
+<!ELEMENT HASH EMPTY>\r
+<!ATTLIST index name CDATA #REQUIRED platform CDATA #IMPLIED>\r
+<!ELEMENT sql (query+, descr?)>\r
+<!ELEMENT query (#CDATA)>\r
+<!ATTLIST sql name CDATA #IMPLIED platform CDATA #IMPLIED, key CDATA, prefixmethod (AUTO|MANUAL|NONE) >\r
+] >\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<xsl:stylesheet version="1.0"\r
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
+>\r
+ <xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="UTF-8"/>\r
+ \r
+ <!-- Schema -->\r
+ <xsl:template match="/">\r
+ <xsl:comment>\r
+ADODB XMLSchema\r
+http://adodb-xmlschema.sourceforge.net\r
+</xsl:comment>\r
+ \r
+ <xsl:comment>\r
+Uninstallation Schema\r
+</xsl:comment>\r
+ \r
+ <xsl:element name="schema">\r
+ <xsl:attribute name="version">0.2</xsl:attribute>\r
+ \r
+ <xsl:apply-templates select="schema/table">\r
+ <xsl:sort select="position()" data-type="number" order="descending"/>\r
+ </xsl:apply-templates>\r
+ </xsl:element>\r
+ </xsl:template>\r
+ \r
+ <!-- Table -->\r
+ <xsl:template match="table">\r
+ <xsl:if test="count(DROP) = 0">\r
+ <xsl:element name="table">\r
+ <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>\r
+ \r
+ <xsl:if test="string-length(@platform) > 0">\r
+ <xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>\r
+ </xsl:if>\r
+ \r
+ <xsl:if test="string-length(@version) > 0">\r
+ <xsl:attribute name="version"><xsl:value-of select="@version"/></xsl:attribute>\r
+ </xsl:if>\r
+ \r
+ <xsl:apply-templates select="descr[1]"/>\r
+ \r
+ <xsl:element name="DROP"/>\r
+ </xsl:element>\r
+ </xsl:if>\r
+ </xsl:template>\r
+ \r
+ <!-- Description -->\r
+ <xsl:template match="descr">\r
+ <xsl:element name="descr">\r
+ <xsl:value-of select="normalize-space(text())"/>\r
+ </xsl:element>\r
+ </xsl:template>\r
+</xsl:stylesheet>
\ No newline at end of file