/** * @return \Doctrine\DBAL\Platforms\AbstractPlatform */ private function getTargetPlatform() { if (!$this->targetPlatform) { $this->targetPlatform = $this->em->getConnection()->getDatabasePlatform(); } return $this->targetPlatform; }
/** * @param object $entity * @return int * @throws \Doctrine\ORM\Mapping\MappingException */ public function update($entity) { $identifiers = []; $types = ['id' => \PDO::PARAM_INT]; foreach ($this->metaData->getIdentifierColumnNames() as $columnName) { $fieldName = $this->metaData->getFieldForColumn($columnName); $value = $this->metaData->getFieldValue($entity, $fieldName); $identifiers[$columnName] = $value; } $updateSet = []; foreach ($this->metaData->getColumnNames() as $columnName) { if (isset($identifiers[$columnName])) { continue; } $fieldName = $this->metaData->getFieldForColumn($columnName); $typeName = $this->metaData->getTypeOfColumn($fieldName); $type = \Doctrine\DBAL\Types\Type::getType($typeName); $value = $type->convertToDatabaseValue($entity->{$fieldName}, $this->em->getConnection()->getDatabasePlatform()); $types[$columnName] = $type->getBindingType(); $updateSet[$columnName] = $value; } return $this->em->getConnection()->update($this->metaData->getTableName(), $updateSet, $identifiers, $types); }
/** * @param int $limit * @return RepositoryPaginator */ public function getPagination($limit = 100) { return new RepositoryPaginator($this->em->createQueryBuilder()->select('*')->from($this->metaData->getTableName()), $this, $limit); }