Navigation Menu

Skip to content

Commit

Permalink
Remove references to ADOdb Extension
Browse files Browse the repository at this point in the history
The ADOdb Extension's development stopped at version 5.04. It is no
longer maintained or supported, yet the library still contains code
referencing it. If those code branches are executed, ADOdb will not
perform properly, due to missing constant declarations (among other
things).

This commit removes all references to the Extension.

Fixes #270, #269
  • Loading branch information
dregad committed Oct 11, 2016
1 parent 0f4217e commit 376249c
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 188 deletions.
19 changes: 6 additions & 13 deletions adodb-lib.inc.php
Expand Up @@ -465,18 +465,11 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
if (!$rstest) $rstest = $zthis->Execute($sql,$inputarr);
}
if ($rstest) {
$qryRecs = $rstest->RecordCount();
$qryRecs = $rstest->RecordCount();
if ($qryRecs == -1) {
global $ADODB_EXTENSION;
// some databases will return -1 on MoveLast() - change to MoveNext()
if ($ADODB_EXTENSION) {
while(!$rstest->EOF) {
adodb_movenext($rstest);
}
} else {
while(!$rstest->EOF) {
$rstest->MoveNext();
}
// some databases will return -1 on MoveLast() - change to MoveNext()
while(!$rstest->EOF) {
$rstest->MoveNext();
}
$qryRecs = $rstest->_currentRow;
}
Expand Down Expand Up @@ -905,7 +898,7 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$force=2)
$values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, $arrFields, $magicq);
}
break;

case ADODB_FORCE_NULL_AND_ZERO:
switch ($type)
{
Expand All @@ -919,7 +912,7 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$force=2)
break;
}
break;

} // switch

/*********************************************************/
Expand Down
189 changes: 60 additions & 129 deletions adodb.inc.php
Expand Up @@ -75,7 +75,6 @@ class library to hide the differences between the different database API's (enca
$ADODB_CACHE_DIR, // directory to cache recordsets
$ADODB_CACHE,
$ADODB_CACHE_CLASS,
$ADODB_EXTENSION, // ADODB extension installed
$ADODB_COMPAT_FETCH, // If $ADODB_COUNTRECS and this is true, $rs->fields is available on EOF
$ADODB_FETCH_MODE, // DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default...
$ADODB_GETONE_EOF,
Expand All @@ -85,8 +84,6 @@ class library to hide the differences between the different database API's (enca
// GLOBAL SETUP
//==============================================================================================

$ADODB_EXTENSION = defined('ADODB_EXTENSION');

/*********************************************************
* Controls $ADODB_FORCE_TYPE mode. Default is ADODB_FORCE_VALUE (3).
* Used in GetUpdateSql and GetInsertSql functions. Thx to Niko, nuko#mbnet.fi
Expand Down Expand Up @@ -124,17 +121,15 @@ class library to hide the differences between the different database API's (enca
if (!defined('ADODB_DEFAULT_METATYPE'))
define ('ADODB_DEFAULT_METATYPE','N');

if (!$ADODB_EXTENSION || ADODB_EXTENSION < 4.0) {

define('ADODB_BAD_RS','<p>Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;</p>');
define('ADODB_BAD_RS','<p>Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;</p>');

// allow [ ] @ ` " and . in table names
define('ADODB_TABLE_REGEX','([]0-9a-z_\:\"\`\.\@\[-]*)');
define('ADODB_TABLE_REGEX','([]0-9a-z_\:\"\`\.\@\[-]*)');

// prefetching used by oracle
if (!defined('ADODB_PREFETCH_ROWS')) {
define('ADODB_PREFETCH_ROWS',10);
}
if (!defined('ADODB_PREFETCH_ROWS')) {
define('ADODB_PREFETCH_ROWS',10);
}


/**
Expand All @@ -149,10 +144,10 @@ class library to hide the differences between the different database API's (enca
* - BOTH: array(0 => 456, 'id' => 456, 1 => 'john', 'name' => 'john')
* - DEFAULT: driver-dependent
*/
define('ADODB_FETCH_DEFAULT', 0);
define('ADODB_FETCH_NUM', 1);
define('ADODB_FETCH_ASSOC', 2);
define('ADODB_FETCH_BOTH', 3);
define('ADODB_FETCH_DEFAULT', 0);
define('ADODB_FETCH_NUM', 1);
define('ADODB_FETCH_ASSOC', 2);
define('ADODB_FETCH_BOTH', 3);

/**
* Associative array case constants
Expand All @@ -169,34 +164,34 @@ class library to hide the differences between the different database API's (enca
* NOTE: This functionality is not implemented everywhere, it currently
* works only with: mssql, odbc, oci8 and ibase derived drivers
*/
define('ADODB_ASSOC_CASE_LOWER', 0);
define('ADODB_ASSOC_CASE_UPPER', 1);
define('ADODB_ASSOC_CASE_NATIVE', 2);
define('ADODB_ASSOC_CASE_LOWER', 0);
define('ADODB_ASSOC_CASE_UPPER', 1);
define('ADODB_ASSOC_CASE_NATIVE', 2);


