public function __construct(SimDAL_Mapper_Entity $entity, $class, $data) { $this->_entity = $entity; $this->_parentKey = isset($data['parentKey']) ? $data['parentKey'] : ''; $this->_foreignKey = isset($data['foreignKey']) ? $data['foreignKey'] : ''; if (!isset($data['type'])) { throw new Exception("Descendent type not given"); } $this->_type = $data['type']; parent::__construct($class, $data, $entity->getMapper()); $this->_processClass($data); }
public function __construct(SimDAL_Mapper_Entity $entity, $property, $fieldname, $datatype, $primarykey = false, $autoincrement = false, $alias = null) { $this->_entity = $entity; $this->_class = $entity->getClass(); $this->_table = $entity->getTable(); $this->_schema = $this->getSchema(); $this->_property = $property; $this->_fieldName = $fieldname; $this->_dataType = $datatype; $this->_primaryKey = $primarykey; $this->_autoIncrement = $autoincrement; $this->_alias = $alias; }
protected function _arrayForStorageFromEntity(SimDAL_Mapper_Entity $mapping, $entity, $includeNull = false, $transformData = false) { $array = array(); /* @var SimDAL_Mapper_Column */ foreach ($mapping->getColumns() as $key => $column) { if ($column->isPrimaryKey() && $column->isAutoIncrement()) { continue; } $method = 'get' . ucfirst($column->getProperty()); if (!method_exists($entity, $method)) { continue; } if (!$includeNull && is_null($entity->{$method}())) { continue; } if ($transformData) { $array[$column->getColumn()] = $this->transformData($column, $entity->{$method}(), $mapping); } else { $array[$column->getColumn()] = $entity->{$method}(); } } return $array; }
protected static function _generateProxyMethods(SimDAL_Mapper_Entity $mapping) { $associations = $mapping->getAssociations(); $methods = ''; /* @var $association SimDAL_Mapper_Association */ if (count($associations)) { foreach ($associations as $association) { switch ($association->getType()) { case 'one-to-many': $methods .= self::_generateProxyMethodForOneToManyAssociation($association, $mapping); break; case 'one-to-one': $methods .= self::_generateProxyMethodForOneToOneAssociation($association, $mapping); break; case 'many-to-one': $methods .= self::_generateProxyMethodForManyToOneAssociation($association, $mapping); break; } } } return $methods; }
public function getClass() { return $this->_from->getClass(); }
public function getLeftValue() { return $this->_entity->getPrimaryKeyColumn(); }
public function getRightValue() { return new SimDAL_Query_Where_Column($this->_entity->getTable(), $this->_entity->getColumn($this->_descendant->getParentKey())); }
protected function _processInsertQuery(SimDAL_Mapper_Entity $mapping, $data) { $sql = "INSERT INTO " . $this->_quoteIdentifier($mapping->getTable()) . " (" . implode(',', array_keys($data)) . ") VALUES (" . implode(',', $data) . ")"; return $sql; }
protected function _processInsertQuery(SimDAL_Mapper_Entity $mapping, $data) { $sql = "INSERT INTO " . $this->_quoteIdentifier($mapping->getTable()) . " ('" . implode('\',\'', array_keys($data)) . "') VALUES ("; foreach ($data as $key => $value) { $sql .= ':' . $key . ','; } $sql = substr($sql, 0, -1) . ')'; $stmt = $this->_conn->prepare($sql); foreach ($data as $key => $value) { $stmt->bindParam(':' . $key, $value); } return $stmt; }