Skip to content

Commit

Permalink
MDL-14672 adodb PHP5 only version V5.04a import - yay!
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed May 2, 2008
1 parent 32ba2f0 commit ef85daa
Show file tree
Hide file tree
Showing 102 changed files with 5,693 additions and 5,461 deletions.
89 changes: 46 additions & 43 deletions lib/adodb/adodb-active-record.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
@version V4.98 13 Feb 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved.
@version V5.04a 25 Mar 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved.
Latest version is available at http://adodb.sourceforge.net
Released under both BSD license and Lesser GPL library license.
Expand All @@ -10,7 +10,7 @@
Active Record implementation. Superset of Zend Framework's.
Version 0.09
Version 0.08
See http://www-128.ibm.com/developerworks/java/library/j-cb03076/?ca=dgr-lnxw01ActiveRecord
for info on Ruby on Rails Active Record implementation
Expand Down Expand Up @@ -53,7 +53,7 @@ function ADODB_SetDatabaseAdapter(&$db)
}

$obj = new ADODB_Active_DB();
$obj->db =& $db;
$obj->db = $db;
$obj->tables = array();

$_ADODB_ACTIVE_DBS[] = $obj;
Expand All @@ -71,24 +71,24 @@ class ADODB_Active_Record {
var $_lasterr = false; // last error message
var $_original = false; // the original values loaded or inserted, refreshed on update

// should be static
function UseDefaultValues($bool=null)
static function UseDefaultValues($bool=null)
{
global $ADODB_ACTIVE_DEFVALS;
if (isset($bool)) $ADODB_ACTIVE_DEFVALS = $bool;
return $ADODB_ACTIVE_DEFVALS;
}

// should be static
function SetDatabaseAdapter(&$db)
static function SetDatabaseAdapter(&$db)
{
return ADODB_SetDatabaseAdapter($db);
}

// php4 constructor
function ADODB_Active_Record($table = false, $pkeyarr=false, $db=false)

public function __set($name, $value)
{
ADODB_Active_Record::__construct($table,$pkeyarr,$db);
$name = str_replace(' ', '_', $name);
$this->$name = $value;
}

// php5 constructor
Expand Down Expand Up @@ -153,23 +153,24 @@ function UpdateActiveTable($pkeys=false,$forceUpdate=false)
global $ADODB_ASSOC_CASE,$_ADODB_ACTIVE_DBS , $ADODB_CACHE_DIR, $ADODB_ACTIVE_CACHESECS;
global $ADODB_ACTIVE_DEFVALS;

$activedb =& $_ADODB_ACTIVE_DBS[$this->_dbat];
$activedb = $_ADODB_ACTIVE_DBS[$this->_dbat];

$table = $this->_table;
$tables = $activedb->tables;
$tableat = $this->_tableat;
if (!$forceUpdate && !empty($tables[$tableat])) {
$tobj =& $tables[$tableat];

$tobj = $tables[$tableat];
foreach($tobj->flds as $name => $fld) {
if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value))
$this->$name = $fld->default_value;
else
$this->$name = null;
if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value))
$this->$name = $fld->default_value;
else
$this->$name = null;
}
return;
}

