|
Adodb Dokumentation
V5.14 8 Sept 2011
|
Öffentliche Methoden | |
| __set ($name, $value) | |
| __construct ($table=false, $pkeyarr=false, $db=false) | |
| __wakeup () | |
| _pluralize ($table) | |
| _singularize ($tables) | |
| hasMany ($foreignRef, $foreignKey=false, $foreignClass= 'ADODB_Active_Record') | |
| belongsTo ($foreignRef, $foreignKey=false, $parentKey='', $parentClass= 'ADODB_Active_Record') | |
| __get ($name) | |
| LoadRelations ($name, $whereOrderBy='', $offset=-1, $limit=-1) | |
| UpdateActiveTable ($pkeys=false, $forceUpdate=false) | |
| GetPrimaryKeys (&$db, $table) | |
| Error ($err, $fn) | |
| ErrorMsg () | |
| ErrorNo () | |
| DB () | |
| & | TableInfo () |
| Reload () | |
| Set (&$row) | |
| LastInsertID (&$db, $fieldname) | |
| doquote (&$db, $val, $t) | |
| GenWhere (&$db, &$table) | |
| _QName ($n, $db=false) | |
| Load ($where=null, $bindarr=false) | |
| Reset () | |
| Save () | |
| Insert () | |
| Delete () | |
| Find ($whereOrderBy, $bindarr=false, $pkeysArr=false, $extra=array()) | |
| Replace () | |
| Update () | |
| GetAttributeNames () | |
| __set ($name, $value) | |
| __construct ($table=false, $pkeyarr=false, $db=false, $options=array()) | |
| __wakeup () | |
| _pluralize ($table) | |
| _singularize ($table) | |
| hasMany ($foreignRef, $foreignKey=false) | |
| belongsTo ($foreignRef, $foreignKey=false) | |
| __get ($name) | |
| LoadRelations ($name, $whereOrderBy, $offset=-1, $limit=-1) | |
| UpdateActiveTable ($pkeys=false, $forceUpdate=false) | |
| GetPrimaryKeys (&$db, $table) | |
| Error ($err, $fn) | |
| ErrorMsg () | |
| ErrorNo () | |
| DB () | |
| & | TableInfo () |
| Reload () | |
| Set (&$row) | |
| LastInsertID (&$db, $fieldname) | |
| doquote (&$db, $val, $t) | |
| GenWhere (&$db, &$table) | |
| Load ($where=null, $bindarr=false) | |
| Save () | |
| Dirty () | |
| Insert () | |
| Delete () | |
| Find ($whereOrderBy, $bindarr=false, $pkeysArr=false, $extra=array()) | |
| packageFind ($whereOrderBy, $bindarr=false, $pkeysArr=false, $extra=array()) | |
| Replace () | |
| Update () | |
| GetAttributeNames () | |
Öffentliche, statische Methoden | |
| static | UseDefaultValues ($bool=null) |
| static | SetDatabaseAdapter (&$db, $index=false) |
| static | TableHasMany ($table, $foreignRef, $foreignKey=false, $foreignClass= 'ADODB_Active_Record') |
| static | TableKeyHasMany ($table, $tablePKey, $foreignRef, $foreignKey=false, $foreignClass= 'ADODB_Active_Record') |
| static | ClassHasMany ($parentclass, $foreignRef, $foreignKey=false, $foreignClass= 'ADODB_Active_Record') |
| static | ClassBelongsTo ($class, $foreignRef, $foreignKey=false, $parentKey='', $parentClass= 'ADODB_Active_Record') |
| static | TableBelongsTo ($table, $foreignRef, $foreignKey=false, $parentKey='', $parentClass= 'ADODB_Active_Record') |
| static | TableKeyBelongsTo ($table, $tablePKey, $foreignRef, $foreignKey=false, $parentKey='', $parentClass= 'ADODB_Active_Record') |
| static | UseDefaultValues ($bool=null) |
| static | SetDatabaseAdapter (&$db) |
Datenfelder | |
| $_dbat | |
| $_table | |
| $_tableat | |
| $_where | |
| $_saved = false | |
| $_lasterr = false | |
| $_original = false | |
| $foreignName | |
| $_sTable | |
| $_pTable | |
Statische öffentliche Attribute | |
| static | $_changeNames = true |
| static | $_quoteNames = false |
| static | $_foreignSuffix = '_id' |
| static | $IrregularP |
| static | $IrregularS |
| static | $WeIsI |
Definiert in Zeile 75 der Datei adodb-active-record.inc.php.
| __get | ( | $ | name | ) |
__get Access properties - used for lazy loading
| mixed | $name | protected |
Definiert in Zeile 274 der Datei adodb-active-record.inc.php.
{
return $this->LoadRelations($name, '', -1, -1);
}