if (!defined('TIMESTAMP_FIRST_YEAR')) {
define('TIMESTAMP_FIRST_YEAR',100);
}
if (!defined('TIMESTAMP_FIRST_YEAR')) {
define('TIMESTAMP_FIRST_YEAR',100);
}

/**
* AutoExecute constants
* (moved from adodb-pear.inc.php since they are only used in here)
*/
define('DB_AUTOQUERY_INSERT', 1);
define('DB_AUTOQUERY_UPDATE', 2);
/**
* AutoExecute constants
* (moved from adodb-pear.inc.php since they are only used in here)
*/
define('DB_AUTOQUERY_INSERT', 1);
define('DB_AUTOQUERY_UPDATE', 2);


// PHP's version scheme makes converting to numbers difficult - workaround
$_adodb_ver = (float) PHP_VERSION;
if ($_adodb_ver >= 5.2) {
define('ADODB_PHPVER',0x5200);
} else if ($_adodb_ver >= 5.0) {
define('ADODB_PHPVER',0x5000);
} else {
die("PHP5 or later required. You are running ".PHP_VERSION);
}
unset($_adodb_ver);
// PHP's version scheme makes converting to numbers difficult - workaround
$_adodb_ver = (float) PHP_VERSION;
if ($_adodb_ver >= 5.2) {
define('ADODB_PHPVER',0x5200);
} else if ($_adodb_ver >= 5.0) {
define('ADODB_PHPVER',0x5000);
} else {
die("PHP5 or later required. You are running ".PHP_VERSION);
}
unset($_adodb_ver);



