Merge branch 'MDL-73664-master' of https://github.com/aanabit/moodle

This commit is contained in:
Ilya Tregubov 2022-02-03 16:37:55 +02:00
commit aafeca8f75
111 changed files with 3660 additions and 3068 deletions

View File

@ -1,23 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Latest version is available at https://adodb.org/
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Active Record implementation. Superset of Zend Framework's.
Version 0.92
See http://www-128.ibm.com/developerworks/java/library/j-cb03076/?ca=dgr-lnxw01ActiveRecord
for info on Ruby on Rails Active Record implementation
*/
/**
* Active Record implementation. Superset of Zend Framework's.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
include_once(ADODB_DIR.'/adodb-lib.inc.php');
global $_ADODB_ACTIVE_DBS;
global $ADODB_ACTIVE_CACHESECS; // set to true to enable caching of metadata such as field info
@ -74,10 +76,9 @@ function ADODB_SetDatabaseAdapter(&$db, $index=false)
class ADODB_Active_Record {
static $_changeNames = true; // dynamically pluralize table names
/*
* Optional parameter that duplicates the ADODB_QUOTE_FIELDNAMES
*/
static $_quoteNames = false;
/** @var bool|string Allows override of global $ADODB_QUOTE_FIELDNAMES */
public $_quoteNames;
static $_foreignSuffix = '_id'; //
var $_dbat; // associative index pointing to ADODB_Active_DB eg. $ADODB_Active_DBS[_dbat]
@ -117,7 +118,12 @@ class ADODB_Active_Record {
// php5 constructor
function __construct($table = false, $pkeyarr=false, $db=false)
{
global $_ADODB_ACTIVE_DBS;
global $_ADODB_ACTIVE_DBS, $ADODB_QUOTE_FIELDNAMES;
// Set the local override for field quoting, only if not defined yet
if (!isset($this->_quoteNames)) {
$this->_quoteNames = $ADODB_QUOTE_FIELDNAMES;
}
if ($db == false && is_object($pkeyarr)) {
$db = $pkeyarr;
@ -880,7 +886,7 @@ class ADODB_Active_Record {
$cnt += 1;
}
}
$tableName = $this->nameQuoter($db,$this->_table);
$sql = sprintf('INSERT INTO %s (%s) VALUES (%s)',
$tableName,
@ -919,7 +925,7 @@ class ADODB_Active_Record {
$where = $this->GenWhere($db,$table);
$tableName = $this->nameQuoter($db,$this->_table);
$sql = sprintf('DELETE FROM %s WHERE %s',
$tableName,
$where
@ -995,19 +1001,19 @@ class ADODB_Active_Record {
}
break;
}
$newArr = array();
foreach($arr as $k=>$v)
$newArr[$this->nameQuoter($db,$k)] = $v;
$arr = $newArr;
$newPkey = array();
foreach($pkey as $k=>$v)
$newPkey[$k] = $this->nameQuoter($db,$v);
$pkey = $newPkey;
$tableName = $this->nameQuoter($db,$this->_table);
$ok = $db->Replace($tableName,$arr,$pkey);
if ($ok) {
$this->_saved = true; // 1= update 2=insert
@ -1095,7 +1101,7 @@ class ADODB_Active_Record {
$tableName,
implode(',',$pairs),
$where);
$ok = $db->Execute($sql,$valarr);
if ($ok) {
$this->_original = $neworig;
@ -1114,62 +1120,27 @@ class ADODB_Active_Record {
}
/**
* Quotes the table and column and field names
*
* this honours the ADODB_QUOTE_FIELDNAMES directive. The routines that
* use it should really just call _adodb_getinsertsql and _adodb_getupdatesql
* which is a nice easy project if you are interested
*
* @param obj $db The database connection
* @param string $name The table or column name to quote
*
* @return string The quoted name
*/
private function nameQuoter($db,$string)
* Quotes the table, column and field names.
*
* This honours the internal {@see $_quoteNames} property, which overrides
* the global $ADODB_QUOTE_FIELDNAMES directive.
*
* @param ADOConnection $db The database connection
* @param string $name The table or column name to quote
*
* @return string The quoted name
*/
private function nameQuoter($db, $name)
{
global $ADODB_QUOTE_FIELDNAMES;
if (!$ADODB_QUOTE_FIELDNAMES && !$this->_quoteNames)
/*
* Nothing to be done
*/
return $string;
if ($this->_quoteNames == 'NONE')
/*
* Force no quoting when ADODB_QUOTE_FIELDNAMES is set
*/
return $string;
if ($this->_quoteNames)
/*
* Internal setting takes precedence
*/
$quoteMethod = $this->_quoteNames;
else
$quoteMethod = $ADODB_QUOTE_FIELDNAMES;
switch ($quoteMethod)
{
case 'LOWER':
$string = strtolower($string);
break;
case 'NATIVE':
/*
* Nothing to be done
*/
break;
case 'UPPER':
default:
$string = strtoupper($string);
}
$string = sprintf( '%s%s%s',
$db->nameQuote,
$string,
$db->nameQuote
);
$save = $ADODB_QUOTE_FIELDNAMES;
$ADODB_QUOTE_FIELDNAMES = $this->_quoteNames;
$string = _adodb_quote_fieldname($db, $name);
$ADODB_QUOTE_FIELDNAMES = $save;
return $string;
}
@ -1182,7 +1153,7 @@ global $_ADODB_ACTIVE_DBS;
$save = $db->SetFetchMode(ADODB_FETCH_NUM);
$qry = "select * from ".$table;
if (!empty($whereOrderBy)) {

View File

@ -1,27 +1,27 @@
<?php
/*
/**
* Active Record implementation. Superset of Zend Framework's.
*
* This is "Active Record eXtended" to support JOIN, WORK and LAZY mode
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Latest version is available at https://adodb.org/
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Active Record implementation. Superset of Zend Framework's.
This is "Active Record eXtended" to support JOIN, WORK and LAZY mode by Chris Ravenscroft chris#voilaweb.com
Version 0.9
See http://www-128.ibm.com/developerworks/java/library/j-cb03076/?ca=dgr-lnxw01ActiveRecord
for info on Ruby on Rails Active Record implementation
*/
// CFR: Active Records Definitions
// CFR: Active Records Definitions
define('ADODB_JOIN_AR', 0x01);
define('ADODB_WORK_AR', 0x02);
define('ADODB_LAZY_AR', 0x03);

View File

@ -1,4 +1,26 @@
<?php
/**
* Library for CSV serialization.
*
* This is used by the csv/proxy driver and is the CacheExecute()
* serialization format.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -6,22 +28,6 @@ if (!defined('ADODB_DIR')) die();
global $ADODB_INCLUDED_CSV;
$ADODB_INCLUDED_CSV = 1;
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Library for CSV serialization. This is used by the csv/proxy driver and is the
CacheExecute() serialization format.
*/
/**
* convert a recordset into special format
*

View File

@ -1,27 +1,30 @@
<?php
/**
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
DOCUMENTATION:
See adodb/tests/test-datadict.php for docs and examples.
*/
/*
Test script for parser
*/
* ADOdb Data Dictionary base class.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
/**
* Test script for parser
*/
function lens_ParseTest()
{
$str = "`zcol ACOL` NUMBER(32,2) DEFAULT 'The \"cow\" (and Jim''s dog) jumps over the moon' PRIMARY, INTI INT AUTO DEFAULT 0, zcol2\"afs ds";
@ -164,6 +167,7 @@ function lens_ParseArgs($args,$endstmtchar=',',$tokenchars='_.-')
class ADODB_DataDict {
/** @var ADOConnection */
var $connection;
var $debug = false;
var $dropTable = 'DROP TABLE %s';
@ -182,16 +186,18 @@ class ADODB_DataDict {
var $invalidResizeTypes4 = array('CLOB','BLOB','TEXT','DATE','TIME'); // for changeTableSQL
var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob
/// in other words, we use a text area for editing.
/** @var string Uppercase driver name */
var $upperName;
/*
* Indicates whether a BLOB/CLOB field will allow a NOT NULL setting
* The type is whatever is matched to an X or X2 or B type. We must
* The type is whatever is matched to an X or X2 or B type. We must
* explicitly set the value in the driver to switch the behaviour on
*/
public $blobAllowsNotNull;
/*
* Indicates whether a BLOB/CLOB field will allow a DEFAULT set
* The type is whatever is matched to an X or X2 or B type. We must
* The type is whatever is matched to an X or X2 or B type. We must
* explicitly set the value in the driver to switch the behaviour on
*/
public $blobAllowsDefaultValue;
@ -678,11 +684,11 @@ class ADODB_DataDict {
//-----------------
// Parse attributes
foreach($fld as $attr => $v) {
if ($attr == 2 && is_numeric($v))
if ($attr == 2 && is_numeric($v))
$attr = 'SIZE';
elseif ($attr == 2 && strtoupper($ftype) == 'ENUM')
elseif ($attr == 2 && strtoupper($ftype) == 'ENUM')
$attr = 'ENUM';
else if (is_numeric($attr) && $attr > 1 && !is_numeric($v))
else if (is_numeric($attr) && $attr > 1 && !is_numeric($v))
$attr = strtoupper($v);
switch($attr) {
@ -744,9 +750,9 @@ class ADODB_DataDict {
* some blob types do not accept nulls, so we override the
* previously defined value
*/
$fnotnull = false;
$fnotnull = false;
if ($fprimary)
if ($fprimary)
$pkey[] = $fname;
if (($ty == 'X' || $ty == 'X2' || $ty == 'XL' || $ty == 'B') && !$this->blobAllowsDefaultValue)
@ -843,7 +849,7 @@ class ADODB_DataDict {
if (strlen($fprec)) $ftype .= ",".$fprec;
$ftype .= ')';
}
/*
* Handle additional options
*/
@ -856,12 +862,12 @@ class ADODB_DataDict {
case 'ENUM':
$ftype .= '(' . $value . ')';
break;
default:
}
}
}
return $ftype;
}
@ -924,7 +930,7 @@ class ADODB_DataDict {
return $sql;
}
}
$s = "CREATE TABLE $tabname (\n";
$s .= implode(",\n", $lines);
if (sizeof($pkey)>0) {

View File

@ -1,19 +1,27 @@
<?php
/**
* @version v5.21.0 2021-02-27
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
* Error handling code and constants.
*
* Set tabs to 4 for best viewing.
* Adapted from the PEAR DB error handling code.
* Portions (c)1997-2002 The PHP Group
*
* The following code is adapted from the PEAR DB error handling code.
* Portions (c)1997-2002 The PHP Group.
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
if (!defined("DB_ERROR")) define("DB_ERROR",-1);
if (!defined("DB_ERROR_SYNTAX")) {

View File

@ -1,18 +1,23 @@
<?php
/**
* @version v5.21.0 2021-02-27
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
* ADOdb Default Error Handler.
*
* Set tabs to 4 for best viewing.
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* Latest version is available at https://adodb.org/
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
*/
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// added Claudio Bustos clbustos#entelchile.net
if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);

View File

@ -1,17 +1,24 @@
<?php
/**
* @version v5.21.0 2021-02-27
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
* Error Handler with PEAR support.
*
* Set tabs to 4 for best viewing.
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* Latest version is available at https://adodb.org/
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
*/
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
include_once('PEAR.php');
if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_PEAR');

View File

@ -1,21 +1,24 @@
<?php
/**
* @version v5.21.0 2021-02-27
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
* Error handling using Exceptions.
*
* Set tabs to 4 for best viewing.
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* Latest version is available at https://adodb.org/
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* Exception-handling code using PHP5 exceptions (try-catch-throw).
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
define('ADODB_ERROR_HANDLER','adodb_throw');

View File

@ -1,26 +0,0 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4.
Declares the ADODB Base Class for PHP5 "ADODB_BASE_RS", and supports iteration with
the ADODB_Iterator class.
$rs = $db->Execute("select * from adoxyz");
foreach($rs as $k => $v) {
echo $k; print_r($v); echo "<br>";
}
Iterator code based on http://cvs.php.net/cvs.php/php-src/ext/spl/examples/cachingiterator.inc?login=2
Moved to adodb.inc.php to improve performance.
*/

View File

@ -1,22 +1,32 @@
<?php
/**
* Helper functions.
*
* Less commonly used functions are placed here to reduce size of adodb.inc.php.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
global $ADODB_INCLUDED_LIB;
$ADODB_INCLUDED_LIB = 1;
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Less commonly used functions are placed here to reduce size of adodb.inc.php.
*/
function adodb_strip_order_by($sql)
{
$rez = preg_match_all('/(\sORDER\s+BY\s(?:[^)](?!LIMIT))*)/is', $sql, $arr);
@ -394,10 +404,23 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
{
$qryRecs = 0;
if (!empty($zthis->_nestedSQL) || preg_match("/^\s*SELECT\s+DISTINCT/is", $sql) ||
preg_match('/\s+GROUP\s+BY\s+/is',$sql) ||
preg_match('/\s+UNION\s+/is',$sql)) {
/*
* These databases require a "SELECT * FROM (SELECT" type
* statement to have an alias for the result
*/
$requiresAlias = '';
$requiresAliasArray = array('postgres9','postgres','mysql','mysqli','mssql','mssqlnative','sqlsrv');
if (in_array($zthis->databaseType,$requiresAliasArray)
|| in_array($zthis->dsnType,$requiresAliasArray)
) {
$requiresAlias = '_ADODB_ALIAS_';
}
if (!empty($zthis->_nestedSQL)
|| preg_match("/^\s*SELECT\s+DISTINCT/is", $sql)
|| preg_match('/\s+GROUP\s+BY\s+/is',$sql)
|| preg_match('/\s+UNION\s+/is',$sql)
) {
$rewritesql = adodb_strip_order_by($sql);
// ok, has SELECT DISTINCT or GROUP BY so see if we can use a table alias
@ -408,24 +431,37 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
$rewritesql = "SELECT ".$hint[0]." COUNT(*) FROM (".$rewritesql.")";
} else
$rewritesql = "SELECT COUNT(*) FROM (".$rewritesql.")";
} else {
$rewritesql = "SELECT COUNT(*) FROM ($rewritesql) $requiresAlias";
}
} else if (strncmp($zthis->databaseType,'postgres',8) == 0
|| strncmp($zthis->databaseType,'mysql',5) == 0
|| strncmp($zthis->databaseType,'mssql',5) == 0
|| strncmp($zthis->dsnType,'sqlsrv',5) == 0
|| strncmp($zthis->dsnType,'mssql',5) == 0
){
$rewritesql = "SELECT COUNT(*) FROM ($rewritesql) _ADODB_ALIAS_";
} else {
$rewritesql = "SELECT COUNT(*) FROM ($rewritesql)";
}
} else {
// now replace SELECT ... FROM with SELECT COUNT(*) FROM
if ( strpos($sql, '_ADODB_COUNT') !== FALSE ) {
$rewritesql = preg_replace('/^\s*?SELECT\s+_ADODB_COUNT(.*)_ADODB_COUNT\s/is','SELECT COUNT(*) ',$sql);
} else {
$rewritesql = preg_replace('/^\s*SELECT\s.*\s+FROM\s/Uis','SELECT COUNT(*) FROM ',$sql);
// Replace 'SELECT ... FROM' with 'SELECT COUNT(*) FROM'
// Parse the query one char at a time starting after the SELECT
// to find the FROM clause's position, ignoring any sub-queries.
$start = stripos($sql, 'SELECT') + 7;
if ($start === false) {
// Not a SELECT statement - probably should trigger an exception here
return 0;
}
$len = strlen($sql);
$numParentheses = 0;
for ($pos = $start; $pos < $len; $pos++) {
switch ($sql[$pos]) {
case '(': $numParentheses++; continue 2;
case ')': $numParentheses--; continue 2;
}
// Ignore whatever is between parentheses (sub-queries)
if ($numParentheses > 0) {
continue;
}
// Exit loop if 'FROM' keyword was found
if (strtoupper(substr($sql, $pos, 4)) == 'FROM') {
break;
}
}
$rewritesql = 'SELECT COUNT(*) ' . substr($sql, $pos);
// fix by alexander zhukov, alex#unipack.ru, because count(*) and 'order by' fails
// with mssql, access and postgresql. Also a good speedup optimization - skips sorting!
// also see PHPLens Issue No: 12752
@ -433,7 +469,9 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
}
if (isset($rewritesql) && $rewritesql != $sql) {
if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[0];
if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) {
$rewritesql .= $limitarr[0];
}
if ($secs2cache) {
// we only use half the time of secs2cache because the count can quickly
@ -442,18 +480,23 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
} else {
$qryRecs = $zthis->GetOne($rewritesql,$inputarr);
}
}
if ($qryRecs !== false) return $qryRecs;
}
//--------------------------------------------
// query rewrite failed - so try slower way...
// strip off unneeded ORDER BY if no UNION
if (preg_match('/\s*UNION\s*/is', $sql)) $rewritesql = $sql;
else $rewritesql = $rewritesql = adodb_strip_order_by($sql);
if (preg_match('/\s*UNION\s*/is', $sql)) {
$rewritesql = $sql;
} else {
$rewritesql = $rewritesql = adodb_strip_order_by($sql);
}
if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[0];
if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) {
$rewritesql .= $limitarr[0];
}
if ($secs2cache) {
$rstest = $zthis->CacheExecute($secs2cache,$rewritesql,$inputarr);
@ -630,10 +673,50 @@ function _adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr
return $rsreturn;
}
function _adodb_getupdatesql(&$zthis, &$rs, $arrFields, $forceUpdate=false, $force=2)
/**
* Performs case conversion and quoting of the given field name.
*
* See Global variable $ADODB_QUOTE_FIELDNAMES.
*
* @param ADOConnection $zthis
* @param string $fieldName
*
* @return string Quoted field name
*/
function _adodb_quote_fieldname($zthis, $fieldName)
{
global $ADODB_QUOTE_FIELDNAMES;
// Case conversion - defaults to UPPER
$case = is_bool($ADODB_QUOTE_FIELDNAMES) ? 'UPPER' : $ADODB_QUOTE_FIELDNAMES;
switch ($case) {
case 'LOWER':
$fieldName = strtolower($fieldName);
break;
case 'NATIVE':
// Do nothing
break;
case 'UPPER':
case 'BRACKETS':
default:
$fieldName = strtoupper($fieldName);
break;
}
// Quote field if requested, or necessary (field contains space)
if ($ADODB_QUOTE_FIELDNAMES || strpos($fieldName, ' ') !== false ) {
if ($ADODB_QUOTE_FIELDNAMES === 'BRACKETS') {
return $zthis->leftBracket . $fieldName . $zthis->rightBracket;
} else {
return $zthis->nameQuote . $fieldName . $zthis->nameQuote;
}
} else {
return $fieldName;
}
}
function _adodb_getupdatesql(&$zthis, &$rs, $arrFields, $forceUpdate=false, $force=2)
{
if (!$rs) {
printf(ADODB_BAD_RS,'GetUpdateSQL');
return false;
@ -679,21 +762,7 @@ function _adodb_getupdatesql(&$zthis, &$rs, $arrFields, $forceUpdate=false, $for
$type = 'C';
}
if ((strpos($upperfname,' ') !== false) || ($ADODB_QUOTE_FIELDNAMES)) {
switch ($ADODB_QUOTE_FIELDNAMES) {
case 'BRACKETS':
$fnameq = $zthis->leftBracket.$upperfname.$zthis->rightBracket;break;
case 'LOWER':
$fnameq = $zthis->nameQuote.strtolower($field->name).$zthis->nameQuote;break;
case 'NATIVE':
$fnameq = $zthis->nameQuote.$field->name.$zthis->nameQuote;break;
case 'UPPER':
default:
$fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;break;
}
} else {
$fnameq = $upperfname;
}
$fnameq = _adodb_quote_fieldname($zthis, $field->name);
//********************************************************//
if (is_null($arrFields[$upperfname])
@ -819,7 +888,6 @@ function _adodb_getinsertsql(&$zthis, &$rs, $arrFields, $force=2)
static $cacheRS = false;
static $cacheSig = 0;
static $cacheCols;
global $ADODB_QUOTE_FIELDNAMES;
$tableName = '';
$values = '';
@ -870,21 +938,7 @@ static $cacheCols;
$upperfname = strtoupper($field->name);
if (adodb_key_exists($upperfname,$arrFields,$force)) {
$bad = false;
if ((strpos($upperfname,' ') !== false) || ($ADODB_QUOTE_FIELDNAMES)) {
switch ($ADODB_QUOTE_FIELDNAMES) {
case 'BRACKETS':
$fnameq = $zthis->leftBracket.$upperfname.$zthis->rightBracket;break;
case 'LOWER':
$fnameq = $zthis->nameQuote.strtolower($field->name).$zthis->nameQuote;break;
case 'NATIVE':
$fnameq = $zthis->nameQuote.$field->name.$zthis->nameQuote;break;
case 'UPPER':
default:
$fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;break;
}
} else
$fnameq = $upperfname;
$fnameq = _adodb_quote_fieldname($zthis, $field->name);
$type = $recordSet->MetaType($field->type);
/********************************************************/
@ -1119,8 +1173,16 @@ function _adodb_debug_execute(&$zthis, $sql, $inputarr)
foreach($inputarr as $kk=>$vv) {
if (is_string($vv) && strlen($vv)>64) $vv = substr($vv,0,64).'...';
if (is_null($vv)) $ss .= "($kk=>null) ";
else $ss .= "($kk=>'$vv') ";
else
{
if (is_array($vv))
{
$vv = sprintf("Array Of Values: [%s]", implode(',',$vv));
}
$ss .= "($kk=>'$vv') ";
}
}
$ss = "[ $ss ]";
}
$sqlTxt = is_array($sql) ? $sql[0] : $sql;

View File

@ -8,20 +8,20 @@
* including dealing with connection failures and retrying queries on a different
* connection instead.
*
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence. See LICENSE.md.
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* Latest version is available at https://adodb.org/
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* @package ADOdb
* @version v5.21.0 2021-02-27
* @author Mike Benoit
* @copyright (c) 2016 Mike Benoit and the ADOdb community
* @license BSD-3-Clause
* @license GNU Lesser General Public License (LGPL) v2.1 or later
* @link https://adodb.org/
* @since v5.21.0
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2016 Mike Benoit and the ADOdb community
*/
/**

View File

@ -1,4 +1,23 @@
<?php
/**
* Memory caching.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -9,37 +28,6 @@ $ADODB_INCLUDED_MEMCACHE = 1;
global $ADODB_INCLUDED_CSV;
if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Usage:
$db = NewADOConnection($driver);
$db->memCache = true; /// should we use memCache instead of caching in files
$db->memCacheHost = array($ip1, $ip2, $ip3);
$db->memCachePort = 11211; /// this is default memCache port
$db->memCacheCompress = false; /// Use 'true' to store the item compressed (uses zlib)
/// Note; compression is not supported w/the memcached library
$db->Connect(...);
$db->CacheExecute($sql);
Notes; The memcache class is shared by all connections, is created during the first call to Connect/PConnect.
We'll look for both the memcache library (https://pecl.php.net/package/memcache) and the memcached
library (https://pecl.php.net/package/memcached). If both exist, the memcache library will be used.
Class instance is stored in $ADODB_CACHE
*/
class ADODB_Cache_MemCache {
var $createdir = false; // create caching directory structure?

View File

@ -1,28 +1,24 @@
<?php
/**
* Recordset pagination with First/Prev/Next/Last links
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
This class provides recordset pagination with
First/Prev/Next/Last links.
Feel free to modify this class for your own use as
it is very basic. To learn how to use it, see the
example in adodb/tests/testpaging.php.
"Pablo Costa" <pablo@cbsp.com.br> implemented Render_PageLinks().
Please note, this class is entirely unsupported,
and no free support requests except for bug reports
will be entertained by the author.
*/
class ADODB_Pager {
var $id; // unique id for pager (defaults to 'adodb')
var $db; // ADODB connection object

View File

@ -1,18 +1,25 @@
<?php
/**
* @version v5.21.0 2021-02-27
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
* PEAR DB Emulation Layer for ADOdb.
*
* Set tabs to 4 for best viewing.
* The following code is modelled on PEAR DB code by Stig Bakken <ssb@fast.no>
* and Tomas V.V.Cox <cox@idecnet.com>. Portions (c)1997-2002 The PHP Group.
*
* PEAR DB Emulation Layer for ADODB.
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* The following code is modelled on PEAR DB code by Stig Bakken <ssb@fast.no> |
* and Tomas V.V.Cox <cox@idecnet.com>. Portions (c)1997-2002 The PHP Group.
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
/*

View File

@ -1,22 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Library for basic performance monitoring and tuning.
My apologies if you see code mixed with presentation. The presentation suits
my needs. If you want to separate code from presentation, be my guest. Patches
are welcome.
*/
/**
* performance monitoring and tuning.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
if (!defined('ADODB_DIR')) include_once(dirname(__FILE__).'/adodb.inc.php');
include_once(ADODB_DIR.'/tohtml.inc.php');

View File

@ -1,16 +0,0 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4.
*/
class ADODB_BASE_RS {
}

View File

@ -1,72 +1,67 @@
<?php
/**
* ADOdb Date Library.
*
* PHP native date functions use integer timestamps for computations.
* Because of this, dates are restricted to the years 1901-2038 on Unix
* and 1970-2038 on Windows due to integer overflow for dates beyond
* those years. This library overcomes these limitations by replacing the
* native function's signed integers (normally 32-bits) with PHP floating
* point numbers (normally 64-bits).
*
* Dates from 100 A.D. to 3000 A.D. and later have been tested.
* The minimum is 100 A.D. as <100 will invoke the 2 => 4 digit year
* conversion. The maximum is billions of years in the future, but this
* is a theoretical limit as the computation of that year would take too
* long with the current implementation of adodb_mktime().
*
* Replaces native functions as follows:
* - getdate() with adodb_getdate()
* - date() with adodb_date()
* - gmdate() with adodb_gmdate()
* - mktime() with adodb_mktime()
* - gmmktime() with adodb_gmmktime()
* - strftime() with adodb_strftime()
* - strftime() with adodb_gmstrftime()
*
* The parameters are identical, except that adodb_date() accepts a subset
* of date()'s field formats. Mktime() will convert from local time to GMT,
* and date() will convert from GMT to local time, but daylight savings is
* not handled currently.
*
* To improve performance, the native date functions are used whenever
* possible, the library only switches to PHP code when the dates fall outside
* of the 32-bit signed integer range.
*
* This library is independent of the rest of ADOdb, and can be used
* as standalone code.
*
* GREGORIAN CORRECTION
*
* Pope Gregory shortened October of A.D. 1582 by ten days. Thursday,
* October 4, 1582 (Julian) was followed immediately by Friday, October 15,
* 1582 (Gregorian). We handle this correctly, so:
* adodb_mktime(0, 0, 0, 10, 15, 1582) - adodb_mktime(0, 0, 0, 10, 4, 1582)
* == 24 * 3600 (1 day)
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2003-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
/*
ADOdb Date Library, part of the ADOdb abstraction library
Latest version is available at https://adodb.org/
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
PHP native date functions use integer timestamps for computations.
Because of this, dates are restricted to the years 1901-2038 on Unix
and 1970-2038 on Windows due to integer overflow for dates beyond
those years. This library overcomes these limitations by replacing the
native function's signed integers (normally 32-bits) with PHP floating
point numbers (normally 64-bits).
Dates from 100 A.D. to 3000 A.D. and later
have been tested. The minimum is 100 A.D. as <100 will invoke the
2 => 4 digit year conversion. The maximum is billions of years in the
future, but this is a theoretical limit as the computation of that year
would take too long with the current implementation of adodb_mktime().
This library replaces native functions as follows:
<pre>
getdate() with adodb_getdate()
date() with adodb_date()
gmdate() with adodb_gmdate()
mktime() with adodb_mktime()
gmmktime() with adodb_gmmktime()
strftime() with adodb_strftime()
strftime() with adodb_gmstrftime()
</pre>
The parameters are identical, except that adodb_date() accepts a subset
of date()'s field formats. Mktime() will convert from local time to GMT,
and date() will convert from GMT to local time, but daylight savings is
not handled currently.
This library is independent of the rest of ADOdb, and can be used
as standalone code.
PERFORMANCE
For high speed, this library uses the native date functions where
possible, and only switches to PHP code when the dates fall outside
the 32-bit signed integer range.
GREGORIAN CORRECTION
Pope Gregory shortened October of A.D. 1582 by ten days. Thursday,
October 4, 1582 (Julian) was followed immediately by Friday, October 15,
1582 (Gregorian).
Since 0.06, we handle this correctly, so:
adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582)
== 24 * 3600 (1 day)
=============================================================================
COPYRIGHT
(c) 2003-2014 John Lim and released under BSD-style license except for code by
jackbbs, which includes adodb_mktime, adodb_get_gmt_diff, adodb_is_leap_year
and originally found at http://www.php.net/manual/en/function.mktime.php
=============================================================================
FUNCTION DESCRIPTIONS

View File

@ -1,21 +1,29 @@
<?php
// Copyright (c) 2004 ars Cognita Inc., all rights reserved
/* ******************************************************************************
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
*******************************************************************************/
/**
* ADOdb XML Schema (v0.2).
*
* xmlschema is a class that allows the user to quickly and easily
* build a database on any ADOdb-supported platform using a simple
* XML schema.
*
* Last Editor: $Author: jlim $
* @author Richard Tango-Lowy & Dan Cech
* @version $Revision: 1.12 $
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package axmls
* @tutorial getting_started.pkg
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2004-2005 ars Cognita Inc., all rights reserved
* @copyright 2005-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
* @author Richard Tango-Lowy
* @author Dan Cech
*/
function _file_get_contents($file)
@ -1299,7 +1307,7 @@ class adoSchema {
function __construct( $db ) {
$this->db = $db;
$this->debug = $this->db->debug;
$this->dict = NewDataDictionary( $this->db );
$this->dict = newDataDictionary( $this->db );
$this->sqlArray = array();
$this->schemaVersion = XMLS_SCHEMA_VERSION;
$this->executeInline( XMLS_EXECUTE_INLINE );

View File

@ -1,21 +1,29 @@
<?php
// Copyright (c) 2004-2005 ars Cognita Inc., all rights reserved
/* ******************************************************************************
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
*******************************************************************************/
/**
* ADOdb XML Schema (v0.3).
*
* xmlschema is a class that allows the user to quickly and easily
* build a database on any ADOdb-supported platform using a simple
* XML schema.
*
* Last Editor: $Author: jlim $
* @author Richard Tango-Lowy & Dan Cech
* @version $Revision: 1.62 $
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package axmls
* @tutorial getting_started.pkg
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2004-2005 ars Cognita Inc., all rights reserved
* @copyright 2005-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
* @author Richard Tango-Lowy
* @author Dan Cech
*/
function _file_get_contents($file)
@ -1415,7 +1423,7 @@ class adoSchema {
function __construct( $db ) {
$this->db = $db;
$this->debug = $this->db->debug;
$this->dict = NewDataDictionary( $this->db );
$this->dict = newDataDictionary( $this->db );
$this->sqlArray = array();
$this->schemaVersion = XMLS_SCHEMA_VERSION;
$this->executeInline( XMLS_EXECUTE_INLINE );
@ -2114,7 +2122,7 @@ class adoSchema {
. '">' . "\n";
// grab details from database
$rs = $this->db->execute( 'SELECT * FROM ' . $table . ' WHERE -1' );
$rs = $this->db->execute('SELECT * FROM ' . $table . ' WHERE 0=1');
$fields = $this->db->metaColumns( $table );
$indexes = $this->db->metaIndexes( $table );

View File

@ -1,34 +1,22 @@
<?php
/*
* Set tabs to 4 for best viewing.
*
* Latest version is available at https://adodb.org/
*
* This is the main include file for ADOdb.
* Database specific drivers are stored in the adodb/drivers/adodb-*.inc.php
*
* The ADOdb files are formatted so that doxygen can be used to generate documentation.
* Doxygen is a documentation generation tool and can be downloaded from http://doxygen.org/
*/
/**
\mainpage
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. You can choose which license
you prefer.
PHP's database access functions are not standardised. This creates a need for a database
class library to hide the differences between the different database API's (encapsulate
the differences) so we can easily switch databases.
We currently support MySQL, Oracle, Microsoft SQL Server, Sybase, Sybase SQL Anywhere, DB2,
Informix, PostgreSQL, FrontBase, Interbase (Firebird and Borland variants), Foxpro, Access,
ADO, SAP DB, SQLite and ODBC. We have had successful reports of connecting to Progress and
other databases via ODBC.
* ADOdb Library main include file.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
if (!defined('_ADODB_LAYER')) {
@ -178,7 +166,7 @@ if (!defined('_ADODB_LAYER')) {
define('DB_AUTOQUERY_UPDATE', 2);
function ADODB_Setup() {
GLOBAL
$ADODB_vers, // database version
@ -210,7 +198,7 @@ if (!defined('_ADODB_LAYER')) {
/**
* ADODB version as a string.
*/
$ADODB_vers = 'v5.21.0 2021-02-27';
$ADODB_vers = 'v5.21.4 2022-01-22';
/**
* Determines whether recordset->RecordCount() is used.
@ -496,7 +484,8 @@ if (!defined('_ADODB_LAYER')) {
//
var $_oldRaiseFn = false;
var $_transOK = null;
var $_connectionID = false; /// The returned link identifier whenever a successful database connection is made.
/** @var resource Identifier for the native database connection */
var $_connectionID = false;
var $_errorMsg = false; /// A variable which was used to keep the returned last error message. The value will
/// then returned by the errorMsg() function
var $_errorCode = false; /// Last error code, not guaranteed to be used - only by oci8
@ -509,6 +498,19 @@ if (!defined('_ADODB_LAYER')) {
var $_logsql = false;
var $_transmode = ''; // transaction mode
/**
* Additional parameters that may be passed to drivers in the connect string.
*
* Data is stored as an array of arrays and not a simple associative array,
* because some drivers (e.g. mysql) allow multiple parameters with the same
* key to be set.
* @link https://github.com/ADOdb/ADOdb/issues/187
*
* @see setConnectionParameter()
*
* @var array $connectionParameters Set of ParameterName => Value pairs
*/
protected $connectionParameters = array();
/**
* Default Constructor.
@ -520,29 +522,29 @@ if (!defined('_ADODB_LAYER')) {
{
}
/*
* Additional parameters that may be passed to drivers in the connect string
* Driver must be coded to accept the parameters
*/
protected $connectionParameters = array();
/**
* Adds a parameter to the connection string.
*
* These parameters are added to the connection string when connecting,
* if the driver is coded to use it.
*
* @param string $parameter The name of the parameter to set
* @param string $value The value of the parameter
*
* @return null
*
* @example, for mssqlnative driver ('CharacterSet','UTF-8')
*/
final public function setConnectionParameter($parameter,$value) {
* Adds a parameter to the connection string.
*
* Parameters must be added before the connection is established;
* they are then passed on to the connect statement, which will.
* process them if the driver supports this feature.
*
* Example usage:
* - mssqlnative: setConnectionParameter('CharacterSet','UTF-8');
* - mysqli: setConnectionParameter(MYSQLI_SET_CHARSET_NAME,'utf8mb4');
*
* If used in a portable environment, parameters set in this manner should
* be predicated on the database provider, as unexpected results may occur
* if applied to the wrong database.
*
* @param string $parameter The name of the parameter to set
* @param string $value The value of the parameter
*
* @return bool True if success, false otherwise (e.g. parameter is not valid)
*/
public function setConnectionParameter($parameter, $value) {
$this->connectionParameters[] = array($parameter=>$value);
return true;
}
/**
@ -1302,6 +1304,7 @@ if (!defined('_ADODB_LAYER')) {
if( is_string($sql) ) {
// Strips keyword used to help generate SELECT COUNT(*) queries
// from SQL if it exists.
// TODO: obsoleted by #715 - kept for backwards-compatibility
$sql = str_replace( '_ADODB_COUNT', '', $sql );
}
@ -1443,7 +1446,7 @@ if (!defined('_ADODB_LAYER')) {
return $this->lastInsID;
}
if ($this->hasInsertID) {
return $this->_insertid($table,$column);
return $this->_insertID($table,$column);
}
if ($this->debug) {
ADOConnection::outp( '<p>Insert_ID error</p>');
@ -1452,14 +1455,35 @@ if (!defined('_ADODB_LAYER')) {
return false;
}
/**
* Enable or disable the Last Insert Id functionality.
*
* If the Driver supports it, this function allows setting {@see $hasInsertID}.
*
* @param bool $enable False to disable
*/
public function enableLastInsertID($enable = true) {}
/**
* Return the id of the last row that has been inserted in a table.
*
* @param string $table
* @param string $column
*
* @return int|false
*/
protected function _insertID($table = '', $column = '')
{
return false;
}
/**
* Portable Insert ID. Pablo Roca <pabloroca#mvps.org>
*
* @param string $table
* @param string $id
* @return mixed The last inserted ID. All databases support this, but be
* @return mixed The last inserted ID. All databases support this, but be
* aware of possible problems in multiuser environments.
* Heavily test this before deploying.
*/
@ -1648,17 +1672,19 @@ if (!defined('_ADODB_LAYER')) {
// 0 to offset-1 which will be discarded anyway. So we disable $ADODB_COUNTRECS.
global $ADODB_COUNTRECS;
$savec = $ADODB_COUNTRECS;
$ADODB_COUNTRECS = false;
try {
$savec = $ADODB_COUNTRECS;
$ADODB_COUNTRECS = false;
if ($secs2cache != 0) {
$rs = $this->CacheExecute($secs2cache,$sql,$inputarr);
} else {
$rs = $this->Execute($sql,$inputarr);
if ($secs2cache != 0) {
$rs = $this->CacheExecute($secs2cache, $sql, $inputarr);
} else {
$rs = $this->Execute($sql, $inputarr);
}
} finally {
$ADODB_COUNTRECS = $savec;
}
$ADODB_COUNTRECS = $savec;
if ($rs && !$rs->EOF) {
$rs = $this->_rs2rs($rs,$nrows,$offset);
}
@ -1805,11 +1831,15 @@ if (!defined('_ADODB_LAYER')) {
public function GetOne($sql, $inputarr=false) {
global $ADODB_COUNTRECS,$ADODB_GETONE_EOF;
$crecs = $ADODB_COUNTRECS;
$ADODB_COUNTRECS = false;
try {
$crecs = $ADODB_COUNTRECS;
$ADODB_COUNTRECS = false;
$rs = $this->Execute($sql, $inputarr);
} finally {
$ADODB_COUNTRECS = $crecs;
}
$ret = false;
$rs = $this->Execute($sql,$inputarr);
if ($rs) {
if ($rs->EOF) {
$ret = $ADODB_GETONE_EOF;
@ -1819,7 +1849,6 @@ if (!defined('_ADODB_LAYER')) {
$rs->Close();
}
$ADODB_COUNTRECS = $crecs;
return $ret;
}
@ -1948,10 +1977,14 @@ if (!defined('_ADODB_LAYER')) {
function GetArray($sql,$inputarr=false) {
global $ADODB_COUNTRECS;
$savec = $ADODB_COUNTRECS;
$ADODB_COUNTRECS = false;
$rs = $this->Execute($sql,$inputarr);
$ADODB_COUNTRECS = $savec;
try {
$savec = $ADODB_COUNTRECS;
$ADODB_COUNTRECS = false;
$rs = $this->Execute($sql, $inputarr);
} finally {
$ADODB_COUNTRECS = $savec;
}
if (!$rs)
if (defined('ADODB_PEAR')) {
return ADODB_PEAR_Error();
@ -1970,10 +2003,13 @@ if (!defined('_ADODB_LAYER')) {
function CacheGetArray($secs2cache,$sql=false,$inputarr=false) {
global $ADODB_COUNTRECS;
$savec = $ADODB_COUNTRECS;
$ADODB_COUNTRECS = false;
$rs = $this->CacheExecute($secs2cache,$sql,$inputarr);
$ADODB_COUNTRECS = $savec;
try {
$savec = $ADODB_COUNTRECS;
$ADODB_COUNTRECS = false;
$rs = $this->CacheExecute($secs2cache, $sql, $inputarr);
} finally {
$ADODB_COUNTRECS = $savec;
}
if (!$rs)
if (defined('ADODB_PEAR')) {
@ -2004,12 +2040,14 @@ if (!defined('_ADODB_LAYER')) {
function GetRow($sql,$inputarr=false) {
global $ADODB_COUNTRECS;
$crecs = $ADODB_COUNTRECS;
$ADODB_COUNTRECS = false;
try {
$crecs = $ADODB_COUNTRECS;
$ADODB_COUNTRECS = false;
$rs = $this->Execute($sql, $inputarr);
} finally {
$ADODB_COUNTRECS = $crecs;
}
$rs = $this->Execute($sql,$inputarr);
$ADODB_COUNTRECS = $crecs;
if ($rs) {
if (!$rs->EOF) {
$arr = $rs->fields;
@ -2467,11 +2505,26 @@ if (!defined('_ADODB_LAYER')) {
return $blob;
}
function GetCharSet() {
/**
* Retrieve the client connection's current character set.
*
* @return string|false The character set, or false if it can't be determined.
*/
function getCharSet() {
return $this->charSet;
}
function SetCharSet($charset) {
/**
* Sets the client-side character set.
*
* This is only supported for some databases.
* @see https://adodb.org/dokuwiki/doku.php?id=v5:reference:connection:setcharset
*
* @param string $charset The character set to switch to.
*
* @return bool True if the character set was changed successfully, false otherwise.
*/
function setCharSet($charset) {
$this->charSet = $charset;
return true;
}
@ -3390,26 +3443,32 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
$this->rs = $rs;
}
#[\ReturnTypeWillChange]
function rewind() {}
#[\ReturnTypeWillChange]
function valid() {
return !$this->rs->EOF;
}
#[\ReturnTypeWillChange]
function key() {
return false;
}
#[\ReturnTypeWillChange]
function current() {
return false;
}
#[\ReturnTypeWillChange]
function next() {}
function __call($func, $params) {
return call_user_func_array(array($this->rs, $func), $params);
}
#[\ReturnTypeWillChange]
function hasMore() {
return false;
}
@ -3456,6 +3515,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
function Init() {}
#[\ReturnTypeWillChange]
function getIterator() {
return new ADODB_Iterator_empty($this);
}
@ -3516,22 +3576,27 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
$this->rs = $rs;
}
#[\ReturnTypeWillChange]
function rewind() {
$this->rs->MoveFirst();
}
#[\ReturnTypeWillChange]
function valid() {
return !$this->rs->EOF;
}
#[\ReturnTypeWillChange]
function key() {
return $this->rs->_currentRow;
}
#[\ReturnTypeWillChange]
function current() {
return $this->rs->fields;
}
#[\ReturnTypeWillChange]
function next() {
$this->rs->MoveNext();
}
@ -3581,7 +3646,8 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
*/
var $_numOfRows = -1; /** number of rows, or -1 */
var $_numOfFields = -1; /** number of fields in recordset */
var $_queryID = -1; /** This variable keeps the result link identifier. */
/** @var resource result link identifier */
var $_queryID = -1;
var $_currentRow = -1; /** This variable keeps the current row in the Recordset. */
var $_closed = false; /** has recordset been closed */
var $_inited = false; /** Init() should only be called once */
@ -3595,6 +3661,12 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
var $_maxRecordCount = 0;
var $datetime = false;
/**
* @var ADOFieldObject[] Field metadata cache
* @see fieldTypesArray()
*/
protected $fieldObjectsCache;
/**
* Constructor
*
@ -3609,6 +3681,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
$this->Close();
}
#[\ReturnTypeWillChange]
function getIterator() {
return new ADODB_Iterator($this);
}
@ -4399,30 +4472,31 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
}
/**
* Get the ADOFieldObject of a specific column.
* Get a Field's metadata from database.
*
* @param fieldoffset is the column position to access(0-based).
* Must be defined by child class.
*
* @return the ADOFieldObject for that column, or false.
* @param int $fieldOffset
*
* @return ADOFieldObject|false
*/
function FetchField($fieldoffset = -1) {
// must be defined by child class
function fetchField($fieldOffset)
{
return false;
}
/**
* Get the ADOFieldObjects of all columns in an array.
* Get Field metadata for all the recordset's columns in an array.
*
* @return ADOFieldObject[]
*/
function FieldTypesArray() {
static $arr = array();
if (empty($arr)) {
for ($i=0, $max=$this->_numOfFields; $i < $max; $i++) {
$arr[] = $this->FetchField($i);
function fieldTypesArray() {
if (empty($this->fieldObjectsCache)) {
for ($i = 0; $i < $this->_numOfFields; $i++) {
$this->fieldObjectsCache[] = $this->fetchField($i);
}
}
return $arr;
return $this->fieldObjectsCache;
}
/**
@ -5101,13 +5175,13 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
if (!defined('ADODB_ASSOC_CASE')) {
define('ADODB_ASSOC_CASE', ADODB_ASSOC_CASE_NATIVE);
}
/*
* Are there special characters in the dsn password
* that disrupt parse_url
*/
$needsSpecialCharacterHandling = false;
$errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false;
if (($at = strpos($db,'://')) !== FALSE) {
$origdsn = $db;
@ -5134,23 +5208,23 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
* Stop # character breaking parse_url
*/
$cFakedsn = str_replace('#','\035',$fakedsn);
if (strcmp($fakedsn,$cFakedsn) != 0)
if (strcmp($fakedsn,$cFakedsn) != 0)
{
/*
* There is a # in the string
*/
$needsSpecialCharacterHandling = true;
/*
* This allows us to successfully parse the url
*/
$fakedsn = $cFakedsn;
}
$dsna = parse_url($fakedsn);
}
if (!$dsna) {
return false;
}
@ -5176,13 +5250,13 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
if (!$db) {
return false;
}
$dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : '';
$dsna['user'] = isset($dsna['user']) ? rawurldecode($dsna['user']) : '';
$dsna['pass'] = isset($dsna['pass']) ? rawurldecode($dsna['pass']) : '';
$dsna['path'] = isset($dsna['path']) ? rawurldecode(substr($dsna['path'],1)) : ''; # strip off initial /
if ($needsSpecialCharacterHandling)
if ($needsSpecialCharacterHandling)
{
/*
* Revert back to the original string
@ -5388,7 +5462,15 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
return new $class($conn);
}
function NewDataDictionary(&$conn,$drivername=false) {
/**
* Get a new Data Dictionary object for the connection.
*
* @param ADOConnection $conn
* @param string $drivername
*
* @return ADODB_DataDict|false
*/
function newDataDictionary(&$conn, $drivername='') {
if (!$drivername) {
$drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType);
}
@ -5415,8 +5497,6 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
return $dict;
}
/*
Perform a print_r, with pre tags for better formatting.
*/

View File

@ -1,16 +1,23 @@
<?php
/**
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
* Data Dictionary for Access.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,15 +1,24 @@
<?php
/**
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
* Data Dictionary for DB2.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
Set tabs to 4 for best viewing.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,16 +1,23 @@
<?php
/**
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
* Data Dictionary for Firebird.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,16 +1,23 @@
<?php
/**
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
* Generic Data Dictionary.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,16 +1,23 @@
<?php
/**
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
* Data Dictionary for Interbase.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,16 +1,23 @@
<?php
/**
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
* Data Dictionary for Informix.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,16 +1,23 @@
<?php
/**
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
* Data Dictionary for Microsoft SQL Server (mssql)
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
/*
In ADOdb, named quotes for MS SQL Server use ". From the MSSQL Docs:

View File

@ -1,16 +1,25 @@
<?php
/**
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
* Data Dictionary for Microsoft SQL Server native (mssqlnative)
Set tabs to 4 for best viewing.
*/
* FileDescription
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
/*
In ADOdb, named quotes for MS SQL Server use ". From the MSSQL Docs:
@ -45,7 +54,7 @@ if (!defined('ADODB_DIR')) die();
class ADODB2_mssqlnative extends ADODB_DataDict {
var $databaseType = 'mssqlnative';
var $dropIndex = 'DROP INDEX %1$s ON %2$s';
var $dropIndex = /** @lang text */ 'DROP INDEX %1$s ON %2$s';
var $renameTable = "EXEC sp_rename '%s','%s'";
var $renameColumn = "EXEC sp_rename '%s.%s','%s'";
var $typeX = 'TEXT'; ## Alternatively, set it to VARCHAR(4000)
@ -61,7 +70,6 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
if (is_object($t)) {
$fieldobj = $t;
$t = $fieldobj->type;
$len = $fieldobj->max_length;
}
$_typeConversion = array(
@ -97,11 +105,11 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
-3 => 'X'
);
if (isset($_typeConversion[$t]))
return $_typeConversion[$t];
return ADODB_DEFAULT_METATYPE;
if (isset($_typeConversion[$t])) {
return $_typeConversion[$t];
}
return ADODB_DEFAULT_METATYPE;
}
function ActualType($meta)
@ -141,7 +149,7 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
{
$tabname = $this->TableName ($tabname);
$f = array();
list($lines,$pkey) = $this->_GenFields($flds);
list($lines,) = $this->_GenFields($flds);
$s = "ALTER TABLE $tabname $this->addCol";
foreach($lines as $v) {
$f[] = "\n $v";
@ -151,30 +159,29 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
return $sql;
}
function DefaultConstraintname($tabname, $colname)
/**
* Get a column's default constraint.
*
* @param string $tabname
* @param string $colname
* @return string|null The Constraint's name, or null if there is none.
*/
function defaultConstraintName($tabname, $colname)
{
$constraintname = false;
$rs = $this->connection->Execute(
"SELECT name FROM sys.default_constraints
WHERE object_name(parent_object_id) = '$tabname'
AND col_name(parent_object_id, parent_column_id) = '$colname'"
);
if ( is_object($rs) ) {
$row = $rs->FetchRow();
$constraintname = $row['name'];
}
return $constraintname;
$sql = "SELECT name FROM sys.default_constraints
WHERE object_name(parent_object_id) = ?
AND col_name(parent_object_id, parent_column_id) = ?";
return $this->connection->getOne($sql, [$tabname, $colname]);
}
function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{
$tabname = $this->TableName ($tabname);
$sql = array();
list($lines,$pkey,$idxs) = $this->_GenFields($flds);
list($lines,,$idxs) = $this->_GenFields($flds);
$alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' ';
foreach($lines as $v) {
$not_null = false;
if ($not_null = preg_match('/NOT NULL/i',$v)) {
$v = preg_replace('/NOT NULL/i','',$v);
}
@ -182,7 +189,7 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
list(,$colname,$default) = $matches;
$v = preg_replace('/^' . preg_quote($colname) . '\s/', '', $v);
$t = trim(str_replace('DEFAULT '.$default,'',$v));
if ( $constraintname = $this->DefaultConstraintname($tabname,$colname) ) {
if ( $constraintname = $this->defaultConstraintName($tabname,$colname) ) {
$sql[] = 'ALTER TABLE '.$tabname.' DROP CONSTRAINT '. $constraintname;
}
if ($not_null) {
@ -195,7 +202,7 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
. ' DEFAULT ' . $default . ' FOR ' . $colname;
} else {
$colname = strtok($v," ");
if ( $constraintname = $this->DefaultConstraintname($tabname,$colname) ) {
if ( $constraintname = $this->defaultConstraintName($tabname,$colname) ) {
$sql[] = 'ALTER TABLE '.$tabname.' DROP CONSTRAINT '. $constraintname;
}
if ($not_null) {
@ -223,17 +230,19 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
* @param string $tableflds Throwaway value to make the function match the parent
* @param string $tableoptions Throway value to make the function match the parent
*
* @return string The SQL necessary to drop the column
* @return string[] The SQL necessary to drop the column
*/
function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{
$tabname = $this->TableName ($tabname);
if (!is_array($flds))
$flds = explode(',',$flds);
if (!is_array($flds)) {
/** @noinspection PhpParamsInspection */
$flds = explode(',', $flds);
}
$f = array();
$s = 'ALTER TABLE ' . $tabname;
foreach($flds as $v) {
if ( $constraintname = $this->DefaultConstraintname($tabname,$v) ) {
if ( $constraintname = $this->defaultConstraintName($tabname,$v) ) {
$sql[] = 'ALTER TABLE ' . $tabname . ' DROP CONSTRAINT ' . $constraintname;
}
$f[] = ' DROP COLUMN ' . $this->NameQuote($v);
@ -244,6 +253,8 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
}
// return string must begin with space
/** @noinspection DuplicatedCode */
function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
{
$suffix = '';
@ -255,78 +266,7 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
return $suffix;
}
/*
CREATE TABLE
[ database_name.[ owner ] . | owner. ] table_name
( { < column_definition >
| column_name AS computed_column_expression
| < table_constraint > ::= [ CONSTRAINT constraint_name ] }
| [ { PRIMARY KEY | UNIQUE } [ ,...n ]
)
[ ON { filegroup | DEFAULT } ]
[ TEXTIMAGE_ON { filegroup | DEFAULT } ]
< column_definition > ::= { column_name data_type }
[ COLLATE < collation_name > ]
[ [ DEFAULT constant_expression ]
| [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ]
]
[ ROWGUIDCOL]
[ < column_constraint > ] [ ...n ]
< column_constraint > ::= [ CONSTRAINT constraint_name ]
{ [ NULL | NOT NULL ]
| [ { PRIMARY KEY | UNIQUE }
[ CLUSTERED | NONCLUSTERED ]
[ WITH FILLFACTOR = fillfactor ]
[ON {filegroup | DEFAULT} ] ]
]
| [ [ FOREIGN KEY ]
REFERENCES ref_table [ ( ref_column ) ]
[ ON DELETE { CASCADE | NO ACTION } ]
[ ON UPDATE { CASCADE | NO ACTION } ]
[ NOT FOR REPLICATION ]
]
| CHECK [ NOT FOR REPLICATION ]
( logical_expression )
}
< table_constraint > ::= [ CONSTRAINT constraint_name ]
{ [ { PRIMARY KEY | UNIQUE }
[ CLUSTERED | NONCLUSTERED ]
{ ( column [ ASC | DESC ] [ ,...n ] ) }
[ WITH FILLFACTOR = fillfactor ]
[ ON { filegroup | DEFAULT } ]
]
| FOREIGN KEY
[ ( column [ ,...n ] ) ]
REFERENCES ref_table [ ( ref_column [ ,...n ] ) ]
[ ON DELETE { CASCADE | NO ACTION } ]
[ ON UPDATE { CASCADE | NO ACTION } ]
[ NOT FOR REPLICATION ]
| CHECK [ NOT FOR REPLICATION ]
( search_conditions )
}
*/
/*
CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name
ON { table | view } ( column [ ASC | DESC ] [ ,...n ] )
[ WITH < index_option > [ ,...n] ]
[ ON filegroup ]
< index_option > :: =
{ PAD_INDEX |
FILLFACTOR = fillfactor |
IGNORE_DUP_KEY |
DROP_EXISTING |
STATISTICS_NORECOMPUTE |
SORT_IN_TEMPDB
}
*/
/** @noinspection DuplicatedCode */
function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
{
$sql = array();
@ -358,17 +298,18 @@ CREATE TABLE
}
function _GetSize($ftype, $ty, $fsize, $fprec,$options=false)
function _GetSize($ftype, $ty, $fsize, $fprec, $options=false)
{
switch ($ftype) {
case 'INT':
case 'SMALLINT':
case 'TINYINT':
case 'BIGINT':
case 'INT':
case 'SMALLINT':
case 'TINYINT':
case 'BIGINT':
return $ftype;
}
if ($ty == 'T') {
return $ftype;
}
if ($ty == 'T') return $ftype;
return parent::_GetSize($ftype, $ty, $fsize, $fprec, $options);
return parent::_GetSize($ftype, $ty, $fsize, $fprec, $options);
}
}

View File

@ -1,16 +1,23 @@
<?php
/**
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
* Data Dictionary for MySQL.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,16 +1,23 @@
<?php
/**
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
* Data Dictionary for Oracle (oci8)
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,22 +1,29 @@
<?php
/**
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
* Data Dictionary for PostgreSQL.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB2_postgres extends ADODB_DataDict {
class ADODB2_postgres extends ADODB_DataDict
{
var $databaseType = 'postgres';
var $seqField = false;
var $seqPrefix = 'SEQ_';
@ -26,9 +33,9 @@ class ADODB2_postgres extends ADODB_DataDict {
var $dropTable = 'DROP TABLE %s CASCADE';
public $blobAllowsDefaultValue = true;
public $blobAllowsNotNull = true;
public $blobAllowsNotNull = true;
function MetaType($t,$len=-1,$fieldobj=false)
function metaType($t, $len=-1, $fieldobj=false)
{
if (is_object($t)) {
$fieldobj = $t;
@ -92,9 +99,9 @@ class ADODB2_postgres extends ADODB_DataDict {
}
}
function ActualType($meta)
function actualType($meta)
{
switch($meta) {
switch ($meta) {
case 'C': return 'VARCHAR';
case 'XL':
case 'X': return 'TEXT';
@ -131,12 +138,12 @@ class ADODB2_postgres extends ADODB_DataDict {
* @param string $flds column-names and types for the changed columns
* @return array with SQL strings
*/
function AddColumnSQL($tabname, $flds)
function addColumnSQL($tabname, $flds)
{
$tabname = $this->TableName ($tabname);
$tabname = $this->tableName($tabname);
$sql = array();
$not_null = false;
list($lines,$pkey) = $this->_GenFields($flds);
list($lines,$pkey) = $this->_genFields($flds);
$alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' ';
foreach($lines as $v) {
if (($not_null = preg_match('/NOT NULL/i',$v))) {
@ -159,9 +166,9 @@ class ADODB2_postgres extends ADODB_DataDict {
}
function DropIndexSQL ($idxname, $tabname = NULL)
function dropIndexSQL($idxname, $tabname = NULL)
{
return array(sprintf($this->dropIndex, $this->TableName($idxname), $this->TableName($tabname)));
return array(sprintf($this->dropIndex, $this->tableName($idxname), $this->tableName($tabname)));
}
/**
@ -175,25 +182,15 @@ class ADODB2_postgres extends ADODB_DataDict {
* @param array/ $tableoptions options for the new table see CreateTableSQL, default ''
* @return array with SQL strings
*/
/*
function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{
if (!$tableflds) {
if ($this->debug) ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL");
return array();
}
return $this->_recreate_copy_table($tabname,False,$tableflds,$tableoptions);
}*/
function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
function alterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
{
// Check if alter single column datatype available - works with 8.0+
$has_alter_column = 8.0 <= (float) @$this->serverInfo['version'];
if ($has_alter_column) {
$tabname = $this->TableName($tabname);
$tabname = $this->tableName($tabname);
$sql = array();
list($lines,$pkey) = $this->_GenFields($flds);
list($lines,$pkey) = $this->_genFields($flds);
$set_null = false;
foreach($lines as $v) {
$alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' ';
@ -211,13 +208,12 @@ class ADODB2_postgres extends ADODB_DataDict {
}
if (preg_match('/^([^ ]+) .*DEFAULT (\'[^\']+\'|\"[^\"]+\"|[^ ]+)/',$v,$matches)) {
$existing = $this->MetaColumns($tabname);
$existing = $this->metaColumns($tabname);
list(,$colname,$default) = $matches;
$alter .= $colname;
if ($this->connection) {
$old_coltype = $this->connection->MetaType($existing[strtoupper($colname)]);
}
else {
$old_coltype = $this->connection->metaType($existing[strtoupper($colname)]);
} else {
$old_coltype = $t;
}
$v = preg_replace('/^' . preg_quote($colname) . '\s/', '', $v);
@ -253,7 +249,7 @@ class ADODB2_postgres extends ADODB_DataDict {
$sql[] = $alter . ' TYPE ' . $rest;
}
# list($colname) = explode(' ',$v);
#list($colname) = explode(' ',$v);
if ($not_null) {
// this does not error out if the column is already not null
$sql[] = $alter . ' SET NOT NULL';
@ -271,7 +267,7 @@ class ADODB2_postgres extends ADODB_DataDict {
if ($this->debug) ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL");
return array();
}
return $this->_recreate_copy_table($tabname,False,$tableflds,$tableoptions);
return $this->_recreate_copy_table($tabname, false, $tableflds,$tableoptions);
}
/**
@ -285,17 +281,19 @@ class ADODB2_postgres extends ADODB_DataDict {
* @param array/ $tableoptions options for the new table see CreateTableSQL, default ''
* @return array with SQL strings
*/
function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
function dropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
{
$has_drop_column = 7.3 <= (float) @$this->serverInfo['version'];
if (!$has_drop_column && !$tableflds) {
if ($this->debug) ADOConnection::outp("DropColumnSQL needs complete table-definiton for PostgreSQL < 7.3");
return array();
}
if ($has_drop_column) {
return ADODB_DataDict::DropColumnSQL($tabname, $flds);
if ($this->debug) {
ADOConnection::outp("dropColumnSQL needs complete table-definiton for PostgreSQL < 7.3");
}
return array();
}
return $this->_recreate_copy_table($tabname,$flds,$tableflds,$tableoptions);
if ($has_drop_column) {
return ADODB_DataDict::dropColumnSQL($tabname, $flds);
}
return $this->_recreate_copy_table($tabname, $flds, $tableflds, $tableoptions);
}
/**
@ -310,11 +308,11 @@ class ADODB2_postgres extends ADODB_DataDict {
* @param array/string $tableoptions options for the new table see CreateTableSQL, default ''
* @return array with SQL strings
*/
function _recreate_copy_table($tabname,$dropflds,$tableflds,$tableoptions='')
function _recreate_copy_table($tabname, $dropflds, $tableflds, $tableoptions='')
{
if ($dropflds && !is_array($dropflds)) $dropflds = explode(',',$dropflds);
$copyflds = array();
foreach($this->MetaColumns($tabname) as $fld) {
foreach($this->metaColumns($tabname) as $fld) {
if (preg_match('/'.$fld->name.' (\w+)/i', $tableflds, $matches)) {
$new_type = strtoupper($matches[1]);
// AlterColumn of a char column to a nummeric one needs an explicit conversation
@ -324,7 +322,7 @@ class ADODB2_postgres extends ADODB_DataDict {
$copyflds[] = "to_number($fld->name,'S9999999999999D99')";
} else {
// other column-type changes needs explicit decode, encode for bytea or cast otherwise
$new_actual_type = $this->ActualType($new_type);
$new_actual_type = $this->actualType($new_type);
if (strtoupper($fld->type) != $new_actual_type) {
if ($new_actual_type == 'BYTEA' && $fld->type == 'text') {
$copyflds[] = "DECODE($fld->name, 'escape')";
@ -340,48 +338,48 @@ class ADODB2_postgres extends ADODB_DataDict {
}
// identify the sequence name and the fld its on
if ($fld->primary_key && $fld->has_default &&
preg_match("/nextval\('([^']+)'::(text|regclass)\)/",$fld->default_value,$matches)) {
preg_match("/nextval\('([^']+)'::(text|regclass)\)/", $fld->default_value, $matches)) {
$seq_name = $matches[1];
$seq_fld = $fld->name;
}
}
$copyflds = implode(', ',$copyflds);
$copyflds = implode(', ', $copyflds);
$tempname = $tabname.'_tmp';
$aSql[] = 'BEGIN'; // we use a transaction, to make sure not to loose the content of the table
$aSql[] = "SELECT * INTO TEMPORARY TABLE $tempname FROM $tabname";
$aSql = array_merge($aSql,$this->DropTableSQL($tabname));
$aSql = array_merge($aSql,$this->CreateTableSQL($tabname,$tableflds,$tableoptions));
$aSql = array_merge($aSql,$this->dropTableSQL($tabname));
$aSql = array_merge($aSql,$this->createTableSQL($tabname, $tableflds, $tableoptions));
$aSql[] = "INSERT INTO $tabname SELECT $copyflds FROM $tempname";
if ($seq_name && $seq_fld) { // if we have a sequence we need to set it again
$seq_name = $tabname.'_'.$seq_fld.'_seq'; // has to be the name of the new implicit sequence
$aSql[] = "SELECT setval('$seq_name',MAX($seq_fld)) FROM $tabname";
$aSql[] = "SELECT setval('$seq_name', MAX($seq_fld)) FROM $tabname";
}
$aSql[] = "DROP TABLE $tempname";
// recreate the indexes, if they not contain one of the dropped columns
foreach($this->MetaIndexes($tabname) as $idx_name => $idx_data)
{
foreach($this->metaIndexes($tabname) as $idx_name => $idx_data) {
if (substr($idx_name,-5) != '_pkey' && (!$dropflds || !count(array_intersect($dropflds,$idx_data['columns'])))) {
$aSql = array_merge($aSql,$this->CreateIndexSQL($idx_name,$tabname,$idx_data['columns'],
$idx_data['unique'] ? array('UNIQUE') : False));
$aSql = array_merge($aSql,$this->createIndexSQL($idx_name, $tabname, $idx_data['columns'],
$idx_data['unique'] ? array('UNIQUE') : false));
}
}
$aSql[] = 'COMMIT';
return $aSql;
}
function DropTableSQL($tabname)
function dropTableSQL($tabname)
{
$sql = ADODB_DataDict::DropTableSQL($tabname);
$drop_seq = $this->_DropAutoIncrement($tabname);
if ($drop_seq) $sql[] = $drop_seq;
$sql = ADODB_DataDict::dropTableSQL($tabname);
$drop_seq = $this->_dropAutoIncrement($tabname);
if ($drop_seq) {
$sql[] = $drop_seq;
}
return $sql;
}
// return string must begin with space
function _CreateSuffix($fname, &$ftype, $fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
function _createSuffix($fname, &$ftype, $fnotnull, $fdefault, $fautoinc, $fconstraint, $funsigned)
{
if ($fautoinc) {
$ftype = 'SERIAL';
@ -397,31 +395,31 @@ class ADODB2_postgres extends ADODB_DataDict {
// search for a sequence for the given table (asumes the seqence-name contains the table-name!)
// if yes return sql to drop it
// this is still necessary if postgres < 7.3 or the SERIAL was created on an earlier version!!!
function _DropAutoIncrement($tabname)
function _dropAutoIncrement($tabname)
{
$tabname = $this->connection->quote('%'.$tabname.'%');
$seq = $this->connection->GetOne("SELECT relname FROM pg_class WHERE NOT relname ~ 'pg_.*' AND relname LIKE $tabname AND relkind='S'");
$seq = $this->connection->getOne("SELECT relname FROM pg_class WHERE NOT relname ~ 'pg_.*' AND relname LIKE $tabname AND relkind='S'");
// check if a tables depends on the sequence and it therefore can't and don't need to be dropped separately
if (!$seq || $this->connection->GetOne("SELECT relname FROM pg_class JOIN pg_depend ON pg_class.relfilenode=pg_depend.objid WHERE relname='$seq' AND relkind='S' AND deptype='i'")) {
return False;
if (!$seq || $this->connection->getOne("SELECT relname FROM pg_class JOIN pg_depend ON pg_class.relfilenode=pg_depend.objid WHERE relname='$seq' AND relkind='S' AND deptype='i'")) {
return false;
}
return "DROP SEQUENCE ".$seq;
}
function RenameTableSQL($tabname,$newname)
function renameTableSQL($tabname, $newname)
{
if (!empty($this->schema)) {
$rename_from = $this->TableName($tabname);
$rename_from = $this->tableName($tabname);
$schema_save = $this->schema;
$this->schema = false;
$rename_to = $this->TableName($newname);
$rename_to = $this->tableName($newname);
$this->schema = $schema_save;
return array (sprintf($this->renameTable, $rename_from, $rename_to));
}
return array (sprintf($this->renameTable, $this->TableName($tabname),$this->TableName($newname)));
return array (sprintf($this->renameTable, $this->tableName($tabname), $this->tableName($newname)));
}
/*
@ -457,17 +455,18 @@ CREATE [ UNIQUE ] INDEX index_name ON table
[ USING acc_method ] ( func_name( column [, ... ]) [ ops_name ] )
[ WHERE predicate ]
*/
function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
function _indexSQL($idxname, $tabname, $flds, $idxoptions)
{
$sql = array();
if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
$sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
if ( isset($idxoptions['DROP']) )
if ( isset($idxoptions['DROP']) ) {
return $sql;
}
}
if ( empty ($flds) ) {
if (empty($flds)) {
return $sql;
}
@ -475,21 +474,24 @@ CREATE [ UNIQUE ] INDEX index_name ON table
$s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' ';
if (isset($idxoptions['HASH']))
if (isset($idxoptions['HASH'])) {
$s .= 'USING HASH ';
if ( isset($idxoptions[$this->upperName]) )
}
if (isset($idxoptions[$this->upperName])) {
$s .= $idxoptions[$this->upperName];
if ( is_array($flds) )
$flds = implode(', ',$flds);
}
if (is_array($flds)) {
$flds = implode(', ', $flds);
}
$s .= '(' . $flds . ')';
$sql[] = $s;
return $sql;
}
function _GetSize($ftype, $ty, $fsize, $fprec, $options=false)
function _getSize($ftype, $ty, $fsize, $fprec, $options=false)
{
if (strlen($fsize) && $ty != 'X' && $ty != 'B' && $ty != 'I' && strpos($ftype,'(') === false) {
$ftype .= "(".$fsize;
@ -500,16 +502,12 @@ CREATE [ UNIQUE ] INDEX index_name ON table
/*
* Handle additional options
*/
if (is_array($options))
{
foreach($options as $type=>$value)
{
switch ($type)
{
if (is_array($options)) {
foreach($options as $type=>$value) {
switch ($type) {
case 'ENUM':
$ftype .= '(' . $value . ')';
break;
$ftype .= '(' . $value . ')';
break;
default:
}
}
@ -517,41 +515,45 @@ CREATE [ UNIQUE ] INDEX index_name ON table
return $ftype;
}
function ChangeTableSQL($tablename, $flds, $tableoptions = false, $dropOldFlds=false){
function changeTableSQL($tablename, $flds, $tableoptions = false, $dropOldFlds=false)
{
global $ADODB_FETCH_MODE;
parent::ChangeTableSQL($tablename, $flds);
parent::changeTableSQL($tablename, $flds);
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
if ($this->connection->fetchMode !== false)
$savem = $this->connection->SetFetchMode(false);
if ($this->connection->fetchMode !== false) {
$savem = $this->connection->setFetchMode(false);
}
// check table exists
$save_handler = $this->connection->raiseErrorFn;
$this->connection->raiseErrorFn = '';
$cols = $this->MetaColumns($tablename);
$cols = $this->metaColumns($tablename);
$this->connection->raiseErrorFn = $save_handler;
if (isset($savem))
$this->connection->SetFetchMode($savem);
if (isset($savem)) {
$this->connection->setFetchMode($savem);
}
$ADODB_FETCH_MODE = $save;
$sqlResult=array();
if ( empty($cols)) {
$sqlResult=$this->CreateTableSQL($tablename, $flds, $tableoptions);
$sqlResult=$this->createTableSQL($tablename, $flds, $tableoptions);
} else {
$sqlResultAdd = $this->AddColumnSQL($tablename, $flds);
$sqlResultAlter = $this->AlterColumnSQL($tablename, $flds, '', $tableoptions);
$sqlResultAdd = $this->addColumnSQL($tablename, $flds);
$sqlResultAlter = $this->alterColumnSQL($tablename, $flds, '', $tableoptions);
$sqlResult = array_merge((array)$sqlResultAdd, (array)$sqlResultAlter);
if ($dropOldFlds) {
// already exists, alter table instead
list($lines,$pkey,$idxs) = $this->_GenFields($flds);
list($lines,$pkey,$idxs) = $this->_genFields($flds);
// genfields can return FALSE at times
if ($lines == null)
if ($lines == null) {
$lines = array();
$alter = 'ALTER TABLE ' . $this->TableName($tablename);
foreach ( $cols as $id => $v ){
if ( !isset($lines[$id]) ){
}
$alter = 'ALTER TABLE ' . $this->tableName($tablename);
foreach ( $cols as $id => $v ) {
if ( !isset($lines[$id]) ) {
$sqlResult[] = $alter . $this->dropCol . ' ' . $v->name;
}
}
@ -560,4 +562,4 @@ CREATE [ UNIQUE ] INDEX index_name ON table
}
return $sqlResult;
}
}
} // end class

View File

@ -1,17 +1,23 @@
<?php
/**
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Modified from datadict-generic.inc.php for sapdb by RalfBecker-AT-outdoor-training.de
*/
* Data Dictionary for SAP DB.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,18 +1,23 @@
<?php
/**
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
SQLite datadict Andrei Besleaga
*/
* Data Dictionary for SQLite.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,16 +1,23 @@
<?php
/**
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
* Data Dictionary for SyBase.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,17 +1,26 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
/**
* Microsoft Access driver.
*
* Requires ODBC. Works only on Microsoft Windows.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
Latest version is available at https://adodb.org/
Microsoft Access data driver. Requires ODBC. Works only on Microsoft Windows.
*/
if (!defined('_ADODB_ODBC_LAYER')) {
if (!defined('ADODB_DIR')) die();

View File

@ -1,17 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Microsoft ADO data driver. Requires ADO. Works only on MS Windows.
*/
/**
* Microsoft ADO driver.
*
* Requires ADO. Works only on MS Windows.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,17 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Microsoft ADO data driver. Requires ADO. Works only on MS Windows. PHP5 compat version.
*/
/**
* Microsoft ADO driver (PHP5 compat version).
*
* Requires ADO. Works only on MS Windows.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,17 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Microsoft Access ADO data driver. Requires ADO and ODBC. Works only on MS Windows.
*/
/**
* Microsoft Access ADO driver.
*
* Requires ADO and ODBC. Works only on MS Windows.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,21 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Microsoft SQL Server ADO data driver. Requires ADO and MSSQL client.
Works only on MS Windows.
Warning: Some versions of PHP (esp PHP4) leak memory when ADO/COM is used.
Please check http://bugs.php.net/ for more info.
*/
/**
* Microsoft SQL Server ADO driver.
*
* Requires ADO and MSSQL client. Works only on MS Windows.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -40,7 +44,7 @@ class ADODB_ado_mssql extends ADODB_ado {
//var $_inTransaction = 1; // always open recordsets, so no transaction problems.
function _insertid()
protected function _insertID($table = '', $column = '')
{
return $this->GetOne('select SCOPE_IDENTITY()');
}

View File

@ -1,20 +1,29 @@
<?php
/**
* ADOdb driver for ADS.
*
* NOTE: This driver requires the Advantage PHP client libraries, which
* can be downloaded for free via:
* @link http://devzone.advantagedatabase.com/dz/content.aspx?key=20
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
/*
(c) 2000-2014 John Lim (jlim#natsoft.com.my). All rights reserved.
Portions Copyright (c) 2007-2009, iAnywhere Solutions, Inc.
All rights reserved. All unpublished rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
NOTE: This driver requires the Advantage PHP client libraries, which
can be downloaded for free via:
http://devzone.advantagedatabase.com/dz/content.aspx?key=20
DELPHI FOR PHP USERS:
The following steps can be taken to utilize this driver from the
CodeGear Delphi for PHP product:
@ -35,6 +44,7 @@ DELPHI FOR PHP USERS:
Database object's DriverName property.
*/
// security - hide paths
if (!defined('ADODB_DIR')) {
die();

View File

@ -1,18 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Support Borland Interbase 6.5 and later
*/
/**
* Borland Interbase driver.
*
* Support Borland Interbase 6.5 and later
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,21 +1,30 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4.
Currently unsupported: MetaDatabases, MetaTables and MetaColumns, and also inputarr in Execute.
Native types have been converted to MetaTypes.
Transactions not supported yet.
Limitation of url length. For IIS, see MaxClientRequestBuffer registry value.
http://support.microsoft.com/default.aspx?scid=kb;en-us;260694
*/
/**
* FileDescription
*
* Currently unsupported: MetaDatabases, MetaTables and MetaColumns,
* and also inputarr in Execute.
* Native types have been converted to MetaTypes.
* Transactions not supported yet.
*
* Limitation of url length. For IIS, see MaxClientRequestBuffer registry value.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -38,7 +47,7 @@ class ADODB_csv extends ADOConnection {
var $hasTransactions = false;
var $_errorNo = false;
function _insertid()
protected function _insertID($table = '', $column = '')
{
return $this->_insertid;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,27 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Microsoft Visual FoxPro data driver. Requires ODBC. Works only on MS Windows.
*/
/**
* IBM DB2 / Oracle compatibility driver.
*
* This driver re-maps ibm :0 bind variables to oracle compatible ? variables.
*
* @deprecated
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,17 +1,28 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Microsoft Visual FoxPro data driver. Requires ODBC. Works only on MS Windows.
*/
/**
* IBM DB2 / Oracle compatibility driver.
*
* This driver provides undocumented bind variable mapping from ibm to oracle.
* The functionality appears to overlap the db2_oci driver.
*
* @deprecated
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,14 +1,24 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Contribution by Frank M. Kromann <frank@frontbase.com>.
Set tabs to 8.
*/
/**
* Frontbase driver.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
* @author Frank M. Kromann <frank@frontbase.com>
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -25,7 +35,7 @@ class ADODB_fbsql extends ADOConnection {
var $fmtTimeStamp = "'Y-m-d H:i:s'";
var $hasLimit = false;
function _insertid()
protected function _insertID($table = '', $column = '')
{
return fbsql_insert_id($this->_connectionID);
}

View File

@ -1,18 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
firebird data driver. Requires firebird client. Works on Windows and Unix.
*/
/**
* Firebird driver.
*
* Requires firebird client. Works on Windows and Unix.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,29 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Latest version is available at https://adodb.org/
Interbase data driver. Requires interbase client. Works on Windows and Unix.
3 Jan 2002 -- suggestions by Hans-Peter Oeri <kampfcaspar75@oeri.ch>
changed transaction handling and added experimental blob stuff
Docs to interbase at the website
http://www.synectics.co.za/php3/tutorial/IB_PHP3_API.html
To use gen_id(), see
http://www.volny.cz/iprenosil/interbase/ip_ib_code.htm#_code_creategen
$rs = $conn->Execute('select gen_id(adodb,1) from rdb$database');
$id = $rs->fields[0];
$conn->Execute("insert into table (id, col1,...) values ($id, $val1,...)");
*/
/**
* Interbase driver.
*
* Requires interbase client. Works on Windows and Unix.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,19 +1,27 @@
<?php
/**
* @version v5.21.0 2021-02-27
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
*
* Set tabs to 4 for best viewing.
*
* Latest version is available at https://adodb.org/
*
* Informix 9 driver that supports SELECT FIRST
*
*/
* Informix 9 driver.
*
* Supports SELECT FIRST.
*
* @deprecated
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,20 +1,27 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim. All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Informix port by Mitchell T. Young (mitch@youngfamily.org)
Further mods by "Samuel CARRIERE" <samuel_carriere@hotmail.com>
*/
/**
* Informix driver.
*
* @deprecated
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
* @author Mitchell T. Young <mitch@youngfamily.org>
* @author Samuel Carriere <samuel_carriere@hotmail.com>
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -83,7 +90,7 @@ class ADODB_informix72 extends ADOConnection {
function _insertid()
protected function _insertID($table = '', $column = '')
{
$sqlca =ifx_getsqlca($this->lastQuery);
return @$sqlca["sqlerrd1"];

View File

@ -1,20 +1,26 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 8.
Revision 1: (02/25/2005) Updated codebase to include the _inject_bind_options function. This allows
users to access the options in the ldap_set_option function appropriately. Most importantly
LDAP Version 3 is now supported. See the examples for more information. Also fixed some minor
bugs that surfaced when PHP error levels were set high.
Joshua Eldridge (joshuae74#hotmail.com)
*/
/**
* LDAP driver.
*
* Provides a subset of ADOdb commands, allowing read-only access to an LDAP database.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
* @author Joshua Eldridge <joshuae74@hotmail.com>
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,21 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Native mssql driver. Requires mssql client. Works on Windows.
To configure for Unix, see
http://phpbuilder.com/columns/alberto20000919.php3
*/
/**
* Native MSSQL driver.
*
* Requires mssql client. Works on Windows.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -110,7 +114,7 @@ class ADODB_mssql extends ADOConnection {
return " ISNULL($field, $ifNull) "; // if MS SQL Server
}
function _insertid()
protected function _insertID($table = '', $column = '')
{
// SCOPE_IDENTITY()
// Returns the last IDENTITY value inserted into an IDENTITY column in
@ -765,7 +769,7 @@ order by constraint_name, referenced_table_name, keyno";
$inputVar = $db->this($v);
$params .= "@P$i=N" . $inputVar;
} else if (is_integer($v)) {
$decl .= "@P$i INT";
$params .= "@P$i=".$v;
@ -815,7 +819,7 @@ order by constraint_name, referenced_table_name, keyno";
return $rez;
}
/**
* Returns a substring of a varchar type field

View File

@ -1,47 +1,27 @@
<?php
/// $Id $
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// ADOdb - Database Abstraction Library for PHP //
// //
// Latest version is available at https://adodb.org //
// //
// Copyright (c) 2000-2014 John Lim (jlim\@natsoft.com.my) //
// All rights reserved. //
// Released under both BSD license and LGPL library license. //
// Whenever there is any discrepancy between the two licenses, //
// the BSD license will take precedence //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
// Copyright (C) 2001-3001 Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
/**
* MSSQL Driver with auto-prepended "N" for correct unicode storage
* of SQL literal strings. Intended to be used with MSSQL drivers that
* are sending UCS-2 data to MSSQL (FreeTDS and ODBTP) in order to get
* true cross-db compatibility from the application point of view.
*/
* MSSQL Driver with auto-prepended "N" for correct unicode storage of SQL literal strings.
*
* Intended to be used with MSSQL drivers that are sending UCS-2 data to MSSQL
* (FreeTDS and ODBTP) in order to get true cross-db compatibility from the
* application point of view.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -60,7 +40,7 @@ class ADODB_mssql_n extends ADODB_mssql {
return ADODB_mssql::_query($sql,$inputarr);
}
/**
/**
* This function will intercept all the literals used in the SQL, prepending the "N" char to them
* in order to allow mssql to store properly data sent in the correct UCS-2 encoding (by freeTDS
* and ODBTP) keeping SQL compatibility at ADOdb level (instead of hacking every project to add

View File

@ -1,24 +1,26 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Native mssql driver. Requires mssql client. Works on Windows.
http://www.microsoft.com/sql/technologies/php/default.mspx
To configure for Unix, see
http://phpbuilder.com/columns/alberto20000919.php3
$stream = sqlsrv_get_field($stmt, $index, SQLSRV_SQLTYPE_STREAM(SQLSRV_ENC_BINARY));
stream_filter_append($stream, "convert.iconv.ucs-2/utf-8"); // Voila, UTF-8 can be read directly from $stream
*/
/**
* Native MSSQL driver.
*
* Requires mssql client. Works on Windows.
* https://docs.microsoft.com/sql/connect/php
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -49,6 +51,13 @@ class ADODB_mssqlnative extends ADOConnection {
var $replaceQuote = "''"; // string to use to replace quotes
var $fmtDate = "'Y-m-d'";
var $fmtTimeStamp = "'Y-m-d\TH:i:s'";
/**
* Enabling InsertID capability will cause execution of an extra query
* {@see $identitySQL} after each INSERT statement. To improve performance
* when inserting a large number of records, you should switch this off by
* calling {@see enableLastInsertID enableLastInsertID(false)}.
* @var bool $hasInsertID
*/
var $hasInsertID = true;
var $substr = "substring";
var $length = 'len';
@ -152,12 +161,23 @@ class ADODB_mssqlnative extends ADOConnection {
return " ISNULL($field, $ifNull) "; // if MS SQL Server
}
function _insertid()
public function enableLastInsertID($enable = true) {
$this->hasInsertID = $enable;
$this->lastInsID = false;
}
/**
* Get the last value inserted into an IDENTITY column.
*
* The value will actually be set in {@see _query()} when executing an
* INSERT statement, but only if the connection's $hasInsertId property
* is true; this can be set with {@see enableLastInsertId()}.
*
* @inheritDoc
*/
protected function _insertID($table = '', $column = '')
{
$rez = sqlsrv_query($this->_connectionID,$this->identitySQL);
sqlsrv_fetch($rez);
$this->lastInsertID = sqlsrv_get_field($rez, 0);
return $this->lastInsertID;
return $this->lastInsID;
}
function _affectedrows()
@ -278,22 +298,25 @@ class ADODB_mssqlnative extends ADOConnection {
// Format date column in sql string given an input format that understands Y M D
function SQLDate($fmt, $col=false)
{
if (!$col) $col = $this->sysTimeStamp;
if (!$col) {
$col = $this->sysTimeStamp;
}
$s = '';
$ConvertableFmt=array(
"m/d/Y"=>101,"m/d/y"=>101 // US
,"Y.m.d"=>102,"y/m/d"=>102 // ANSI
,"d/m/Y"=>103,"d/m/y"=>103 // French /english
,"d.m.Y"=>104,"d.m.y"=>104 // German
,"d-m-Y"=>105,"d-m-y"=>105 // Italian
,"m-d-Y"=>110,"m-d-y"=>110 // US Dash
,"Y/m/d"=>111,"y/m/d"=>111 // Japan
,"Ymd"=>112,"ymd"=>112 // ISO
,"H:i:s"=>108 // Time
"m/d/Y"=>101, "m/d/y"=>101 // US
,"Y.m.d"=>102, "y.m.d"=>102 // ANSI
,"d/m/Y"=>103, "d/m/y"=>103 // French /english
,"d.m.Y"=>104, "d.m.y"=>104 // German
,"d-m-Y"=>105, "d-m-y"=>105 // Italian
,"m-d-Y"=>110, "m-d-y"=>110 // US Dash
,"Y/m/d"=>111, "y/m/d"=>111 // Japan
,"Ymd"=>112, "ymd"=>112 // ISO
,"H:i:s"=>108 // Time
);
if(key_exists($fmt,$ConvertableFmt))
return "convert (varchar ,$col,".$ConvertableFmt[$fmt].")";
if (key_exists($fmt,$ConvertableFmt)) {
return "convert (varchar ,$col," . $ConvertableFmt[$fmt] . ")";
}
$len = strlen($fmt);
for ($i=0; $i < $len; $i++) {
@ -439,9 +462,9 @@ class ADODB_mssqlnative extends ADOConnection {
function ErrorNo()
{
$err = sqlsrv_errors(SQLSRV_ERR_ALL);
if ($err && $err[0])
if ($err && $err[0])
return $err[0]['code'];
else
else
return 0;
}
@ -454,13 +477,13 @@ class ADODB_mssqlnative extends ADOConnection {
ADOConnection::outp('Microsoft SQL Server native driver (mssqlnative) not installed');
return null;
}
if (!empty($this->port))
/*
* Port uses a comma
* Port uses a comma
*/
$argHostname .= ",".$this->port;
$connectionInfo = $this->connectionInfo;
$connectionInfo["Database"] = $argDatabasename;
if ((string)$argUsername != '' || (string)$argPassword != '')
@ -471,12 +494,12 @@ class ADODB_mssqlnative extends ADOConnection {
*/
$connectionInfo["UID"] = $argUsername;
$connectionInfo["PWD"] = $argPassword;
if ($this->debug)
ADOConnection::outp('userid or password supplied, attempting connection with SQL Server Authentication');
}
else
else
{
/*
* If they don't pass either value, we won't add them to the
@ -484,11 +507,11 @@ class ADODB_mssqlnative extends ADOConnection {
* to use windows authentication
*/
if ($this->debug)
ADOConnection::outp('No userid or password supplied, attempting connection with Windows Authentication');
}
/*
* Now merge in the passed connection parameters setting
*/
@ -501,7 +524,7 @@ class ADODB_mssqlnative extends ADOConnection {
if ($this->debug) ADOConnection::outp("connecting to host: $argHostname params: ".var_export($connectionInfo,true));
if(!($this->_connectionID = @sqlsrv_connect($argHostname,$connectionInfo)))
{
if ($this->debug)
if ($this->debug)
ADOConnection::outp( 'Connection Failed: '.print_r( sqlsrv_errors(), true));
return false;
}
@ -518,6 +541,7 @@ class ADODB_mssqlnative extends ADOConnection {
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
}
function Prepare($sql)
{
return $sql; // prepare does not work properly with bind parameters as bind parameters are managed by sqlsrv_prepare!
@ -575,38 +599,69 @@ class ADODB_mssqlnative extends ADOConnection {
return $this->Execute($sql) != false;
}
// returns query ID if successful, otherwise false
function _query($sql,$inputarr=false)
/**
* Execute a query.
*
* If executing an INSERT statement and $hasInsertId is true, will set
* $lastInsId.
*
* @param string $sql
* @param array $inputarr
* @return resource|false Query Id if successful, otherwise false
*/
function _query($sql, $inputarr = false)
{
$this->_errorMsg = false;
if (is_array($sql))
if (is_array($sql)) {
$sql = $sql[1];
$insert = false;
// handle native driver flaw for retrieving the last insert ID
if(preg_match('/^\W*insert[\s\w()[\]",.]+values\s*\((?:[^;\']|\'\'|(?:(?:\'\')*\'[^\']+\'(?:\'\')*))*;?$/i', $sql)) {
$insert = true;
$sql .= '; '.$this->identitySQL; // select scope_identity()
}
if($inputarr)
{
/*
* Ensure that the input array is numeric, as required by
* sqlsrv_query. If param() was used to create portable binds
* then the array might be associative
*/
// Handle native driver flaw for retrieving the last insert ID
if ($this->hasInsertID) {
// Check if it's an INSERT statement
$retrieveLastInsertID = preg_match(
'/^\W*insert[\s\w()[\]",.]+values\s*\((?:[^;\']|\'\'|(?:(?:\'\')*\'[^\']+\'(?:\'\')*))*;?$/i',
$sql
);
if ($retrieveLastInsertID) {
// Append the identity SQL, so it is executed in the same
// scope as the insert query.
$sql .= '; ' . $this->identitySQL;
}
} else {
$retrieveLastInsertID = false;
}
if ($inputarr) {
// Ensure that the input array is indexed numerically, as required
// by sqlsrv_query(). If param() was used to create portable binds
// then the array might be associative.
$inputarr = array_values($inputarr);
$rez = sqlsrv_query($this->_connectionID, $sql, $inputarr);
} else {
$rez = sqlsrv_query($this->_connectionID,$sql);
$rez = sqlsrv_query($this->_connectionID, $sql);
}
if ($this->debug) ADOConnection::outp("<hr>running query: ".var_export($sql,true)."<hr>input array: ".var_export($inputarr,true)."<hr>result: ".var_export($rez,true));
if ($this->debug) {
ADOConnection::outp("<hr>running query: " . var_export($sql, true)
. "<hr>input array: " . var_export($inputarr, true)
. "<hr>result: " . var_export($rez, true)
);
}
if(!$rez)
$this->lastInsID = false;
if (!$rez) {
$rez = false;
} elseif ($retrieveLastInsertID) {
// Get the inserted id from the last result
// Note: loop is required as server may return more than one row,
// e.g. if triggers are involved (see #41)
while (sqlsrv_next_result($rez)) {
sqlsrv_fetch($rez);
$this->lastInsID = sqlsrv_get_field($rez, 0, SQLSRV_PHPTYPE_INT);
}
}
return $rez;
}
@ -623,7 +678,7 @@ class ADODB_mssqlnative extends ADOConnection {
return $rez;
}
function MetaIndexes($table,$primary=false, $owner = false)
{
$table = $this->qstr($table);
@ -711,7 +766,7 @@ class ADODB_mssqlnative extends ADOConnection {
function MetaDatabases()
{
$this->SelectDB("master");
$rs =& $this->Execute($this->metaDatabasesSQL);
$rs = $this->Execute($this->metaDatabasesSQL);
$rows = $rs->GetRows();
$ret = array();
for($i=0;$i<count($rows);$i++) {
@ -899,51 +954,48 @@ class ADODB_mssqlnative extends ADOConnection {
* @param string $procedureNamePattern (optional)
* @param string $catalog (optional)
* @param string $schemaPattern (optional)
* @return array of stored objects in current database.
*
*/
public function metaProcedures($procedureNamePattern = null, $catalog = null, $schemaPattern = null)
{
$metaProcedures = array();
$procedureSQL = '';
$catalogSQL = '';
$schemaSQL = '';
if ($procedureNamePattern)
$procedureSQL = "AND ROUTINE_NAME LIKE " . strtoupper($this->qstr($procedureNamePattern));
if ($catalog)
$catalogSQL = "AND SPECIFIC_SCHEMA=" . strtoupper($this->qstr($catalog));
if ($schemaPattern)
$schemaSQL = "AND ROUTINE_SCHEMA LIKE {$this->qstr($schemaPattern)}";
$fields = " ROUTINE_NAME,ROUTINE_TYPE,ROUTINE_SCHEMA,ROUTINE_CATALOG";
$SQL = "SELECT $fields
FROM {$this->database}.information_schema.routines
WHERE 1=1
$procedureSQL
$catalogSQL
$schemaSQL
ORDER BY ROUTINE_NAME
";
FROM {$this->database}.information_schema.routines
WHERE 1=1
$procedureSQL
$catalogSQL
$schemaSQL
ORDER BY ROUTINE_NAME
";
$result = $this->execute($SQL);
if (!$result)
return false;
while ($r = $result->fetchRow()){
if (!isset($r[0]))
/*
* Convert to numeric
*/
$r = array_values($r);
$procedureName = $r[0];
$schemaName = $r[2];
$routineCatalog= $r[3];
@ -952,13 +1004,11 @@ class ADODB_mssqlnative extends ADOConnection {
'schema' => $schemaName,
'remarks' => '',
);
}
return $metaProcedures;
}
}
/*--------------------------------------------------------------------------------------
@ -972,13 +1022,8 @@ class ADORecordset_mssqlnative extends ADORecordSet {
var $fieldOffset = 0;
// _mths works only in non-localised system
/*
* Holds a cached version of the metadata
*/
private $fieldObjects = false;
/*
* Flags if we have retrieved the metadata
/**
* @var bool True if we have retrieved the fields metadata
*/
private $fieldObjectsRetrieved = false;
@ -987,7 +1032,6 @@ class ADORecordset_mssqlnative extends ADORecordSet {
*/
private $fieldObjectsIndex = array();
/*
* Cross references the dateTime objects for faster decoding
*/
@ -1075,9 +1119,9 @@ class ADORecordset_mssqlnative extends ADORecordSet {
* Too early
*/
return;
if ($this->fetchMode != ADODB_FETCH_NUM)
if ($this->fetchMode != ADODB_FETCH_NUM)
return $this->fields[$colname];
if (!$this->bind) {
$this->bind = array();
for ($i=0; $i < $this->_numOfFields; $i++) {
@ -1098,26 +1142,23 @@ class ADORecordset_mssqlnative extends ADORecordSet {
* the next field that wasn't yet retrieved by fetchField()
* is retrieved.
*
* $param int $fieldOffset (optional default=-1 for all
* @param int $fieldOffset (optional default=-1 for all
* @return mixed an ADOFieldObject, or array of objects
*/
private function _fetchField($fieldOffset = -1)
{
if ($this->fieldObjectsRetrieved){
if ($this->fieldObjects) {
/*
* Already got the information
*/
if ($fieldOffset == -1)
return $this->fieldObjects;
else
return $this->fieldObjects[$fieldOffset];
}
else
/*
* No metadata available
*/
if ($this->fieldObjectsRetrieved) {
if ($this->fieldObjectsCache) {
// Already got the information
if ($fieldOffset == -1) {
return $this->fieldObjectsCache;
} else {
return $this->fieldObjectsCache[$fieldOffset];
}
} else {
// No metadata available
return false;
}
}
$this->fieldObjectsRetrieved = true;
@ -1127,36 +1168,28 @@ class ADORecordset_mssqlnative extends ADORecordSet {
*/
$fieldMetaData = sqlsrv_field_metadata($this->_queryID);
if (!$fieldMetaData)
/*
* Not a statement that gives us metaData
*/
if (!$fieldMetaData) {
// Not a statement that gives us metaData
return false;
}
$this->_numOfFields = count($fieldMetaData);
foreach ($fieldMetaData as $key=>$value)
{
foreach ($fieldMetaData as $key=>$value) {
$fld = new ADOFieldObject;
/*
* Caution - keys are case-sensitive, must respect
* casing of values
*/
// Caution - keys are case-sensitive, must respect casing of values
$fld->name = $value['Name'];
$fld->max_length = $value['Size'];
$fld->column_source = $value['Name'];
$fld->type = $this->_typeConversion[$value['Type']];
$this->fieldObjects[$key] = $fld;
$this->fieldObjectsCache[$key] = $fld;
$this->fieldObjectsIndex[$fld->name] = $key;
}
if ($fieldOffset == -1)
return $this->fieldObjects;
if ($fieldOffset == -1) {
return $this->fieldObjectsCache;
}
return $this->fieldObjects[$fieldOffset];
return $this->fieldObjectsCache[$fieldOffset];
}
/*
@ -1173,7 +1206,7 @@ class ADORecordset_mssqlnative extends ADORecordSet {
*/
function fetchField($fieldOffset = -1)
{
return $this->fieldObjects[$fieldOffset];
return $this->fieldObjectsCache[$fieldOffset];
}
function _seek($row)
@ -1243,7 +1276,7 @@ class ADORecordset_mssqlnative extends ADORecordSet {
$this->_queryID = false;
return $rez;
}
return true;
}

View File

@ -1,29 +1,27 @@
<?php
/**
* @version v5.21.0 2021-02-27
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
*
* Set tabs to 4 for best viewing.
*
* Latest version is available at https://adodb.org/
*
* Portable MSSQL Driver that supports || instead of +
*
*/
* Portable MSSQL Driver that supports || instead of +.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
/*
The big difference between mssqlpo and it's parent mssql is that mssqlpo supports
the more standard || string concatenation operator.
*/
include_once(ADODB_DIR.'/drivers/adodb-mssql.inc.php');
class ADODB_mssqlpo extends ADODB_mssql {

View File

@ -1,22 +1,30 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 8.
This driver only supports the original non-transactional MySQL driver. It
is deprecated in PHP version 5.5 and removed in PHP version 7. It is deprecated
as of ADOdb version 5.20.0. Use the mysqli driver instead, which supports both
transactional and non-transactional updates
Requires mysql client. Works on Windows and Unix.
28 Feb 2001: MetaColumns bug fix - suggested by Freek Dijkstra (phpeverywhere@macfreek.com)
*/
/**
* MySQL driver
*
* @deprecated
*
* This driver only supports the original non-transactional MySQL driver,
* which was deprecated in PHP version 5.5 and removed in PHP version 7.
* It is deprecated as of ADOdb version 5.20.0, use the mysqli driver
* instead, which supports both transactional and non-transactional updates.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -76,17 +84,16 @@ class ADODB_mysql extends ADOConnection {
}
}
// SetCharSet - switch the client encoding
function setCharSet($charset_name)
function setCharSet($charset)
{
if (!function_exists('mysql_set_charset')) {
return false;
}
if ($this->charSet !== $charset_name) {
$ok = @mysql_set_charset($charset_name,$this->_connectionID);
if ($this->charSet !== $charset) {
$ok = @mysql_set_charset($charset,$this->_connectionID);
if ($ok) {
$this->charSet = $charset_name;
$this->charSet = $charset;
return true;
}
return false;
@ -273,7 +280,7 @@ class ADODB_mysql extends ADOConnection {
return "'" . str_replace("'", $this->replaceQuote, $s) . "'";
}
function _insertid()
protected function _insertID($table = '', $column = '')
{
return ADOConnection::GetOne('SELECT LAST_INSERT_ID()');
//return mysql_insert_id($this->_connectionID);
@ -481,23 +488,23 @@ class ADODB_mysql extends ADOConnection {
// returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (!empty($this->port))
if (!empty($this->port))
$argHostname .= ":".$this->port;
$this->_connectionID =
$this->_connectionID =
mysql_connect($argHostname,
$argUsername,
$argPassword,
$this->forceNewConnect,
$this->clientFlags
);
if ($this->_connectionID === false)
if ($this->_connectionID === false)
return false;
if ($argDatabasename)
if ($argDatabasename)
return $this->SelectDB($argDatabasename);
return true;
}
@ -506,17 +513,17 @@ class ADODB_mysql extends ADOConnection {
{
if (!empty($this->port)) $argHostname .= ":".$this->port;
$this->_connectionID =
$this->_connectionID =
mysql_pconnect($argHostname,
$argUsername,
$argPassword,
$this->clientFlags);
if ($this->_connectionID === false)
if ($this->_connectionID === false)
return false;
if ($this->autoRollback)
if ($this->autoRollback)
$this->RollbackTrans();
if ($argDatabasename)
if ($argDatabasename)
return $this->SelectDB($argDatabasename);
return true;
}

View File

@ -1,23 +1,28 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 8.
This is the preferred driver for MySQL connections, and supports both transactional
and non-transactional table types. You can use this as a drop-in replacement for both
the mysql and mysqlt drivers. As of ADOdb Version 5.20.0, all other native MySQL drivers
are deprecated
Requires mysql client. Works on Windows and Unix.
21 October 2003: MySQLi extension implementation by Arjen de Rijke (a.de.rijke@xs4all.nl)
Based on adodb 3.40
*/
/**
* MySQL improved driver (mysqli)
*
* This is the preferred driver for MySQL connections. It supports both
* transactional and non-transactional table types. You can use this as a
* drop-in replacement for both the mysql and mysqlt drivers.
* As of ADOdb Version 5.20.0, all other native MySQL drivers are deprecated.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) {
@ -77,6 +82,24 @@ class ADODB_mysqli extends ADOConnection {
private $usePreparedStatement = false;
private $useLastInsertStatement = false;
/**
* @var bool True if the last executed statement is a SELECT {@see _query()}
*/
private $isSelectStatement = false;
/**
* ADODB_mysqli constructor.
*/
public function __construct()
{
parent::__construct();
// Forcing error reporting mode to OFF, which is no longer the default
// starting with PHP 8.1 (see #755)
mysqli_report(MYSQLI_REPORT_OFF);
}
/**
* Sets the isolation level of a transaction.
*
@ -97,6 +120,27 @@ class ADODB_mysqli extends ADOConnection {
$this->execute("SET SESSION TRANSACTION ".$transaction_mode);
}
/**
* Adds a parameter to the connection string.
*
* Parameter must be one of the the constants listed in mysqli_options().
* @see https://www.php.net/manual/en/mysqli.options.php
*
* @param int $parameter The parameter to set
* @param string $value The value of the parameter
*
* @example, for mssqlnative driver ('CharacterSet','UTF-8')
* @return bool
*/
public function setConnectionParameter($parameter, $value) {
if(!is_numeric($parameter)) {
$this->outp_throw("Invalid connection parameter '$parameter'", __METHOD__);
return false;
}
$this->connectionParameters[$parameter] = $value;
return true;
}
/**
* Connect to a database.
*
@ -139,13 +183,15 @@ class ADODB_mysqli extends ADOConnection {
mysqli_options($this->_connectionID,$arr[0],$arr[1]);
}
/*
* Now merge in the standard connection parameters setting
*/
foreach ($this->connectionParameters as $options)
{
foreach($options as $k=>$v)
$ok = mysqli_options($this->_connectionID,$k,$v);
// Now merge in the standard connection parameters setting
foreach ($this->connectionParameters as $parameter => $value) {
// Make sure parameter is numeric before calling mysqli_options()
// that to avoid Warning (or TypeError exception on PHP 8).
if (!is_numeric($parameter)
|| !mysqli_options($this->_connectionID, $parameter, $value)
) {
$this->outp_throw("Invalid connection parameter '$parameter'", __METHOD__);
}
}
//https://php.net/manual/en/mysqli.persistconns.php
@ -377,9 +423,9 @@ class ADODB_mysqli extends ADOConnection {
/**
* Return the AUTO_INCREMENT id of the last row that has been inserted or updated in a table.
*
* @return int|string
* @inheritDoc
*/
function _insertid()
protected function _insertID($table = '', $column = '')
{
// mysqli_insert_id does not return the last_insert_id if called after
// execution of a stored procedure so we execute this instead.
@ -406,6 +452,12 @@ class ADODB_mysqli extends ADOConnection {
*/
function _affectedrows()
{
if ($this->isSelectStatement) {
// Affected rows works fine against selects, returning
// the rowcount, but ADOdb does not do that.
return false;
}
$result = @mysqli_affected_rows($this->_connectionID);
if ($result == -1) {
if ($this->debug) ADOConnection::outp("mysqli_affected_rows() failed : " . $this->errorMsg());
@ -864,15 +916,15 @@ class ADODB_mysqli extends ADOConnection {
* Return assoc array where key is column name, value is column type
* [1] => int unsigned
*/
$SQL = "SELECT column_name, column_type
FROM information_schema.columns
WHERE table_schema='{$this->databaseName}'
$SQL = "SELECT column_name, column_type
FROM information_schema.columns
WHERE table_schema='{$this->databaseName}'
AND table_name='$table'";
$schemaArray = $this->getAssoc($SQL);
$schemaArray = array_change_key_case($schemaArray,CASE_LOWER);
$rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
@ -884,7 +936,7 @@ class ADODB_mysqli extends ADOConnection {
$fld = new ADOFieldObject();
$fld->name = $rs->fields[0];
$type = $rs->fields[1];
/*
* Type from information_schema returns
* the same format in V8 mysql as V5
@ -910,7 +962,7 @@ class ADODB_mysqli extends ADOConnection {
$fld->type = $type;
$fld->max_length = -1;
}
$fld->not_null = ($rs->fields[2] != 'YES');
$fld->primary_key = ($rs->fields[3] == 'PRI');
$fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
@ -1096,8 +1148,10 @@ class ADODB_mysqli extends ADOConnection {
}
} else {
$rs = mysqli_query($this->_connectionID, $sql, $ADODB_COUNTRECS ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT);
if ($rs) return $rs;
if ($rs) {
$this->isSelectStatement = is_object($rs);
return $rs;
}
}
if($this->debug)
@ -1173,46 +1227,29 @@ class ADODB_mysqli extends ADOConnection {
return 4294967295;
}
/**
* Get the name of the character set the client connection is using now.
*
* @return string|bool The name of the character set, or false if it can't be determined.
*/
function GetCharSet()
function getCharSet()
{
//we will use ADO's builtin property charSet
if (!method_exists($this->_connectionID,'character_set_name'))
if (!$this->_connectionID || !method_exists($this->_connectionID,'character_set_name')) {
return false;
$this->charSet = @$this->_connectionID->character_set_name();
if (!$this->charSet) {
return false;
} else {
return $this->charSet;
}
$this->charSet = $this->_connectionID->character_set_name();
return $this->charSet ?: false;
}
/**
* Sets the character set for database connections (limited databases).
*
* @link https://adodb.org/dokuwiki/doku.php?id=v5:reference:connection:setcharset
*
* @param string $charset_name The character set to switch to.
*
* @return bool True if the character set was changed successfully, otherwise false.
*/
function SetCharSet($charset_name)
function setCharSet($charset)
{
if (!method_exists($this->_connectionID,'set_charset')) {
if (!$this->_connectionID || !method_exists($this->_connectionID,'set_charset')) {
return false;
}
if ($this->charSet !== $charset_name) {
$if = @$this->_connectionID->set_charset($charset_name);
return ($if === true & $this->getCharSet() == $charset_name);
} else {
return true;
if ($this->charSet !== $charset) {
if (!$this->_connectionID->set_charset($charset)) {
return false;
}
$this->getCharSet();
}
return true;
}
}

View File

@ -1,24 +1,30 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 8.
MySQL code that supports transactions. For MySQL 3.23 or later.
Code from James Poon <jpoon88@yahoo.com>
This driver extends the deprecated mysql driver, and was originally designed to be a
portable driver in the same manner as oci8po and mssqlpo. Its functionality
is exactly duplicated in the mysqlt driver, which is itself deprecated.
This driver will be removed in ADOdb version 6.0.0.
Requires mysql client. Works on Windows and Unix.
*/
/**
* Portable MySQL driver
*
* @deprecated
*
* Extends the deprecated mysql driver, and was originally designed to be a
* portable driver in the same manner as oci8po and mssqlpo. Its functionality
* is exactly duplicated in the mysqlt driver, which is itself deprecated.
* This driver will be removed in ADOdb version 6.0.0.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,21 +1,30 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 8.
This driver only supports the original MySQL driver in transactional mode. It
is deprecated in PHP version 5.5 and removed in PHP version 7. It is deprecated
as of ADOdb version 5.20.0. Use the mysqli driver instead, which supports both
transactional and non-transactional updates
Requires mysql client. Works on Windows and Unix.
*/
/**
* MySQL driver in transactional mode
*
* @deprecated
*
* This driver only supports the original MySQL driver in transactional mode. It
* is deprecated in PHP version 5.5 and removed in PHP version 7. It is deprecated
* as of ADOdb version 5.20.0. Use the mysqli driver instead, which supports both
* transactional and non-transactional updates
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,21 +1,35 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
/**
* Netezza Driver
*
* @link https://www.ibm.com/products/netezza
* Based on the previous postgres drivers. Major Additions/Changes:
* - MetaDatabasesSQL, MetaTablesSQL, MetaColumnsSQL
* Note: You have to have admin privileges to access the system tables
* - Removed non-working keys code (Netezza has no concept of keys)
* - Fixed the way data types and lengths are returned in MetaColumns()
* as well as added the default lengths for certain types
* - Updated public variables for Netezza
* TODO: Still need to remove blob functions, as Netezza doesn't support blob
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
* @author Josh Eldridge <joshuae74@hotmail.com>
*/
First cut at the Netezza Driver by Josh Eldridge joshuae74#hotmail.com
Based on the previous postgres drivers.
http://www.netezza.com/
Major Additions/Changes:
MetaDatabasesSQL, MetaTablesSQL, MetaColumnsSQL
Note: You have to have admin privileges to access the system tables
Removed non-working keys code (Netezza has no concept of keys)
Fixed the way data types and lengths are returned in MetaColumns()
as well as added the default lengths for certain types
Updated public variables for Netezza
Still need to remove blob functions, as Netezza doesn't support blob
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,20 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim. All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Latest version is available at https://adodb.org/
Code contributed by George Fourlanos <fou@infomap.gr>
13 Nov 2000 jlim - removed all ora_* references.
*/
/**
* FileDescription
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
* @author John Lim
* @author George Fourlanos <fou@infomap.gr>
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -106,12 +111,12 @@ END;
* Legacy compatibility for sequence names for emulated auto-increments
*/
public $useCompactAutoIncrements = false;
/*
* Defines the schema name for emulated auto-increment columns
*/
public $schema = false;
/*
* Defines the prefix for emulated auto-increment columns
*/
@ -313,33 +318,32 @@ END;
{
return " NVL($field, $ifNull) "; // if Oracle
}
function _insertid($tabname,$column='')
protected function _insertID($table = '', $column = '')
{
if (!$this->seqField)
if (!$this->seqField)
return false;
if ($this->schema)
if ($this->schema)
{
$t = strpos($tabname,'.');
if ($t !== false)
$tab = substr($tabname,$t+1);
else
$tab = $tabname;
$t = strpos($table,'.');
if ($t !== false)
$tab = substr($table,$t+1);
else
$tab = $table;
if ($this->useCompactAutoIncrements)
$tab = sprintf('%u',crc32(strtolower($tab)));
$seqname = $this->schema.'.'.$this->seqPrefix.$tab;
}
else
}
else
{
if ($this->useCompactAutoIncrements)
$tabname = sprintf('%u',crc32(strtolower($tabname)));
$seqname = $this->seqPrefix.$tabname;
$table = sprintf('%u',crc32(strtolower($table)));
$seqname = $this->seqPrefix.$table;
}
if (strlen($seqname) > 30)
@ -347,7 +351,7 @@ END;
* We cannot successfully identify the sequence
*/
return false;
return $this->getOne("SELECT $seqname.currval FROM dual");
}
@ -1598,7 +1602,7 @@ class ADORecordset_oci8 extends ADORecordSet {
$this->adodbFetchMode = $mode;
$this->_queryID = $queryID;
}
/**
* Overrides the core destructor method as that causes problems here
*

View File

@ -1,18 +1,27 @@
<?php
/**
* @version v5.21.0 2021-02-27
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
* Oracle 8.0.5 (oci8) driver
*
* Set tabs to 4 for best viewing.
* @deprecated
*
* Latest version is available at https://adodb.org/
* Optimizes selectLimit() performance with FIRST_ROWS hint.
*
* Oracle 8.0.5 driver
*/
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,23 +1,28 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim. All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Latest version is available at https://adodb.org/
Portable version of oci8 driver, to make it more similar to other database drivers.
The main differences are
1. that the OCI_ASSOC names are in lowercase instead of uppercase.
2. bind variables are mapped using ? instead of :<bindvar>
Should some emulation of RecordCount() be implemented?
*/
/**
* Portable version of Oracle oci8 driver
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* Portable version of oci8 driver, to make it more similar to other database
* drivers. The main differences are
* 1. that the OCI_ASSOC names are in lowercase instead of uppercase.
* 2. bind variables are mapped using ? instead of :<bindvar>
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,23 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim. All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Latest version is available at https://adodb.org/
Portable version of oci8 driver, to make it more similar to other database drivers.
The main differences are
1. that the OCI_ASSOC names are in lowercase instead of uppercase.
2. bind variables are mapped using ? instead of :<bindvar>
Should some emulation of RecordCount() be implemented?
*/
/**
* Oracle "quercus" driver.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,17 +1,24 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
/**
* Base ODBC driver
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
Latest version is available at https://adodb.org/
Requires ODBC. Works on Windows and Unix.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,92 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
DB2 data driver. Requires ODBC.
From phpdb list:
Hi Andrew,
thanks a lot for your help. Today we discovered what
our real problem was:
After "playing" a little bit with the php-scripts that try
to connect to the IBM DB2, we set the optional parameter
Cursortype when calling odbc_pconnect(....).
And the exciting thing: When we set the cursor type
to SQL_CUR_USE_ODBC Cursor Type, then
the whole query speed up from 1 till 10 seconds
to 0.2 till 0.3 seconds for 100 records. Amazing!!!
Therefore, PHP is just almost fast as calling the DB2
from Servlets using JDBC (don't take too much care
about the speed at whole: the database was on a
completely other location, so the whole connection
was made over a slow network connection).
I hope this helps when other encounter the same
problem when trying to connect to DB2 from
PHP.
Kind regards,
Christian Szardenings
2 Oct 2001
Mark Newnham has discovered that the SQL_CUR_USE_ODBC is not supported by
IBM's DB2 ODBC driver, so this must be a 3rd party ODBC driver.
From the IBM CLI Reference:
SQL_ATTR_ODBC_CURSORS (DB2 CLI v5)
This connection attribute is defined by ODBC, but is not supported by DB2
CLI. Any attempt to set or get this attribute will result in an SQLSTATE of
HYC00 (Driver not capable).
A 32-bit option specifying how the Driver Manager uses the ODBC cursor
library.
So I guess this means the message [above] was related to using a 3rd party
odbc driver.
Setting SQL_CUR_USE_ODBC
========================
To set SQL_CUR_USE_ODBC for drivers that require it, do this:
$db = NewADOConnection('odbc_db2');
$db->curMode = SQL_CUR_USE_ODBC;
$db->Connect($dsn, $userid, $pwd);
USING CLI INTERFACE
===================
I have had reports that the $host and $database params have to be reversed in
Connect() when using the CLI interface. From Halmai Csongor csongor.halmai#nexum.hu:
> The symptom is that if I change the database engine from postgres or any other to DB2 then the following
> connection command becomes wrong despite being described this version to be correct in the docs.
>
> $connection_object->Connect( $DATABASE_HOST, $DATABASE_AUTH_USER_NAME, $DATABASE_AUTH_PASSWORD, $DATABASE_NAME )
>
> In case of DB2 I had to swap the first and last arguments in order to connect properly.
System Error 5
==============
IF you get a System Error 5 when trying to Connect/Load, it could be a permission problem. Give the user connecting
to DB2 full rights to the DB2 SQLLIB directory, and place the user in the DBUSERS group.
*/
/**
* DB2 driver via ODBC
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -131,7 +62,7 @@ class ADODB_ODBC_DB2 extends ADODB_odbc {
return array('description'=>'DB2 ODBC driver', 'version'=>$vers);
}
function _insertid()
protected function _insertID($table = '', $column = '')
{
return $this->GetOne($this->identitySQL);
}

View File

@ -1,18 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
MSSQL support via ODBC. Requires ODBC. Works on Windows and Unix.
For Unix configuration, see http://phpbuilder.com/columns/alberto20000919.php3
*/
/**
* MSSQL driver via ODBC
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -66,7 +71,7 @@ class ADODB_odbc_mssql extends ADODB_odbc {
return " ISNULL($field, $ifNull) "; // if MS SQL Server
}
function _insertid()
protected function _insertID($table = '', $column = '')
{
// SCOPE_IDENTITY()
// Returns the last IDENTITY value inserted into an IDENTITY column in
@ -345,7 +350,7 @@ order by constraint_name, referenced_table_name, keyno";
}
return $s;
}
/**
* Returns a substring of a varchar type field
*
@ -363,17 +368,17 @@ order by constraint_name, referenced_table_name, keyno";
if ($length == 0)
/*
* The length available to varchar is 2GB, but that makes no
* sense in a substring, so I'm going to arbitrarily limit
* sense in a substring, so I'm going to arbitrarily limit
* the length to 1K, but you could change it if you want
*/
$length = 1024;
$text = "SUBSTRING($fld,$start,$length)";
return $text;
}
/**
* Returns the maximum size of a MetaType C field. Because of the
* Returns the maximum size of a MetaType C field. Because of the
* database design, SQL Server places no limits on the size of data inserted
* Although the actual limit is 2^31-1 bytes.
*
@ -385,7 +390,7 @@ order by constraint_name, referenced_table_name, keyno";
}
/**
* Returns the maximum size of a MetaType X field. Because of the
* Returns the maximum size of a MetaType X field. Because of the
* database design, SQL Server places no limits on the size of data inserted
* Although the actual limit is 2^31-1 bytes.
*
@ -395,7 +400,7 @@ order by constraint_name, referenced_table_name, keyno";
{
return ADODB_STRINGMAX_NOLIMIT;
}
// returns concatenated string
// MSSQL requires integers to be cast as strings
// automatically cast every datatype to VARCHAR(255)

View File

@ -1,14 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2015 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4.
Microsoft SQL Server 2012 via ODBC
*/
/**
* Microsoft SQL Server 2012 driver via ODBC
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
if (!defined('ADODB_DIR'))
die();

View File

@ -1,17 +1,24 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
/**
* Oracle driver via ODBC
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
Latest version is available at https://adodb.org/
Oracle support via ODBC. Requires ODBC. Works on Windows.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,15 +1,26 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
*/
// Code contributed by "stefan bogdan" <sbogdan#rsb.ro>
/**
* ODBTP driver
*
* @deprecated will be removed in ADOdb version 6
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
* @author stefan bogdan <sbogdan@rsb.ro>
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -76,7 +87,7 @@ class ADODB_odbtp extends ADOConnection{
}
*/
function _insertid()
protected function _insertID($table = '', $column = '')
{
// SCOPE_IDENTITY()
// Returns the last IDENTITY value inserted into an IDENTITY column in

View File

@ -1,30 +1,36 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
*/
// Code contributed by "Robert Twitty" <rtwitty#neutron.ushmm.org>
/**
* ODBTP Unicode driver.
*
* @deprecated will be removed in ADOdb version 6
*
* Because the ODBTP server sends and reads UNICODE text data using UTF-8
* encoding, the following HTML meta tag must be included within the HTML
* head section of every HTML form and script page:
* <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
* Also, all SQL query strings must be submitted as UTF-8 encoded text.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
* @author Robert Twitty <rtwitty@neutron.ushmm.org>
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
/*
Because the ODBTP server sends and reads UNICODE text data using UTF-8
encoding, the following HTML meta tag must be included within the HTML
head section of every HTML form and script page:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Also, all SQL query strings must be submitted as UTF-8 encoded text.
*/
if (!defined('_ADODB_ODBTP_LAYER')) {
include_once(ADODB_DIR."/drivers/adodb-odbtp.inc.php");
}

View File

@ -1,18 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Latest version is available at https://adodb.org/
Oracle data driver. Requires Oracle client. Works on Windows and Unix and Oracle 7.
If you are using Oracle 8 or later, use the oci8 driver which is much better and more reliable.
*/
/**
* Oracle data driver
*
* @deprecated Use oci8 driver instead
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,23 +1,23 @@
<?php
/**
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Requires ODBC. Works on Windows and Unix.
Problems:
Where is float/decimal type in pdo_param_type
LOB handling for CLOB/BLOB differs significantly
*/
* ADOdb base PDO driver
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -85,7 +85,7 @@ class ADODB_pdo extends ADOConnection {
var $dsnType = '';
var $stmt = false;
var $_driver;
/*
* Describe parameters passed directly to the PDO driver
*
@ -159,8 +159,8 @@ class ADODB_pdo extends ADOConnection {
*/
if ($persist) {
$this->pdoParameters[\PDO::ATTR_PERSISTENT] = true;
}
}
try {
$this->_connectionID = new \PDO($argDSN, $argUsername, $argPassword, $this->pdoParameters);
} catch (Exception $e) {
@ -197,7 +197,7 @@ class ADODB_pdo extends ADOConnection {
$this->_connectionID->setAttribute($k,$v);
}
}
$class = 'ADODB_pdo_'.$this->dsnType;
//$this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,true);
switch($this->dsnType) {
@ -273,10 +273,10 @@ class ADODB_pdo extends ADOConnection {
return $this->_driver->MetaColumns($table,$normalize);
}
public function metaIndexes($table,$normalize=true)
public function metaIndexes($table,$normalize=true,$owner=false)
{
if (method_exists($this->_driver,'metaIndexes'))
return $this->_driver->metaIndexes($table,$normalize);
return $this->_driver->metaIndexes($table,$normalize,$owner);
}
/**
@ -559,12 +559,16 @@ class ADODB_pdo extends ADOConnection {
} else {
$stmt = $this->_connectionID->prepare($sql);
}
if ($stmt) {
if ($this->_driver instanceof ADODB_pdo) {
$this->_driver->debug = $this->debug;
}
if ($inputarr) {
/*
* inputarr must be numeric
*/
$inputarr = array_values($inputarr);
$ok = $stmt->execute($inputarr);
}
else {
@ -605,13 +609,10 @@ class ADODB_pdo extends ADOConnection {
function _affectedrows()
{
if(method_exists($this->_driver, '_affectedrows'))
return $this->_driver->_affectedrows();
return ($this->_stmt) ? $this->_stmt->rowCount() : 0;
}
function _insertid()
protected function _insertID($table = '', $column = '')
{
return ($this->_connectionID) ? $this->_connectionID->lastInsertId() : 0;
}
@ -829,22 +830,22 @@ class ADORecordSet_pdo extends ADORecordSet {
}
//adodb_pr($arr);
$o->name = $arr['name'];
if (isset($arr['sqlsrv:decl_type']) && $arr['sqlsrv:decl_type'] <> "null")
if (isset($arr['sqlsrv:decl_type']) && $arr['sqlsrv:decl_type'] <> "null")
{
/*
* If the database is SQL server, use the native built-ins
*/
$o->type = $arr['sqlsrv:decl_type'];
}
elseif (isset($arr['native_type']) && $arr['native_type'] <> "null")
elseif (isset($arr['native_type']) && $arr['native_type'] <> "null")
{
$o->type = $arr['native_type'];
}
else
else
{
$o->type = adodb_pdo_type($arr['pdo_type']);
}
$o->max_length = $arr['len'];
$o->precision = $arr['precision'];

View File

@ -2,13 +2,21 @@
/**
* ADOdb PDO dblib driver.
*
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses, the BSD license
* will take precedence.
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @version v5.21.0 2021-02-27
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2019 Damien Regad, Mark Newnham and the ADOdb community
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2019 Damien Regad, Mark Newnham and the ADOdb community
*/
class ADODB_pdo_dblib extends ADODB_pdo

View File

@ -1,19 +1,24 @@
<?php
/**
* ADOdb PDO Firebird driver
*
* @version v5.21.0 2021-02-27
* @copyright (c) 2019 Damien Regad, Mark Newnham and the ADOdb community
*
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence. See License.txt.
*
* Set tabs to 4 for best viewing.
*
* Latest version is available at https://adodb.org/
* PDO Firebird driver
*
* This version has only been tested on Firebird 3.0 and PHP 7
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2019 Damien Regad, Mark Newnham and the ADOdb community
*/
/**

View File

@ -1,16 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 8.
*/
/**
* PDO MSSQL driver
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
class ADODB_pdo_mssql extends ADODB_pdo {

View File

@ -1,14 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 8.
*/
/**
* PDO MySQL driver
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
class ADODB_pdo_mysql extends ADODB_pdo {
@ -48,6 +57,67 @@ class ADODB_pdo_mysql extends ADODB_pdo {
return $date . ' + INTERVAL ' . $fraction . ' SECOND';
// return "from_unixtime(unix_timestamp($date)+$fraction)";
}
/**
* Get a list of indexes on the specified table.
*
* @param string $table The name of the table to get indexes for.
* @param bool $primary (Optional) Whether or not to include the primary key.
* @param bool $owner (Optional) Unused.
*
* @return array|bool An array of the indexes, or false if the query to get the indexes failed.
*/
function metaIndexes($table, $primary = false, $owner = false)
{
// save old fetch mode
global $ADODB_FETCH_MODE;
$false = false;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== FALSE) {
$savem = $this->setFetchMode(FALSE);
}
// get index details
$rs = $this->execute(sprintf('SHOW INDEXES FROM %s',$table));
// restore fetchmode
if (isset($savem)) {
$this->setFetchMode($savem);
}
$ADODB_FETCH_MODE = $save;
if (!is_object($rs)) {
return $false;
}
$indexes = array ();
// parse index data into array
while ($row = $rs->fetchRow()) {
if ($primary == FALSE AND $row[2] == 'PRIMARY') {
continue;
}
if (!isset($indexes[$row[2]])) {
$indexes[$row[2]] = array(
'unique' => ($row[1] == 0),
'columns' => array()
);
}
$indexes[$row[2]]['columns'][$row[3] - 1] = $row[4];
}
// sort columns by order in the index
foreach ( array_keys ($indexes) as $index )
{
ksort ($indexes[$index]['columns']);
}
return $indexes;
}
function Concat()
{

View File

@ -1,16 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 8.
*/
/**
* PDO Oracle (oci) driver
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
class ADODB_pdo_oci extends ADODB_pdo_base {

View File

@ -1,15 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 8.
*/
/**
* PDO PostgreSQL (pgsql) driver
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
class ADODB_pdo_pgsql extends ADODB_pdo {
var $metaDatabasesSQL = "select datname from pg_database where datname not in ('template0','template1') order by 1";

View File

@ -1,19 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Thanks Diogo Toscano (diogo#scriptcase.net) for the code.
And also Sid Dunayer [sdunayer#interserv.com] for extensive fixes.
*/
/**
* PDO SQLite driver
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
* @author Diogo Toscano <diogo@scriptcase.net>
* @author Sid Dunayer <sdunayer@interserv.com>
*/
class ADODB_pdo_sqlite extends ADODB_pdo {
var $metaTablesSQL = "SELECT name FROM sqlite_master WHERE type='table'";

View File

@ -1,8 +1,25 @@
<?php
/**
* Provided by Ned Andre to support sqlsrv library
* PDO sqlsrv driver
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
* @author Ned Andre
*/
class ADODB_pdo_sqlsrv extends ADODB_pdo
{
var $hasTop = 'top';

View File

@ -1,15 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4.
NOTE: Since 3.31, this file is no longer used, and the "postgres" driver is
remapped to lastest available postgres version. Maintaining multiple
postgres drivers is no easy job, so hopefully this will ensure greater
consistency and fewer bugs.
*/
/**
* ADOdb PostgreSQL driver
*
* NOTE: Since ADOdb 3.31, this file is no longer used, and the "postgres"
* driver is remapped to the latest available postgres version. Maintaining
* multiple postgres drivers is no easy job, so hopefully this will ensure
* greater consistency and fewer bugs.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/

View File

@ -1,61 +1,27 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 8.
Original version derived from Alberto Cerezal (acerezalp@dbnet.es) - DBNet Informatica & Comunicaciones.
08 Nov 2000 jlim - Minor corrections, removing mysql stuff
09 Nov 2000 jlim - added insertid support suggested by "Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
jlim - changed concat operator to || and data types to MetaType to match documented pgsql types
see http://www.postgresql.org/devel-corner/docs/postgres/datatype.htm
22 Nov 2000 jlim - added changes to FetchField() and MetaTables() contributed by "raser" <raser@mail.zen.com.tw>
27 Nov 2000 jlim - added changes to _connect/_pconnect from ideas by "Lennie" <leen@wirehub.nl>
15 Dec 2000 jlim - added changes suggested by Additional code changes by "Eric G. Werk" egw@netguide.dk.
31 Jan 2002 jlim - finally installed postgresql. testing
01 Mar 2001 jlim - Freek Dijkstra changes, also support for text type
See http://www.varlena.com/varlena/GeneralBits/47.php
-- What indexes are on my table?
select * from pg_indexes where tablename = 'tablename';
-- What triggers are on my table?
select c.relname as "Table", t.tgname as "Trigger Name",
t.tgconstrname as "Constraint Name", t.tgenabled as "Enabled",
t.tgisconstraint as "Is Constraint", cc.relname as "Referenced Table",
p.proname as "Function Name"
from pg_trigger t, pg_class c, pg_class cc, pg_proc p
where t.tgfoid = p.oid and t.tgrelid = c.oid
and t.tgconstrrelid = cc.oid
and c.relname = 'tablename';
-- What constraints are on my table?
select r.relname as "Table", c.conname as "Constraint Name",
contype as "Constraint Type", conkey as "Key Columns",
confkey as "Foreign Columns", consrc as "Source"
from pg_class r, pg_constraint c
where r.oid = c.conrelid
and relname = 'tablename';
*/
/**
* ADOdb PostgreSQL 6.4 driver
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
function adodb_addslashes($s)
{
$len = strlen($s);
if ($len == 0) return "''";
if (strncmp($s,"'",1) === 0 && substr($s,$len-1) == "'") return $s; // already quoted
return "'".addslashes($s)."'";
}
class ADODB_postgres64 extends ADOConnection{
var $databaseType = 'postgres64';
var $dataProvider = 'postgres';
@ -183,8 +149,10 @@ class ADODB_postgres64 extends ADOConnection{
* Using a OID as a unique identifier is not generally wise.
* Unless you are very careful, you might end up with a tuple having
* a different OID if a database must be reloaded.
*
* @inheritDoc
*/
function _insertid($table,$column)
protected function _insertID($table = '', $column = '')
{
if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false;
$oid = pg_last_oid($this->_resultid);
@ -705,35 +673,57 @@ class ADODB_postgres64 extends ADOConnection{
return $indexes;
}
// returns true or false
//
// examples:
// $db->Connect("host=host1 user=user1 password=secret port=4341");
// $db->Connect('host1','user1','secret');
function _connect($str,$user='',$pwd='',$db='',$ctype=0)
/**
* Connect to a database.
*
* Examples:
* $db->Connect("host=host1 user=user1 password=secret port=4341");
* $db->Connect('host1:4341', 'user1', 'secret');
*
* @param string $str pg_connect() Connection string or Hostname[:port]
* @param string $user (Optional) The username to connect as.
* @param string $pwd (Optional) The password to connect with.
* @param string $db (Optional) The name of the database to start in when connected.
* @param int $ctype Connection type
* @return bool|null True if connected successfully, false if connection failed, or
* null if the PostgreSQL extension is not loaded.
*/
function _connect($str, $user='', $pwd='', $db='', $ctype=0)
{
if (!function_exists('pg_connect')) return null;
if (!function_exists('pg_connect')) {
return null;
}
$this->_errorMsg = false;
// If $user, $pwd and $db are all null, then $str is a pg_connect()
// connection string. Otherwise we expect it to be a hostname,
// with optional port separated by ':'
if ($user || $pwd || $db) {
$user = adodb_addslashes($user);
$pwd = adodb_addslashes($pwd);
if (strlen($db) == 0) $db = 'template1';
$db = adodb_addslashes($db);
if ($str) {
$host = explode(":", $str);
if ($host[0]) $str = "host=".adodb_addslashes($host[0]);
else $str = '';
if (isset($host[1])) $str .= " port=$host[1]";
else if (!empty($this->port)) $str .= " port=".$this->port;
// Hostname & port
if ($str) {
$host = explode(':', $str);
if ($host[0]) {
$conn['host'] = $host[0];
}
if (isset($host[1])) {
$conn['port'] = (int)$host[1];
} elseif (!empty($this->port)) {
$conn['port'] = $this->port;
}
}
if ($user) $str .= " user=".$user;
if ($pwd) $str .= " password=".$pwd;
if ($db) $str .= " dbname=".$db;
}
$conn['user'] = $user;
$conn['password'] = $pwd;
// @TODO not sure why we default to 'template1', pg_connect() uses the username when dbname is empty
$conn['dbname'] = $db ?: 'template1';
//if ($user) $linea = "user=$user host=$linea password=$pwd dbname=$db port=5432";
// Generate connection string
$str = '';
foreach ($conn as $param => $value) {
// Escaping single quotes and backslashes per pg_connect() documentation
$str .= $param . "='" . addcslashes($value, "'\\") . "' ";
}
}
if ($ctype === 1) { // persistent
$this->_connectionID = pg_pconnect($str);
@ -761,11 +751,11 @@ class ADODB_postgres64 extends ADOConnection{
# PHP does not handle 'hex' properly ('x74657374' is returned as 't657374')
# https://bugs.php.net/bug.php?id=59831 states this is in fact not a bug,
# so we manually set bytea_output
if (!empty($this->connection->noBlobs) && version_compare($info['version'], '9.0', '>=')) {
$version = pg_version($this->connectionID);
if (version_compare($info['client'], '9.2', '<')) {
$this->Execute('set bytea_output=escape');
}
if (!empty($this->connection->noBlobs)
&& version_compare($info['version'], '9.0', '>=')
&& version_compare($info['client'], '9.2', '<')
) {
$this->Execute('set bytea_output=escape');
}
return true;
@ -876,7 +866,7 @@ class ADODB_postgres64 extends ADOConnection{
if ($this->_errorMsg !== false) {
return $this->_errorMsg;
}
if (!empty($this->_resultid)) {
$this->_errorMsg = @pg_result_error($this->_resultid);
if ($this->_errorMsg) {
@ -974,10 +964,9 @@ class ADORecordSet_postgres64 extends ADORecordSet{
return $row;
}
function _initrs()
function _initRS()
{
global $ADODB_COUNTRECS;
global $ADODB_COUNTRECS;
$qid = $this->_queryID;
$this->_numOfRows = ($ADODB_COUNTRECS)? @pg_num_rows($qid):-1;
$this->_numOfFields = @pg_num_fields($qid);
@ -992,10 +981,11 @@ class ADORecordSet_postgres64 extends ADORecordSet{
}
}
/* Use associative array to get fields array */
function Fields($colname)
function fields($colname)
{
if ($this->fetchMode != PGSQL_NUM) return @$this->fields[$colname];
if ($this->fetchMode != PGSQL_NUM) {
return @$this->fields[$colname];
}
if (!$this->bind) {
$this->bind = array();
@ -1007,14 +997,14 @@ class ADORecordSet_postgres64 extends ADORecordSet{
return $this->fields[$this->bind[strtoupper($colname)]];
}
function FetchField($off = 0)
function fetchField($fieldOffset = 0)
{
// offsets begin at 0
$o= new ADOFieldObject();
$o->name = @pg_field_name($this->_queryID,$off);
$o->type = @pg_field_type($this->_queryID,$off);
$o->max_length = @pg_field_size($this->_queryID,$off);
$o = new ADOFieldObject();
$o->name = @pg_field_name($this->_queryID, $fieldOffset);
$o->type = @pg_field_type($this->_queryID, $fieldOffset);
$o->max_length = @pg_field_size($this->_queryID, $fieldOffset);
return $o;
}

View File

@ -1,17 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4.
Postgres7 support.
28 Feb 2001: Currently indicate that we support LIMIT
01 Dec 2001: dannym added support for default values
*/
/**
* ADOdb PostgreSQL 7 driver
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -269,34 +275,47 @@ class ADODB_postgres7 extends ADODB_postgres64 {
return $rez;
}
// this is a set of functions for managing client encoding - very important if the encodings
// of your database and your output target (i.e. HTML) don't match
//for instance, you may have UNICODE database and server it on-site as WIN1251 etc.
// GetCharSet - get the name of the character set the client is using now
// the functions should work with Postgres 7.0 and above, the set of charsets supported
// depends on compile flags of postgres distribution - if no charsets were compiled into the server
// it will return 'SQL_ANSI' always
function GetCharSet()
/**
* Retrieve the client connection's current character set.
* If no charsets were compiled into the server, the function will always
* return 'SQL_ASCII'.
* @see https://www.php.net/manual/en/function.pg-client-encoding.php
*
* @return string|false The character set, or false if it can't be determined.
*/
function getCharSet()
{
//we will use ADO's builtin property charSet
$this->charSet = @pg_client_encoding($this->_connectionID);
if (!$this->charSet) {
if (!$this->_connectionID) {
return false;
} else {
return $this->charSet;
}
$this->charSet = pg_client_encoding($this->_connectionID);
return $this->charSet ?: false;
}
// SetCharSet - switch the client encoding
function SetCharSet($charset_name)
/**
* Sets the client-side character set (encoding).
*
* Allows managing client encoding - very important if the database and
* the output target (i.e. HTML) don't match; for instance, you may have a
* UNICODE database and server your pages as WIN1251, etc.
*
* Supported on PostgreSQL 7.0 and above. Available charsets depend on
* PostgreSQL version and the distribution's compile flags.
*
* @param string $charset The character set to switch to.
*
* @return bool True if the character set was changed successfully, false otherwise.
*/
function setCharSet($charset)
{
$this->GetCharSet();
if ($this->charSet !== $charset_name) {
$if = pg_set_client_encoding($this->_connectionID, $charset_name);
if ($if == "0" & $this->GetCharSet() == $charset_name) {
return true;
} else return false;
} else return true;
if ($this->charSet !== $charset) {
if (!$this->_connectionID || pg_set_client_encoding($this->_connectionID, $charset) != 0) {
return false;
}
$this->getCharSet();
}
return true;
}
}

View File

@ -1,15 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4.
Postgres8 support.
*/
/**
* ADOdb PostgreSQL 8 driver
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -23,8 +31,8 @@ class ADODB_postgres8 extends ADODB_postgres7
// From PostgreSQL 8.0 onwards, the adsrc column used in earlier versions to
// retrieve the default value is obsolete and should not be used (see #562).
var $metaDefaultsSQL = "SELECT d.adnum as num, pg_get_expr(d.adbin, d.adrelid) as def
FROM pg_attrdef d, pg_class c
WHERE d.adrelid=c.oid AND c.relname='%s'
FROM pg_attrdef d, pg_class c
WHERE d.adrelid=c.oid AND c.relname='%s'
ORDER BY d.adnum";
/**
@ -37,7 +45,7 @@ class ADODB_postgres8 extends ADODB_postgres7
* @return int last inserted ID for given table/column, or the most recently
* returned one if $table or $column are empty
*/
function _insertid($table, $column)
protected function _insertID($table = '', $column = '')
{
return empty($table) || empty($column)
? $this->GetOne("SELECT lastval()")

View File

@ -1,15 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4.
Postgres9 support.
*/
/**
* ADOdb PostgreSQL 9+ driver
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,15 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4.
Synonym for csv driver.
*/
/**
* ADOdb Proxy Server driver
*
* @deprecated
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,18 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
SAPDB data driver. Requires ODBC.
*/
/**
* SAPDB data driver
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -144,7 +149,7 @@ class ADODB_SAPDB extends ADODB_odbc {
}
// unlike it seems, this depends on the db-session and works in a multiuser environment
function _insertid($table,$column)
protected function _insertID($table = '', $column = '')
{
return empty($table) ? False : $this->GetOne("SELECT $table.CURRVAL FROM DUAL");
}

View File

@ -1,47 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
21.02.2002 - Wade Johnson wade@wadejohnson.de
Extended ODBC class for Sybase SQLAnywhere.
1) Added support to retrieve the last row insert ID on tables with
primary key column using autoincrement function.
2) Added blob support. Usage:
a) create blob variable on db server:
$dbconn->create_blobvar($blobVarName);
b) load blob var from file. $filename must be complete path
$dbcon->load_blobvar_from_file($blobVarName, $filename);
c) Use the $blobVarName in SQL insert or update statement in the values
clause:
$recordSet = $dbconn->Execute('INSERT INTO tabname (idcol, blobcol) '
.
'VALUES (\'test\', ' . $blobVarName . ')');
instead of loading blob from a file, you can also load from
an unformatted (raw) blob variable:
$dbcon->load_blobvar_from_var($blobVarName, $varName);
d) drop blob variable on db server to free up resources:
$dbconn->drop_blobvar($blobVarName);
Sybase_SQLAnywhere data driver. Requires ODBC.
*/
/**
* SAP SQL Anywhere driver (previously Sybase SQL Anywhere)
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -54,13 +30,15 @@ if (!defined('ADODB_SYBASE_SQLANYWHERE')){
define('ADODB_SYBASE_SQLANYWHERE',1);
class ADODB_sqlanywhere extends ADODB_odbc {
var $databaseType = "sqlanywhere";
var $hasInsertID = true;
class ADODB_sqlanywhere extends ADODB_odbc
{
var $databaseType = "sqlanywhere";
var $hasInsertID = true;
function _insertid() {
return $this->GetOne('select @@identity');
}
protected function _insertID($table = '', $column = '')
{
return $this->GetOne('select @@identity');
}
function create_blobvar($blobVarName) {
$this->Execute("create variable $blobVarName long binary");

View File

@ -1,21 +1,27 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Latest version is available at https://adodb.org/
SQLite info: http://www.hwaci.com/sw/sqlite/
Install Instructions:
====================
1. Place this in adodb/drivers
2. Rename the file, remove the .txt prefix.
*/
/**
* SQLite driver
*
* @link https://www.sqlite.org/
*
* @deprecated Use SQLite3 driver instead
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -132,7 +138,7 @@ class ADODB_sqlite extends ADOConnection {
$parentDriver->hasInsertID = true;
}
function _insertid()
protected function _insertID($table = '', $column = '')
{
return sqlite_last_insert_rowid($this->_connectionID);
}

View File

@ -1,21 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Latest version is available at https://adodb.org/
SQLite info: http://www.hwaci.com/sw/sqlite/
Install Instructions:
====================
1. Place this in adodb/drivers
2. Rename the file, remove the .txt prefix.
*/
/**
* SQLite3 driver
*
* @link https://www.sqlite.org/
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -253,7 +257,7 @@ class ADODB_sqlite3 extends ADOConnection {
$parentDriver->hasInsertID = true;
}
function _insertid()
protected function _insertID($table = '', $column = '')
{
return $this->_connectionID->lastInsertRowID();
}
@ -417,7 +421,7 @@ class ADODB_sqlite3 extends ADOConnection {
{
return $this->_connectionID->close();
}
function metaIndexes($table, $primary = FALSE, $owner = false)
{
$false = false;
@ -428,9 +432,9 @@ class ADODB_sqlite3 extends ADOConnection {
if ($this->fetchMode !== FALSE) {
$savem = $this->SetFetchMode(FALSE);
}
$pragmaData = array();
/*
* If we want the primary key, we must extract
* it from the table statement, and the pragma
@ -442,22 +446,22 @@ class ADODB_sqlite3 extends ADOConnection {
);
$pragmaData = $this->getAll($sql);
}
/*
* Exclude the empty entry for the primary index
*/
$sqlite = "SELECT name,sql
FROM sqlite_master
WHERE type='index'
FROM sqlite_master
WHERE type='index'
AND sql IS NOT NULL
AND LOWER(tbl_name)='%s'";
$SQL = sprintf($sqlite,
strtolower($table)
);
$rs = $this->execute($SQL);
if (!is_object($rs)) {
if (isset($savem)) {
$this->SetFetchMode($savem);
@ -467,10 +471,10 @@ class ADODB_sqlite3 extends ADOConnection {
}
$indexes = array ();
while ($row = $rs->FetchRow())
while ($row = $rs->FetchRow())
{
if (!isset($indexes[$row[0]])) {
$indexes[$row[0]] = array(
'unique' => preg_match("/unique/i",$row[1]),
@ -485,26 +489,26 @@ class ADODB_sqlite3 extends ADOConnection {
preg_match_all('/\((.*)\)/',$row[1],$indexExpression);
$indexes[$row[0]]['columns'] = array_map('trim',explode(',',$indexExpression[1][0]));
}
if (isset($savem)) {
$this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
}
/*
* If we want primary, add it here
*/
if ($primary){
/*
* Check the previously retrieved pragma to search
* with a closure
*/
$pkIndexData = array('unique'=>1,'columns'=>array());
$pkCallBack = function ($value, $key) use (&$pkIndexData) {
/*
* As we iterate the elements check for pk index and sort
*/
@ -514,7 +518,7 @@ class ADODB_sqlite3 extends ADOConnection {
ksort($pkIndexData['columns']);
}
};
array_walk($pragmaData,$pkCallBack);
/*
@ -524,7 +528,7 @@ class ADODB_sqlite3 extends ADOConnection {
if (count($pkIndexData['columns']) > 0)
$indexes['PRIMARY'] = $pkIndexData;
}
return $indexes;
}

View File

@ -1,23 +1,31 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Portable version of sqlite driver, to make it more similar to other database drivers.
The main differences are
1. When selecting (joining) multiple tables, in assoc mode the table
names are included in the assoc keys in the "sqlite" driver.
In "sqlitepo" driver, the table names are stripped from the returned column names.
When this results in a conflict, the first field get preference.
Contributed by Herman Kuiper herman#ozuzo.net
*/
/**
* SQLite Portable driver.
*
* Make it more similar to other database drivers. The main differences are
* - When selecting (joining) multiple tables, in assoc mode the table
* names are included in the assoc keys in the "sqlite" driver.
* In "sqlitepo" driver, the table names are stripped from the returned
* column names. When this results in a conflict, the first field gets
* preference.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
* @author Herman Kuiper <herman@ozuzo.net>
*/
if (!defined('ADODB_DIR')) die();

View File

@ -1,21 +1,24 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim. All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Sybase driver contributed by Toni (toni.tunkkari@finebyte.com)
- MSSQL date patch applied.
Date patch by Toni 15 Feb 2002
*/
/**
* Sybase driver
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
* @author Toni Tunkkari <toni.tunkkari@finebyte.com>
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -44,11 +47,15 @@ class ADODB_sybase extends ADOConnection {
var $port;
// might require begintrans -- committrans
function _insertid()
/**
* might require begintrans -- committrans
* @inheritDoc
*/
protected function _insertID($table = '', $column = '')
{
return $this->GetOne('select @@identity');
}
// might require begintrans -- committrans
function _affectedrows()
{

View File

@ -1,17 +1,24 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4.
Contributed by Interakt Online. Thx Cristian MARIN cristic#interaktonline.com
*/
/**
* SAP Adaptive Server Enterprise driver (formerly Sybase ASE)
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
* @author Cristian Marin, Interakt Online <cristic@interaktonline.com>
*/
require_once ADODB_DIR."/drivers/adodb-sybase.inc.php";

View File

@ -1,63 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Set tabs to 4.
*/
/*
Setup:
$db = NewADOConnection('text');
$db->Connect($array,[$types],[$colnames]);
Parameter $array is the 2 dimensional array of data. The first row can contain the
column names. If column names is not defined in first row, you MUST define $colnames,
the 3rd parameter.
Parameter $types is optional. If defined, it should contain an array matching
the number of columns in $array, with each element matching the correct type defined
by MetaType: (B,C,I,L,N). If undefined, we will probe for $this->_proberows rows
to guess the type. Only C,I and N are recognised.
Parameter $colnames is optional. If defined, it is an array that contains the
column names of $array. If undefined, we assume the first row of $array holds the
column names.
The Execute() function will return a recordset. The recordset works like a normal recordset.
We have partial support for SQL parsing. We process the SQL using the following rules:
1. SQL order by's always work for the first column ordered. Subsequent cols are ignored
2. All operations take place on the same table. No joins possible. In fact the FROM clause
is ignored! You can use any name for the table.
3. To simplify code, all columns are returned, except when selecting 1 column
$rs = $db->Execute('select col1,col2 from table'); // sql ignored, will generate all cols
We special case handling of 1 column because it is used in filter popups
$rs = $db->Execute('select col1 from table');
// sql accepted and processed -- any table name is accepted
$rs = $db->Execute('select distinct col1 from table');
// sql accepted and processed
4. Where clauses are ignored, but searching with the 3rd parameter of Execute is permitted.
This has to use PHP syntax and we will eval() it. You can even use PHP functions.
$rs = $db->Execute('select * from table',false,"\$COL1='abc' and $\COL2=3")
// the 3rd param is searched -- make sure that $COL1 is a legal column name
// and all column names must be in upper case.
4. Group by, having, other clauses are ignored
5. Expression columns, min(), max() are ignored
6. All data is readonly. Only SELECTs permitted.
*/
/**
* ADOdb Plain Text driver
*
* @deprecated
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
@ -97,11 +59,6 @@ class ADODB_text extends ADOConnection {
return sizeof($this->_origarray);
}
function _insertid()
{
return false;
}
function _affectedrows()
{
return false;

View File

@ -1,17 +1,25 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Microsoft Visual FoxPro data driver. Requires ODBC. Works only on MS Windows.
*/
/**
* Microsoft Visual FoxPro driver
*
* @deprecated
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,4 +1,23 @@
<?php
/**
* English language strings.
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
$ADODB_LANG_ARRAY = array (
'LANG' => 'en',

View File

@ -1,18 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Library for basic performance monitoring and tuning
*/
/**
* Library for basic performance monitoring and tuning
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,18 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Library for basic performance monitoring and tuning
*/
/**
* Library for basic performance monitoring and tuning
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

View File

@ -1,19 +1,23 @@
<?php
/*
@version v5.21.0 2021-02-27
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at https://adodb.org/
Library for basic performance monitoring and tuning
*/
/**
* Library for basic performance monitoring and tuning
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();

Some files were not shown because too many files have changed in this diff Show More