$db =& $activedb->db;
$db = $activedb->db;
$fname = $ADODB_CACHE_DIR . '/adodb_' . $db->databaseType . '_active_'. $table . '.cache';
if (!$forceUpdate && $ADODB_ACTIVE_CACHESECS && $ADODB_CACHE_DIR && file_exists($fname)) {
$fp = fopen($fname,'r');
Expand Down Expand Up @@ -288,7 +289,7 @@ function Error($err,$fn)
if ($this->_dbat < 0) $db = false;
else {
$activedb = $_ADODB_ACTIVE_DBS[$this->_dbat];
$db =& $activedb->db;
$db = $activedb->db;
}

if (function_exists('adodb_throw')) {
Expand Down Expand Up @@ -322,7 +323,7 @@ function ErrorNo()


// retrieve ADOConnection from _ADODB_Active_DBs
function &DB()
function DB()
{
global $_ADODB_ACTIVE_DBS;

Expand All @@ -332,17 +333,17 @@ function &DB()
return $false;
}
$activedb = $_ADODB_ACTIVE_DBS[$this->_dbat];
$db =& $activedb->db;
$db = $activedb->db;
return $db;
}

// retrieve ADODB_Active_Table
function &TableInfo()
function TableInfo()
{
global $_ADODB_ACTIVE_DBS;

$activedb = $_ADODB_ACTIVE_DBS[$this->_dbat];
$table =& $activedb->tables[$this->_tableat];
$table = $activedb->tables[$this->_tableat];
return $table;
}

Expand All @@ -351,7 +352,7 @@ function Set(&$row)
{
global $ACTIVE_RECORD_SAFETY;

$db =& $this->DB();
$db = $this->DB();

if (!$row) {
$this->_saved = false;
Expand All @@ -360,8 +361,9 @@ function Set(&$row)

$this->_saved = true;

$table =& $this->TableInfo();
$table = $this->TableInfo();
if ($ACTIVE_RECORD_SAFETY && sizeof($table->flds) != sizeof($row)) {
# <AP>
$bad_size = TRUE;
if (sizeof($row) == 2 * sizeof($table->flds)) {
// Only keep string keys
Expand All @@ -370,13 +372,14 @@ function Set(&$row)
$bad_size = FALSE;
}
if ($bad_size) {
$this->Error("Table structure of $this->_table has changed","Load");
return false;
}
$this->Error("Table structure of $this->_table has changed","Load");
return false;
}
# </AP>
}
else
$keys = array_keys($row);

$keys = array_keys($row);
# <AP>
reset($keys);
$this->_original = array();
foreach($table->flds as $name=>$fld) {
Expand Down Expand Up @@ -446,7 +449,7 @@ function GenWhere(&$db, &$table)

function Load($where,$bindarr=false)
{
$db =& $this->DB(); if (!$db) return false;
$db = $this->DB(); if (!$db) return false;
$this->_where = $where;

$save = $db->SetFetchMode(ADODB_FETCH_NUM);
Expand All @@ -468,9 +471,9 @@ function Save()
// false on error
function Insert()
{
$db =& $this->DB(); if (!$db) return false;
$db = $this->DB(); if (!$db) return false;
$cnt = 0;
$table =& $this->TableInfo();
$table = $this->TableInfo();

$valarr = array();
$names = array();
Expand Down Expand Up @@ -518,8 +521,8 @@ function Insert()

function Delete()
{
$db =& $this->DB(); if (!$db) return false;
$table =& $this->TableInfo();
$db = $this->DB(); if (!$db) return false;
$table = $this->TableInfo();

$where = $this->GenWhere($db,$table);
$sql = 'DELETE FROM '.$this->_table.' WHERE '.$where;
Expand All @@ -529,10 +532,10 @@ function Delete()
}

// returns an array of active record objects
function &Find($whereOrderBy,$bindarr=false,$pkeysArr=false)
function Find($whereOrderBy,$bindarr=false,$pkeysArr=false)
{
$db =& $this->DB(); if (!$db || empty($this->_table)) return false;
$arr =& $db->GetActiveRecordsClass(get_class($this),$this->_table, $whereOrderBy,$bindarr,$pkeysArr);
$db = $this->DB(); if (!$db || empty($this->_table)) return false;
$arr = $db->GetActiveRecordsClass(get_class($this),$this->_table, $whereOrderBy,$bindarr,$pkeysArr);
return $arr;
}

Expand All @@ -541,8 +544,8 @@ function Replace()
{
global $ADODB_ASSOC_CASE;

$db =& $this->DB(); if (!$db) return false;
$table =& $this->TableInfo();
$db = $this->DB(); if (!$db) return false;
$table = $this->TableInfo();

$pkey = $table->keys;

Expand Down Expand Up @@ -593,16 +596,16 @@ function Replace()
}
}

$this->_original =& $valarr;
$this->_original = $valarr;
}
return $ok;
}

// returns 0 on error, 1 on update, -1 if no change in data (no update)
function Update()
{
$db =& $this->DB(); if (!$db) return false;
$table =& $this->TableInfo();
$db = $this->DB(); if (!$db) return false;
$table = $this->TableInfo();

$where = $this->GenWhere($db, $table);

Expand Down Expand Up @@ -647,15 +650,15 @@ function Update()
$sql = 'UPDATE '.$this->_table." SET ".implode(",",$pairs)." WHERE ".$where;
$ok = $db->Execute($sql,$valarr);
if ($ok) {
$this->_original =& $neworig;
$this->_original = $neworig;
return 1;
}
return 0;
}

function GetAttributeNames()
{
$table =& $this->TableInfo();
$table = $this->TableInfo();
if (!$table) return false;
return array_keys($table->flds);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/adodb/adodb-csvlib.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/*
V4.98 13 Feb 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.04a 25 Mar 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). 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. See License.txt.
Expand Down Expand Up @@ -54,7 +54,7 @@ function _rs2serialize(&$rs,$conn=false,$sql='')
$line = "====1,$tt,$sql\n";

if ($rs->databaseType == 'array') {
$rows =& $rs->_array;
$rows = $rs->_array;
} else {
$rows = array();
while (!$rs->EOF) {
Expand All @@ -64,7 +64,7 @@ function _rs2serialize(&$rs,$conn=false,$sql='')
}

for($i=0; $i < $max; $i++) {
$o =& $rs->FetchField($i);
$o = $rs->FetchField($i);
$flds[] = $o;
}

Expand All @@ -90,7 +90,7 @@ function _rs2serialize(&$rs,$conn=false,$sql='')
* error occurred in sql INSERT/UPDATE/DELETE,
* empty recordset is returned
*/
function &csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array')
function csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array')
{
$false = false;
$err = false;
Expand Down
5 changes: 2 additions & 3 deletions lib/adodb/adodb-datadict.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
V4.98 13 Feb 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.04a 25 Mar 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). 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.
Expand Down Expand Up @@ -215,7 +215,6 @@ function MetaIndexes($table, $primary = false, $owner = false)
return $this->connection->MetaIndexes($this->TableName($table), $primary, $owner);
}


function MetaType($t,$len=-1,$fieldobj=false)
{
static $typeMap = array(
Expand Down Expand Up @@ -369,7 +368,7 @@ function TableName($name)
function ExecuteSQLArray($sql, $continueOnError = true)
{
$rez = 2;
$conn = &$this->connection;
$conn = $this->connection;
$saved = $conn->debug;
foreach($sql as $line) {

Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-error.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @version V4.98 13 Feb 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved.
* @version V5.04a 25 Mar 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). 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.
Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-errorhandler.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @version V4.98 13 Feb 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved.
* @version V5.04a 25 Mar 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). 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.
Expand Down
4 changes: 2 additions & 2 deletions lib/adodb/adodb-errorpear.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @version V4.98 13 Feb 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved.
* @version V5.04a 25 Mar 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). 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.
Expand Down Expand Up @@ -78,7 +78,7 @@ function ADODB_Error_PEAR($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false)
* Returns last PEAR_Error object. This error might be for an error that
* occured several sql statements ago.
*/
function &ADODB_PEAR_Error()
function ADODB_PEAR_Error()
{
global $ADODB_Last_PEAR_Error;

Expand Down
2 changes: 1 addition & 1 deletion lib/adodb/adodb-exceptions.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* @version V4.98 13 Feb 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved.
* @version V5.04a 25 Mar 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). 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.
Expand Down
Loading

0 comments on commit ef85daa

Please sign in to comment.