/**
Expand Down Expand Up @@ -3528,10 +3523,6 @@ function GetMenu3($name,$defstr='',$blank1stItem=true,$multiple=false,
* @return an array indexed by the rows (0-based) from the recordset
*/
function GetArray($nRows = -1) {
global $ADODB_EXTENSION; if ($ADODB_EXTENSION) {
$results = adodb_getall($this,$nRows);
return $results;
}
$results = array();
$cnt = 0;
while (!$this->EOF && $nRows != $cnt) {
Expand Down Expand Up @@ -3597,8 +3588,6 @@ function GetRows($nRows = -1) {

function vGetAssoc($force_array = false, $first2cols = false)
{
global $ADODB_EXTENSION;

print_r($this);
exit;

Expand All @@ -3611,80 +3600,39 @@ function vGetAssoc($force_array = false, $first2cols = false)
$results = array();

if (!$first2cols && ($cols > 2 || $force_array)) {
if ($ADODB_EXTENSION) {
if ($numIndex) {
while (!$this->EOF) {
$results[trim($this->fields[0])] = array_slice($this->fields, 1);
adodb_movenext($this);
}
} else {
while (!$this->EOF) {
// Fix for array_slice re-numbering numeric associative keys
$keys = array_slice(array_keys($this->fields), 1);
$sliced_array = array();

foreach($keys as $key) {
$sliced_array[$key] = $this->fields[$key];
}

$results[trim(reset($this->fields))] = $sliced_array;
adodb_movenext($this);
}
if ($numIndex) {
while (!$this->EOF) {
$results[trim($this->fields[0])] = array_slice($this->fields, 1);
$this->MoveNext();
}
} else {
if ($numIndex) {
while (!$this->EOF) {
$results[trim($this->fields[0])] = array_slice($this->fields, 1);
$this->MoveNext();
}
} else {
while (!$this->EOF) {
// Fix for array_slice re-numbering numeric associative keys
$keys = array_slice(array_keys($this->fields), 1);
$sliced_array = array();
while (!$this->EOF) {
// Fix for array_slice re-numbering numeric associative keys
$keys = array_slice(array_keys($this->fields), 1);
$sliced_array = array();

foreach($keys as $key) {
$sliced_array[$key] = $this->fields[$key];
}

$results[trim(reset($this->fields))] = $sliced_array;
$this->MoveNext();
foreach($keys as $key) {
$sliced_array[$key] = $this->fields[$key];
}

$results[trim(reset($this->fields))] = $sliced_array;
$this->MoveNext();
}
}
} else {
if ($ADODB_EXTENSION) {
// return scalar values
if ($numIndex) {
while (!$this->EOF) {
// some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
$results[trim(($this->fields[0]))] = $this->fields[1];
adodb_movenext($this);
}
} else {
while (!$this->EOF) {
// some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
$v1 = trim(reset($this->fields));
$v2 = ''.next($this->fields);
$results[$v1] = $v2;
adodb_movenext($this);
}
if ($numIndex) {
while (!$this->EOF) {
// some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
$results[trim(($this->fields[0]))] = $this->fields[1];
$this->MoveNext();
}
} else {
if ($numIndex) {
while (!$this->EOF) {
// some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
$results[trim(($this->fields[0]))] = $this->fields[1];
$this->MoveNext();
}
} else {
while (!$this->EOF) {
// some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
$v1 = trim(reset($this->fields));
$v2 = ''.next($this->fields);
$results[$v1] = $v2;
$this->MoveNext();
}
while (!$this->EOF) {
// some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
$v1 = trim(reset($this->fields));
$v2 = ''.next($this->fields);
$results[$v1] = $v2;
$this->MoveNext();
}
}
}
Expand Down Expand Up @@ -3718,9 +3666,6 @@ function vGetAssoc($force_array = false, $first2cols = false)
*/
function getAssoc($force_array = false, $first2cols = false)
{

global $ADODB_EXTENSION;

/*
* Insufficient rows to show data
*/
Expand Down Expand Up @@ -3833,14 +3778,7 @@ function getAssoc($force_array = false, $first2cols = false)
break;
}

if ($ADODB_EXTENSION)
/*
* Don't really need this either except for
* old version compatibility
*/
adodb_movenext($this);
else
$this->MoveNext();
$this->MoveNext();
}
/*
* Done
Expand Down Expand Up @@ -4066,18 +4004,11 @@ function Move($rowNumber = 0) {
if ($rowNumber < $this->_currentRow) {
return false;
}
global $ADODB_EXTENSION;
if ($ADODB_EXTENSION) {
while (!$this->EOF && $this->_currentRow < $rowNumber) {
adodb_movenext($this);
}
} else {
while (! $this->EOF && $this->_currentRow < $rowNumber) {
$this->_currentRow++;
while (! $this->EOF && $this->_currentRow < $rowNumber) {
$this->_currentRow++;

if (!$this->_fetch()) {
$this->EOF = true;
}
if (!$this->_fetch()) {
$this->EOF = true;
}
}
return !($this->EOF);
Expand Down
3 changes: 2 additions & 1 deletion docs/changelog.md
Expand Up @@ -20,8 +20,9 @@ Older changelogs:
- adodb: Add new value defaulting mode for getInsertSQL(). #214
- adodb: Added portable substring method. #219
- adodb: New helper methods: day(), month(), year(). #225
- adodb: Remove references to obsolete ADOdb Extension. #270
- adodb-time: Fix 'Q' (quarter of year) format in adodb_date(). #222
- adodb-time: Add 'W' (week of year) format support in adodb_date(). #223
- adodb-time: Add 'W' (week of year) format support in adodb_date(). #223
- firebird: updated driver, thanks to Lester Caine. #201
- mssql: Add charMax() and textMax() methods. #220
- mssqlnative: Query not returning id. #185
Expand Down
8 changes: 0 additions & 8 deletions drivers/adodb-access.inc.php
Expand Up @@ -32,14 +32,6 @@ class ADODB_access extends ADODB_odbc {
var $hasTransactions = false;
var $upperCase = 'ucase';

function __construct()
{
global $ADODB_EXTENSION;

$ADODB_EXTENSION = false;
parent::__construct();
}

function Time()
{
return time();
Expand Down
7 changes: 0 additions & 7 deletions drivers/adodb-mysql.inc.php
Expand Up @@ -51,11 +51,6 @@ class ADODB_mysql extends ADOConnection {
var $nameQuote = '`'; /// string to use to quote identifiers and names
var $compat323 = false; // true if compat with mysql 3.23

function __construct()
{
if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_';
}


// SetCharSet - switch the client encoding
function SetCharSet($charset_name)
Expand Down Expand Up @@ -794,8 +789,6 @@ function _seek($row)

function MoveNext()
{
//return adodb_movenext($this);
//if (defined('ADODB_EXTENSION')) return adodb_movenext($this);
if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
$this->_updatefields();
$this->_currentRow += 1;
Expand Down
9 changes: 0 additions & 9 deletions drivers/adodb-mysqli.inc.php
Expand Up @@ -29,9 +29,6 @@
if (! defined("MYSQLI_BINARY_FLAG")) define("MYSQLI_BINARY_FLAG", 128);
if (!defined('MYSQLI_READ_DEFAULT_GROUP')) define('MYSQLI_READ_DEFAULT_GROUP',1);

// disable adodb extension - currently incompatible.
global $ADODB_EXTENSION; $ADODB_EXTENSION = false;

class ADODB_mysqli extends ADOConnection {
var $databaseType = 'mysqli';
var $dataProvider = 'mysql';
Expand Down Expand Up @@ -70,12 +67,6 @@ class ADODB_mysqli extends ADOConnection {
private $usePreparedStatement = false;
private $useLastInsertStatement = false;

function __construct()
{
// if(!extension_loaded("mysqli"))
//trigger_error("You must have the mysqli extension installed.", E_USER_ERROR);
}

function SetTransactionMode( $transaction_mode )
{
$this->_transmode = $transaction_mode;
Expand Down

0 comments on commit 376249c

Please sign in to comment.