Exemple #1
0
 /**
  * rollbackSavePoint
  * releases given savepoint
  *
  * @param string $savepoint     name of a savepoint to rollback to
  * @return void
  */
 public function rollbackSavepoint($savepoint)
 {
     if (!$this->_platform->supportsSavepoints()) {
         throw ConnectionException::savepointsNotSupported();
     }
     $this->_conn->exec($this->_platform->rollbackSavePoint($savepoint));
 }
 /**
  * @return string
  */
 private function getCurrentVersion()
 {
     /** @var $result Statement */
     $result = $this->db->query('SELECT version FROM schema');
     $version = $result->fetchColumn();
     if (!$version) {
         $version = '0';
         $this->db->exec("INSERT INTO schema VALUES ('{$version}')");
     }
     return $version;
 }
 /**
  * Link files to the ORM product values.
  *
  * @param string $productValueTable
  * @param string $productMediaTable
  * @param string $fkMedia
  */
 protected function migrateMediasOnProductValueOrm($productValueTable, $productMediaTable, $fkMedia)
 {
     $this->output->writeln(sprintf('Adding temporary fields to table <comment>%s</comment>...', $productValueTable));
     $this->ormConnection->exec(sprintf('ALTER TABLE %s ADD new_media_id INT(11) NULL DEFAULT NULL AFTER media_id, ADD INDEX (new_media_id)', $productValueTable));
     // associate the "new" media ID to the product value
     //
     // UPDATE pim_catalog_product_value pv
     // LEFT JOIN pim_catalog_product_media pm ON pv.media_id = pm.id
     // LEFT JOIN akeneo_file_storage_file_info fi ON fi.old_file_key = pm.filename
     // SET pv.new_media_id=fi.id
     // WHERE pv.media_id IS NOT NULL
     $this->ormConnection->exec(sprintf('UPDATE %s pv
         LEFT JOIN %s pm ON pv.media_id = pm.id
         LEFT JOIN akeneo_file_storage_file_info fi ON fi.old_file_key = pm.filename
         SET pv.new_media_id=fi.id
         WHERE pv.media_id IS NOT NULL', $productValueTable, $productMediaTable));
     $this->output->writeln(sprintf('Cleaning temporary fields to table <comment>%s</comment>...', $productValueTable));
     $this->ormConnection->exec(sprintf('ALTER TABLE %s DROP FOREIGN KEY %s', $productValueTable, $fkMedia));
     $this->ormConnection->exec(sprintf('ALTER TABLE %s DROP media_id', $productValueTable));
     $this->ormConnection->exec(sprintf('ALTER TABLE %s CHANGE new_media_id media_id INT(11) NULL DEFAULT NULL, ADD INDEX (media_id)', $productValueTable));
     $this->ormConnection->exec(sprintf('ALTER TABLE %s ADD FOREIGN KEY (media_id) REFERENCES akeneo_file_storage_file_info(id) ON DELETE SET NULL ON UPDATE RESTRICT', $productValueTable));
     $this->ormConnection->exec(sprintf('DROP INDEX new_media_id ON %s', $productValueTable));
 }
Exemple #4
0
 /**
  * Execute an SQL statement and return the number of affected rows.
  * 
  * @param string $statement
  * @return integer The number of affected rows.
  */
 public function exec($statement)
 {
     $this->connect();
     return $this->_conn->exec($statement);
 }
 /**
  * Creates a new session with the given $id and $data
  *
  * @param string $id
  * @param string $data
  *
  * @return Boolean
  */
 private function createNewSession($id, $data = '')
 {
     $this->con->exec(sprintf("INSERT INTO {$this->tableName} (sess_id, sess_data, sess_time) VALUES (%s, %s, %d)", $this->con->quote($id), $this->con->quote(base64_encode($data)), time()));
     return true;
 }
 /**
  * Remove old media table
  *
  * @param string $productMediaTable
  */
 public function dropFormerMediaTable($productMediaTable)
 {
     $this->writeConsole(sprintf('Dropping table <comment>%s</comment>...', $productMediaTable));
     $this->ormConnection->exec(sprintf('DROP TABLE %s', $productMediaTable));
 }