Public Member Functions | |
__construct (Connection $conn, $tableName, $p3=null, $p4=null) | |
Construct new TableDataSet instance. | |
tableName () | |
Gets the tableName defined in the schema. | |
tableInfo () | |
Load the TableInfo (metadata) object for this table. | |
fetchRecords ($p1=0, $p2=null) | |
Fetch start to max records. | |
addRecord () | |
Creates a new Record within this DataSet. | |
save () | |
Saves all the records in the DataSet. | |
removeDeletedRecords () | |
Removes any records that are marked as a zombie. | |
setOptimisticLockingColumn ($olc) | |
Sets the table column used for optomistic locking. | |
optimisticLockingCol () | |
Gets the table column used for optomistic locking. | |
where ($where) | |
Sets the value for the SQL portion of the WHERE statement. | |
getWhere () | |
Gets the value of the SQL portion of WHERE. | |
order ($order) | |
Sets the value for the SQL portion of the ORDER statement. | |
getOrder () | |
Gets the value of the SQL portion of ORDER. | |
other ($other) | |
Sets the value for the SQL portion of the OTHER statement. | |
getOther () | |
Gets the value of the SQL portion of OTHER. | |
refresh () | |
This method refreshes all of the Records stored in this TableDataSet. | |
setRefreshOnSave ($v) | |
Setting this causes each Record to refresh itself when a save() is performed on it. | |
refreshOnSave () | |
Setting this causes each Record to refresh itself when a save() is performed on it. | |
getSelectSql () | |
Builds the select string that was used to populate this TableDataSet. | |
Private Member Functions | |
buildSelectString () | |
Used by getSelectSql() to build the select string that was used to populate this TableDataSet. | |
Private Attributes | |
$tableName | |
Name of current table. | |
$tableInfo | |
TableInfo (metadata) object. | |
$optimisticLockingCol | |
the optimistic locking column value | |
$where | |
the value for the sql where clause | |
$order | |
the value for the sql order by clause | |
$other | |
the value for the sql other clause | |
$refreshOnSave = false | |
Whether to reload record values when save() is performed. |
Definition at line 39 of file TableDataSet.php.
TableDataSet::__construct | ( | Connection $ | conn, | |
$ | tableName, | |||
$ | p3 = null , |
|||
$ | p4 = null | |||
) |
Construct new TableDataSet instance.
Supports a few signatures:
Connection | $conn | |
string | $tableName | |
mixed | $p3 KeyDef or column list (string) | |
mixed | $p4 KeyDef or column list (string) |
Definition at line 75 of file TableDataSet.php.
References $tableName, and tableName().
00076 { 00077 $this->conn = $conn; 00078 $this->columns = "*"; 00079 $this->tableName = $tableName; 00080 00081 if ($p4 !== null) { 00082 $this->columns = $p3; 00083 $this->keyDef = $p4; 00084 } elseif ($p3 !== null) { 00085 if ($p3 instanceof KeyDef) { 00086 $this->keyDef = $p3; 00087 } else { // it's a string (column list) 00088 $this->columns = $p3; 00089 } 00090 } 00091 }
TableDataSet::addRecord | ( | ) |
Creates a new Record within this DataSet.
DataSetException | ||
SQLException |
Definition at line 138 of file TableDataSet.php.
00139 { 00140 $rec = new Record($this, true); 00141 $rec->markForInsert(); 00142 $this->records[] = $rec; 00143 return $rec; 00144 }
TableDataSet::buildSelectString | ( | ) | [private] |
Used by getSelectSql() to build the select string that was used to populate this TableDataSet.
DataSetException |
Definition at line 324 of file TableDataSet.php.
References order(), other(), tableName(), and where().
Referenced by fetchRecords().
00325 { 00326 $this->selectSql = "SELECT "; 00327 $this->selectSql .= $this->columns; 00328 $this->selectSql .= " FROM " . $this->tableName; 00329 if ($this->where !== null && $this->where !== "") { 00330 $this->selectSql .= " WHERE " . $this->where; 00331 } 00332 if ($this->order !== null && $this->order !== "") { 00333 $this->selectSql .= " ORDER BY " . $this->order; 00334 } 00335 if ($this->other !== null && $this->other !== "") { 00336 $this->selectSql .= $this->other; 00337 } 00338 }
TableDataSet::fetchRecords | ( | $ | p1 = 0 , |
|
$ | p2 = null | |||
) |
Fetch start to max records.
start is at Record 0
int | $start | |
int | $max |
SQLException | ||
DataSetException |
Reimplemented from DataSet.
Definition at line 125 of file TableDataSet.php.
References buildSelectString().
00126 { 00127 $this->buildSelectString(); 00128 return parent::fetchRecords($p1, $p2); 00129 }
TableDataSet::getOrder | ( | ) |
Gets the value of the SQL portion of ORDER.
Definition at line 243 of file TableDataSet.php.
References order().
00244 { 00245 return $this->order; 00246 }
TableDataSet::getOther | ( | ) |
Gets the value of the SQL portion of OTHER.
Definition at line 267 of file TableDataSet.php.
References other().
00268 { 00269 return $this->other; 00270 }
TableDataSet::getSelectSql | ( | ) |
Builds the select string that was used to populate this TableDataSet.
Reimplemented from DataSet.
Definition at line 312 of file TableDataSet.php.
TableDataSet::getWhere | ( | ) |
Gets the value of the SQL portion of WHERE.
Definition at line 219 of file TableDataSet.php.
References where().
00220 { 00221 return $this->where; 00222 }
TableDataSet::optimisticLockingCol | ( | ) |
Gets the table column used for optomistic locking.
Definition at line 196 of file TableDataSet.php.
Referenced by setOptimisticLockingColumn().
00197 { 00198 return $this->optimisticLockingCol; 00199 }
TableDataSet::order | ( | $ | order | ) |
Sets the value for the SQL portion of the ORDER statement.
DataSetException |
Definition at line 230 of file TableDataSet.php.
References $order.
Referenced by buildSelectString(), and getOrder().
00231 { 00232 if ($order === null) { 00233 throw new DataSetException("null not allowed for order clause"); 00234 } 00235 $this->order = $order; 00236 return $this; 00237 }
TableDataSet::other | ( | $ | other | ) |
Sets the value for the SQL portion of the OTHER statement.
string | $other |
DataSetException |
Definition at line 254 of file TableDataSet.php.
References $other.
Referenced by buildSelectString(), and getOther().
00255 { 00256 if ($other === null) { 00257 throw new DataSetException("null not allowed for other clause"); 00258 } 00259 $this->other = $other; 00260 return $this; 00261 }
TableDataSet::refresh | ( | ) |
This method refreshes all of the Records stored in this TableDataSet.
SQLException,DataSetException |
Definition at line 277 of file TableDataSet.php.
TableDataSet::refreshOnSave | ( | ) |
Setting this causes each Record to refresh itself when a save() is performed on it.
Default value is false.
Definition at line 303 of file TableDataSet.php.
Referenced by setRefreshOnSave().
00304 { 00305 return $this->refreshOnSave; 00306 }
TableDataSet::removeDeletedRecords | ( | ) |
Removes any records that are marked as a zombie.
DataSetException |
Definition at line 170 of file TableDataSet.php.
Referenced by save().
00171 { 00172 // this algorythm should be a fair bit 00173 // faster than calling DataSet::removeRecord() 00174 $new_recs = array(); 00175 foreach($this->records as $rec) { 00176 if (!$rec->isAZombie()) { 00177 $new_recs[] = $rec; 00178 } 00179 } 00180 $this->records = $new_recs; 00181 }
TableDataSet::save | ( | ) |
Saves all the records in the DataSet.
SQLException,DataSetException |
Definition at line 151 of file TableDataSet.php.
References removeDeletedRecords().
00152 { 00153 $j = 0; 00154 foreach($this->records as $rec) { 00155 $rec->save(); 00156 $j++; 00157 } 00158 // now go through and remove any records 00159 // that were previously marked as a zombie by the 00160 // delete process 00161 $this->removeDeletedRecords(); 00162 return $j; 00163 }
TableDataSet::setOptimisticLockingColumn | ( | $ | olc | ) |
Sets the table column used for optomistic locking.
string | $olc |
Definition at line 187 of file TableDataSet.php.
References optimisticLockingCol().
00188 { 00189 $this->optimisticLockingCol = $olc; 00190 }
TableDataSet::setRefreshOnSave | ( | $ | v | ) |
Setting this causes each Record to refresh itself when a save() is performed on it.
Default value is false.
boolean | $v |
Definition at line 291 of file TableDataSet.php.
References refreshOnSave().
00292 { 00293 $this->refreshOnSave = $v; 00294 }
TableDataSet::tableInfo | ( | ) |
Load the TableInfo (metadata) object for this table.
SQLException | if current conn doesn't know about $this->tableName |
Definition at line 108 of file TableDataSet.php.
References tableName().
00109 { 00110 if ($this->tableInfo === null) { 00111 $this->tableInfo = $this->conn->getDatabaseInfo()->getTable($this->tableName); 00112 } 00113 return $this->tableInfo; 00114 }
TableDataSet::tableName | ( | ) |
Gets the tableName defined in the schema.
DataSetException |
Definition at line 98 of file TableDataSet.php.
Referenced by __construct(), buildSelectString(), and tableInfo().
00099 { 00100 return $this->tableName; 00101 }
TableDataSet::where | ( | $ | where | ) |
Sets the value for the SQL portion of the WHERE statement.
DataSetException |
Definition at line 206 of file TableDataSet.php.
References $where.
Referenced by buildSelectString(), and getWhere().
00207 { 00208 if ($where == null) { 00209 throw new DataSetException("null not allowed for where clause"); 00210 } 00211 $this->where = $where; 00212 return $this; 00213 }
TableDataSet::$optimisticLockingCol [private] |
TableDataSet::$order [private] |
the value for the sql order by clause
Definition at line 54 of file TableDataSet.php.
Referenced by order().
TableDataSet::$other [private] |
the value for the sql other clause
Definition at line 57 of file TableDataSet.php.
Referenced by other().
TableDataSet::$refreshOnSave = false [private] |
Whether to reload record values when save() is performed.
Definition at line 60 of file TableDataSet.php.
TableDataSet::$tableInfo [private] |
TableDataSet::$tableName [private] |
TableDataSet::$where [private] |
the value for the sql where clause
Definition at line 51 of file TableDataSet.php.
Referenced by where().