function __construct($table = false, $pkeyarr = false, $db = false) { global $ADODB_ASSOC_CASE, $_ADODB_ACTIVE_DBS; if ($db == false && is_object($pkeyarr)) { $db = $pkeyarr; $pkeyarr = false; } if (!$table) { $table = $this->_pluralize(get_class($this)); } if ($db) { $this->_dbat = ADODB_Active_Record::SetDatabaseAdapter($db); } else { $this->_dbat = sizeof($_ADODB_ACTIVE_DBS) - 1; } if ($this->_dbat < 0) { $this->Error("No database connection set; use ADOdb_Active_Record::SetDatabaseAdapter(\$db)", 'ADODB_Active_Record::__constructor'); } $this->_table = $table; $this->_tableat = $table; # reserved for setting the assoc value to a non-table name, eg. the sql string in future $this->UpdateActiveTable($pkeyarr); }
function __construct($table = false, $pkeyarr = false, $db = false, $options = array()) { global $ADODB_ASSOC_CASE, $_ADODB_ACTIVE_DBS; if ($db == false && is_object($pkeyarr)) { $db = $pkeyarr; $pkeyarr = false; } if ($table) { // table argument exists. It is expected to be // already plural form. $this->_pTable = $table; $this->_sTable = $this->_singularize($this->_pTable); } else { // We will use current classname as table name. // We need to pluralize it for the real table name. $this->_sTable = strtolower(get_class($this)); $this->_pTable = $this->_pluralize($this->_sTable); } $this->_table =& $this->_pTable; $this->foreignName = $this->_sTable; // CFR: default foreign name (singular) if ($db) { $this->_dbat = ADODB_Active_Record::SetDatabaseAdapter($db); } else { $this->_dbat = sizeof($_ADODB_ACTIVE_DBS) - 1; } if ($this->_dbat < 0) { $this->Error("No database connection set; use ADOdb_Active_Record::SetDatabaseAdapter(\$db)", 'ADODB_Active_Record::__constructor'); } $this->_tableat = $this->_table; # reserved for setting the assoc value to a non-table name, eg. the sql string in future // CFR: Just added this option because UpdateActiveTable() can refresh its information // but there was no way to ask it to do that. $forceUpdate = isset($options['refresh']) && true === $options['refresh']; $this->UpdateActiveTable($pkeyarr, $forceUpdate); if (isset($options['new']) && true === $options['new']) { $table =& $this->TableInfo(); unset($table->_hasMany); unset($table->_belongsTo); $table->_hasMany = array(); $table->_belongsTo = array(); } }
function __construct($table = false, $pkeyarr=false, $db=false) { global $ADODB_ASSOC_CASE,$_ADODB_ACTIVE_DBS; if ($db == false && is_object($pkeyarr)) { $db = $pkeyarr; $pkeyarr = false; } if (!$table) { if (!empty($this->_table)) $table = $this->_table; else $table = $this->_pluralize(get_class($this)); } $this->foreignName = strtolower(get_class($this)); // CFR: default foreign name if ($db) { $this->_dbat = ADODB_Active_Record::SetDatabaseAdapter($db); } else if (!isset($this->_dbat)) { if (sizeof($_ADODB_ACTIVE_DBS) == 0) $this->Error("No database connection set; use ADOdb_Active_Record::SetDatabaseAdapter(\$db)",'ADODB_Active_Record::__constructor'); end($_ADODB_ACTIVE_DBS); $this->_dbat = key($_ADODB_ACTIVE_DBS); } $this->_table = $table; $this->_tableat = $table; # reserved for setting the assoc value to a non-table name, eg. the sql string in future $this->UpdateActiveTable($pkeyarr); }