Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  * @see \Fixin\Model\Storage\Grammar\GrammarInterface::insertMultiple($repository, $rows)
  */
 public function insertMultiple(RepositoryInterface $repository, array $rows) : QueryInterface
 {
     $query = $this->container->clonePrototype(static::PROTOTYPE_QUERY)->appendWord(static::STATEMENT_INSERT)->appendClause(static::CLAUSE_INTO, $this->quoteIdentifier($repository->getName()));
     $columnNames = [];
     foreach (array_keys(reset($rows)) as $identifier) {
         $columnNames[] = $this->identifierToString($identifier, $query);
     }
     $query->appendString(sprintf(static::MASK_COLUMN_NAMES, implode(static::LIST_SEPARATOR, $columnNames)));
     $source = [];
     foreach ($rows as $set) {
         $values = [];
         foreach ($set as $value) {
             $values[] = $this->expressionToString($value, $query);
         }
         $source[] = sprintf(static::MASK_VALUES, implode(static::LIST_SEPARATOR, $values));
     }
     return $query->appendClause(static::CLAUSE_VALUES, implode(static::LIST_SEPARATOR_MULTI_LINE, $source));
 }
Exemplo n.º 2
0
 /**
  * Set repository
  *
  * @param RepositoryInterface $repository
  */
 protected function setRepository(RepositoryInterface $repository)
 {
     $this->repository = $repository;
     $this->primaryKeyFlipped = array_flip($repository->getPrimaryKey());
 }
Exemplo n.º 3
0
 /**
  * {@inheritDoc}
  * @see \Fixin\Model\Request\RequestInterface::getAlias()
  */
 public function getAlias() : string
 {
     return $this->alias ?? ($this->alias = $this->repository->getName());
 }