| __get | ( | $ | name | ) |
__get Access properties - used for lazy loading
| mixed | $name | protected |
Definiert in Zeile 340 der Datei adodb-active-recordx.inc.php.
{
return $this->LoadRelations($name, '', -1. -1);
}

| belongsTo | ( | $ | foreignRef, |
| $ | foreignKey = false |
||
| ) |
ar->foreignName will contain the name of the tables associated with this table because this table's rows may also be referenced by those tables using thistable_id or the provided foreign keys (this index name is stored in ar->foreignKey)
this-table.other-table_id = other-table.id
Definiert in Zeile 315 der Datei adodb-active-recordx.inc.php.
{
global $inflector;
$ar = new ADODB_Active_Record($this->_pluralize($foreignRef));
$ar->foreignName = $foreignRef;
$ar->UpdateActiveTable();
$ar->foreignKey = ($foreignKey) ? $foreignKey : $ar->foreignName . self::$_foreignSuffix;
$table =& $this->TableInfo();
if(!isset($table->_belongsTo[$foreignRef]))
{
$table->_belongsTo[$foreignRef] = $ar;
$table->updateColsCount();
}
$this->$foreignRef = $table->_belongsTo[$foreignRef];
}
| Load | ( | $ | where = null, |
| $ | bindarr = false |
||
| ) |
Definiert in Zeile 747 der Datei adodb-active-recordx.inc.php.
{
$db = $this->DB(); if (!$db) return false;
$this->_where = $where;
$save = $db->SetFetchMode(ADODB_FETCH_NUM);
$qry = "select * from ".$this->_table;
$table =& $this->TableInfo();
if(($k = reset($table->keys)))
$hasManyId = $k;
else
$hasManyId = 'id';
foreach($table->_belongsTo as $foreignTable)
{
if(($k = reset($foreignTable->TableInfo()->keys)))
{
$belongsToId = $k;
}
else
{
$belongsToId = 'id';
}
$qry .= ' LEFT JOIN '.$foreignTable->_table.' ON '.
$this->_table.'.'.$foreignTable->foreignKey.'='.
$foreignTable->_table.'.'.$belongsToId;
}
foreach($table->_hasMany as $foreignTable)
{
$qry .= ' LEFT JOIN '.$foreignTable->_table.' ON '.
$this->_table.'.'.$hasManyId.'='.
$foreignTable->_table.'.'.$foreignTable->foreignKey;
}
if($where)
$qry .= ' WHERE '.$where;
// Simple case: no relations. Load row and return.
if((count($table->_hasMany) + count($table->_belongsTo)) < 1)
{
$row = $db->GetRow($qry,$bindarr);
if(!$row)
return false;
$db->SetFetchMode($save);
return $this->Set($row);
}
// More complex case when relations have to be collated
$rows = $db->GetAll($qry,$bindarr);
if(!$rows)
return false;
$db->SetFetchMode($save);
if(count($rows) < 1)
return false;
$class = get_class($this);
$isFirstRow = true;
if(($k = reset($this->TableInfo()->keys)))
$myId = $k;
else
$myId = 'id';
$index = 0; $found = false;
foreach($this->TableInfo()->flds as $fld)
{
if($fld->name == $myId)
{
$found = true;
break;
}
$index++;
}
if(!$found)
$this->outp_throw("Unable to locate key $myId for $class in Load()",'Load');
foreach($rows as $row)
{
$rowId = intval($row[$index]);
if($rowId > 0)
{
if($isFirstRow)
{
$isFirstRow = false;
if(!$this->Set($row))
return false;
}
$obj = new $class($table,false,$db);
$obj->Set($row);
// TODO Copy/paste code below: bad!
if(count($table->_hasMany) > 0)
{
foreach($table->_hasMany as $foreignTable)
{
$foreignName = $foreignTable->foreignName;
if(!empty($obj->$foreignName))
{
if(!is_array($this->$foreignName))
{
$foreignObj = $this->$foreignName;
$this->$foreignName = array(clone($foreignObj));
}
else
{
$foreignObj = $obj->$foreignName;
array_push($this->$foreignName, clone($foreignObj));
}
}
}
}
if(count($table->_belongsTo) > 0)
{
foreach($table->_belongsTo as $foreignTable)
{
$foreignName = $foreignTable->foreignName;
if(!empty($obj->$foreignName))
{
if(!is_array($this->$foreignName))
{
$foreignObj = $this->$foreignName;
$this->$foreignName = array(clone($foreignObj));
}
else
{
$foreignObj = $obj->$foreignName;
array_push($this->$foreignName, clone($foreignObj));
}
}
}
}
}
}
return true;
}
| LoadRelations | ( | $ | name, |
| $ | whereOrderBy = '', |
||
| $ | offset = -1, |
||
| $ | limit = -1 |
||
| ) |
| string | $name | |
| string | $whereOrderBy | : eg. ' AND field1 = value ORDER BY field2' |
| offset | ||
| limit |
Definiert in Zeile 286 der Datei adodb-active-record.inc.php.
{
$extras = array();
$table = $this->TableInfo();
if ($limit >= 0) $extras['limit'] = $limit;
if ($offset >= 0) $extras['offset'] = $offset;
if (strlen($whereOrderBy))
if (!preg_match('/^[ \n\r]*AND/i',$whereOrderBy))
if (!preg_match('/^[ \n\r]*ORDER[ \n\r]/i',$whereOrderBy))
$whereOrderBy = 'AND '.$whereOrderBy;
if(!empty($table->_belongsTo[$name]))
{
$obj = $table->_belongsTo[$name];
$columnName = $obj->foreignKey;
if(empty($this->$columnName))
$this->$name = null;
else
{
if ($obj->parentKey) $key = $obj->parentKey;
else $key = reset($table->keys);
$arrayOfOne = $obj->Find($key.'='.$this->$columnName.' '.$whereOrderBy,false,false,$extras);
if ($arrayOfOne) {
$this->$name = $arrayOfOne[0];
return $arrayOfOne[0];
}
}
}
if(!empty($table->_hasMany[$name]))
{
$obj = $table->_hasMany[$name];
$key = reset($table->keys);
$id = @$this->$key;
if (!is_numeric($id)) {
$db = $this->DB();
$id = $db->qstr($id);
}
$objs = $obj->Find($obj->foreignKey.'='.$id. ' '.$whereOrderBy,false,false,$extras);
if (!$objs) $objs = array();
$this->$name = $objs;
return $objs;
}
return array();
}

$IrregularP [static] |
array(
'PERSON' => 'people',
'MAN' => 'men',
'WOMAN' => 'women',
'CHILD' => 'children',
'COW' => 'kine',
)
Definiert in Zeile 189 der Datei adodb-active-recordx.inc.php.
$IrregularS [static] |
array(
'PEOPLE' => 'PERSON',
'MEN' => 'man',
'WOMEN' => 'woman',
'CHILDREN' => 'child',
'KINE' => 'cow',
)
Definiert in Zeile 197 der Datei adodb-active-recordx.inc.php.
$WeIsI [static] |
array(
'EQUIPMENT' => true,
'INFORMATION' => true,
'RICE' => true,
'MONEY' => true,
'SPECIES' => true,
'SERIES' => true,
'FISH' => true,
'SHEEP' => true,
)
Definiert in Zeile 205 der Datei adodb-active-recordx.inc.php.