Exemplo n.º 1
0
 /**
  * @param SqlInterface $query
  * @return void
  */
 public function execute(SqlInterface $query)
 {
     $platform = new Platform($this->adapter);
     $platform->setSubject($query);
     if (defined('ANELEGAN_DB_DEBUG') && ANELEGAN_DB_DEBUG) {
         $this->console->writeLine(PHP_EOL . $platform->getSqlString($this->adapter->getPlatform()) . PHP_EOL);
     } else {
         $this->adapter->query($platform->getSqlString(), Adapter::QUERY_MODE_EXECUTE);
     }
 }
 /**
  * @param SqlInterface $query
  * @return void
  */
 public function execute(SqlInterface $query)
 {
     $time = microtime(true);
     $adapterPlatform = $this->adapter->getPlatform();
     if ($query instanceof ZendCreateTable) {
         $this->console->write('    > create table ' . $adapterPlatform->quoteIdentifier($query->getRawState(ZendCreateTable::TABLE)) . '...');
     } elseif ($query instanceof ZendAlterTable) {
         $this->console->write('    > alter table ' . $adapterPlatform->quoteIdentifier($query->getRawState(ZendAlterTable::TABLE)) . '...');
     } elseif ($query instanceof TruncateTable) {
         $this->console->write('    > truncate table ' . $adapterPlatform->quoteIdentifier($query->getRawState(TruncateTable::TABLE)) . '...');
     } elseif ($query instanceof DropTable) {
         $this->console->write('    > drop table ' . $adapterPlatform->quoteIdentifier($query->getRawState(DropTable::TABLE)) . '...');
     } elseif ($query instanceof Insert) {
         $this->console->write('    > insert into ' . $adapterPlatform->quoteIdentifier($query->getRawState('table')) . '...');
     } elseif ($query instanceof Update) {
         $this->console->write('    > update table ' . $adapterPlatform->quoteIdentifier($query->getRawState('table')) . '...');
     } elseif ($query instanceof Delete) {
         $this->console->write('    > delete from ' . $adapterPlatform->quoteIdentifier($query->getRawState('table')) . '...');
     } else {
         throw new InvalidArgumentException(sprintf('Parameter of a method %s must be a executable Sql statement that modifies a table.', __METHOD__));
     }
     $platform = new Platform($this->adapter);
     $platform->setSubject($query);
     if (defined('ANELEGAN_DB_DEBUG') && ANELEGAN_DB_DEBUG) {
         $this->console->write(PHP_EOL . $platform->getSqlString($this->adapter->getPlatform()) . PHP_EOL);
     } else {
         $this->adapter->query($platform->getSqlString(), Adapter::QUERY_MODE_EXECUTE);
     }
     $this->console->writeLine(' done (time: ' . sprintf('%.3f', microtime(true) - $time) . 's)');
 }