26 #require_once 'Zend/Db.php'; 117 $this->_table =
$config[
'table'];
118 $this->_tableClass = get_class($this->_table);
119 }
elseif ($this->_tableClass !==
null) {
124 if (!is_array(
$config[
'data'])) {
125 #require_once 'Zend/Db/Table/Row/Exception.php'; 128 $this->_data =
$config[
'data'];
141 $this->_primary = (array)
$info[
'primary'];
159 if (!is_string($columnName)) {
160 #require_once 'Zend/Db/Table/Row/Exception.php'; 177 if (!array_key_exists($columnName, $this->_data)) {
178 #require_once 'Zend/Db/Table/Row/Exception.php'; 181 return $this->_data[$columnName];
195 if (!array_key_exists($columnName, $this->_data)) {
196 #require_once 'Zend/Db/Table/Row/Exception.php'; 199 $this->_data[$columnName] =
$value;
200 $this->_modifiedFields[$columnName] =
true;
213 if (!array_key_exists($columnName, $this->_data)) {
214 #require_once 'Zend/Db/Table/Row/Exception.php'; 217 if ($this->
isConnected() && in_array($columnName, $this->_table->info(
'primary'))) {
218 #require_once 'Zend/Db/Table/Row/Exception.php'; 221 unset($this->_data[$columnName]);
234 return array_key_exists($columnName, $this->_data);
244 return array(
'_tableClass',
'_primary',
'_data',
'_cleanData',
'_readOnly' ,
'_modifiedFields');
256 $this->_connected =
false;
268 return $this->
__isset($offset);
280 return $this->
__get($offset);
303 return $this->
__unset($offset);
338 $this->_table =
null;
339 $this->_connected =
false;
343 $tableClass = get_class(
$table);
344 if (!
$table instanceof $this->_tableClass) {
345 #require_once 'Zend/Db/Table/Row/Exception.php'; 346 throw new Zend_Db_Table_Row_Exception(
"The specified Table is of class $tableClass, expecting class to be instance of $this->_tableClass");
350 $this->_tableClass = $tableClass;
352 $info = $this->_table->info();
354 if (
$info[
'cols'] != array_keys($this->_data)) {
355 #require_once 'Zend/Db/Table/Row/Exception.php'; 359 if (! array_intersect((array) $this->_primary,
$info[
'primary']) == (array) $this->_primary) {
361 #require_once 'Zend/Db/Table/Row/Exception.php'; 365 $this->_connected =
true;
408 $this->_readOnly = (bool) $flag;
437 if (empty($this->_cleanData)) {
453 if ($this->_readOnly ===
true) {
454 #require_once 'Zend/Db/Table/Row/Exception.php'; 466 $data = array_intersect_key($this->_data, $this->_modifiedFields);
473 if (is_array($primaryKey)) {
474 $newPrimaryKey = $primaryKey;
477 $tempPrimaryKey = (array) $this->_primary;
478 $newPrimaryKey = array(current($tempPrimaryKey) => $primaryKey);
487 $this->_data = array_merge($this->_data, $newPrimaryKey);
511 if ($this->_readOnly ===
true) {
512 #require_once 'Zend/Db/Table/Row/Exception.php'; 531 $diffData = array_intersect_key($this->_data, $this->_modifiedFields);
536 $pkDiffData = array_intersect_key($diffData, array_flip((array)$this->_primary));
542 if (count($pkDiffData) > 0) {
543 $depTables = $this->
_getTable()->getDependentTables();
544 if (!empty($depTables)) {
547 foreach ($depTables as $tableClass) {
560 if (count($diffData) > 0) {
561 $this->
_getTable()->update($diffData, $where);
583 if (count($primaryKey) == 1) {
584 return current($primaryKey);
595 public function delete()
600 if ($this->_readOnly ===
true) {
601 #require_once 'Zend/Db/Table/Row/Exception.php'; 615 $depTables = $this->
_getTable()->getDependentTables();
616 if (!empty($depTables)) {
618 foreach ($depTables as $tableClass) {
637 $this->_data = array_combine(
638 array_keys($this->_data),
639 array_fill(0, count($this->_data),
null)
647 return new ArrayIterator((array) $this->_data);
668 $data = array_intersect_key(
$data, $this->_data);
694 if (!$this->_connected) {
695 #require_once 'Zend/Db/Table/Row/Exception.php'; 709 if (!is_array($this->_primary)) {
710 #require_once 'Zend/Db/Table/Row/Exception.php'; 714 $primary = array_flip($this->_primary);
716 $array = array_intersect_key($this->_data, $primary);
718 $array = array_intersect_key($this->_cleanData, $primary);
720 if (count($primary) != count($array)) {
721 #require_once 'Zend/Db/Table/Row/Exception.php'; 754 foreach ($primaryKey as $column =>
$value) {
756 $type = $metadata[$column][
'DATA_TYPE'];
757 $columnName = $db->quoteIdentifier($column,
true);
758 $where[] = $db->quoteInto(
"{$tableName}.{$columnName} = ?",
$value,
$type);
774 #require_once 'Zend/Db/Table/Row/Exception.php'; 778 $this->_data =
$row->toArray();
780 $this->_modifiedFields = array();
855 $parentTableName = (get_class($parentTable) ===
'Zend_Db_Table') ? $parentTable->
getDefinitionConfigName() : get_class($parentTable);
859 $parentInfo = $parentTable->
info();
882 if (is_string($dependentTable)) {
887 $type = gettype($dependentTable);
888 if (
$type ==
'object') {
889 $type = get_class($dependentTable);
891 #require_once 'Zend/Db/Table/Row/Exception.php'; 897 if (($tableDefinition = $this->_table->getDefinition()) !==
null 898 && ($dependentTable->getDefinition() ==
null)) {
903 $select = $dependentTable->select();
905 $select->setTable($dependentTable);
912 $value = $this->_data[$parentColumnName];
914 $dependentDb = $dependentTable->getAdapter();
916 $dependentColumn = $dependentDb->quoteIdentifier($dependentColumnName,
true);
917 $dependentInfo = $dependentTable->info();
922 return $dependentTable->fetchAll(
$select);
938 if (is_string($parentTable)) {
943 $type = gettype($parentTable);
944 if (
$type ==
'object') {
945 $type = get_class($parentTable);
947 #require_once 'Zend/Db/Table/Row/Exception.php'; 953 if (($tableDefinition = $this->_table->getDefinition()) !==
null 954 && ($parentTable->getDefinition() ==
null)) {
959 $select = $parentTable->select();
961 $select->setTable($parentTable);
969 $value = $this->_data[$dependentColumnName];
971 $parentDb = $parentTable->getAdapter();
973 $parentColumn = $parentDb->quoteIdentifier($parentColumnName,
true);
974 $parentInfo = $parentTable->info();
979 if (
$value ===
null && $nullable ==
true) {
980 $select->where(
"$parentColumn IS NULL");
989 return $parentTable->fetchRow(
$select);
1006 if (is_string($intersectionTable)) {
1011 $type = gettype($intersectionTable);
1012 if (
$type ==
'object') {
1013 $type = get_class($intersectionTable);
1015 #require_once 'Zend/Db/Table/Row/Exception.php'; 1021 if (($tableDefinition = $this->_table->getDefinition()) !==
null 1022 && ($intersectionTable->getDefinition() ==
null)) {
1026 if (is_string($matchTable)) {
1031 $type = gettype($matchTable);
1032 if (
$type ==
'object') {
1033 $type = get_class($matchTable);
1035 #require_once 'Zend/Db/Table/Row/Exception.php'; 1041 if (($tableDefinition = $this->_table->getDefinition()) !==
null 1042 && ($matchTable->getDefinition() ==
null)) {
1047 $select = $matchTable->select();
1049 $select->setTable($matchTable);
1053 $interInfo = $intersectionTable->info();
1054 $interDb = $intersectionTable->getAdapter();
1055 $interName = $interInfo[
'name'];
1056 $interSchema = isset($interInfo[
'schema']) ? $interInfo[
'schema'] :
null;
1057 $matchInfo = $matchTable->info();
1058 $matchName = $matchInfo[
'name'];
1059 $matchSchema = isset($matchInfo[
'schema']) ? $matchInfo[
'schema'] :
null;
1061 $matchMap = $this->
_prepareReference($intersectionTable, $matchTable, $matchRefRule);
1066 $joinCond[] =
"$interCol = $matchCol";
1068 $joinCond = implode(
' AND ', $joinCond);
1070 $select->from(array(
'i' => $interName), array(), $interSchema)
1072 ->setIntegrityCheck(
false);
1078 $value = $this->_data[$callerColumnName];
1080 $interCol = $interDb->quoteIdentifier(
"i.$interColumnName",
true);
1081 $interInfo = $intersectionTable->info();
1089 'table' => $matchTable,
1091 'rowClass' => $matchTable->getRowClass(),
1092 'readOnly' =>
false,
1096 $rowsetClass = $matchTable->getRowsetClass();
1099 #require_once 'Zend/Loader.php'; 1102 #require_once 'Zend/Db/Table/Row/Exception.php'; 1106 $rowset =
new $rowsetClass(
$config);
1135 if (preg_match(
'/^findParent(\w+?)(?:By(\w+))?$/',
$method, $matches)) {
1137 $ruleKey1 = isset($matches[2]) ? $matches[2] :
null;
1148 if (preg_match(
'/^find(\w+?)Via(\w+?)(?:By(\w+?)(?:And(\w+))?)?$/',
$method, $matches)) {
1150 $viaClass = $matches[2];
1151 $ruleKey1 = isset($matches[3]) ? $matches[3] :
null;
1152 $ruleKey2 = isset($matches[4]) ? $matches[4] :
null;
1162 if (preg_match(
'/^find(\w+?)(?:By(\w+))?$/',
$method, $matches)) {
1164 $ruleKey1 = isset($matches[2]) ? $matches[2] :
null;
1168 #require_once 'Zend/Db/Table/Row/Exception.php'; _prepareReference(Zend_Db_Table_Abstract $dependentTable, Zend_Db_Table_Abstract $parentTable, $ruleKey)
getReference($tableClassname, $ruleKey=null)
elseif(isset( $params[ 'redirect_parent']))
static loadClass($class, $dirs=null)
getPrimaryKey($useDirty=true)
_getPrimaryKey($useDirty=true)
findDependentRowset($dependentTable, $ruleKey=null, Zend_Db_Table_Select $select=null)
getDefinitionConfigName()
findParentRow($parentTable, $ruleKey=null, Zend_Db_Table_Select $select=null)
_transformColumn($columnName)
$_option $_optionId $class
setTable(Zend_Db_Table_Abstract $table=null)
_getWhereQuery($useDirty=true)
findManyToManyRowset($matchTable, $intersectionTable, $callerRefRule=null, $matchRefRule=null, Zend_Db_Table_Select $select=null)
setFromArray(array $data)
__construct(array $config=array())
foreach( $_productCollection as $_product)() ?>" class $info
__call($method, array $args)
_getTableFromString($tableName)
__set($columnName, $value)
static getTableFromString($tableName, Zend_Db_Table_Abstract $referenceTable=null)
offsetSet($offset, $value)