Exemplo n.º 1
0
 /**
  * This method is called after a connection was created to run necessary
  * post-initialization queries or code.
  * Removes the charset query and adds the date queries
  *
  * @see parent::initConnection()
  *
  * @param \PDO  $con
  * @param array $settings
  */
 public function initConnection(ConnectionInterface $con, array $settings)
 {
     $con->exec("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'");
     $con->exec("ALTER SESSION SET NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SS'");
     if (isset($settings['queries']) && is_array($settings['queries'])) {
         foreach ($settings['queries'] as $queries) {
             foreach ((array) $queries as $query) {
                 $con->exec($query);
             }
         }
     }
 }
 /**
  * Execute an SQL statement and return the number of affected rows.
  * Overrides PDO::exec() to log queries when required
  *
  * @param  string  $sql
  * @return integer
  */
 public function exec($sql)
 {
     $return = $this->connection->exec($sql);
     if ($this->useDebug) {
         $this->log($sql);
         $this->setLastExecutedQuery($sql);
         $this->incrementQueryCount();
     }
     return $return;
 }
Exemplo n.º 3
0
 /**
  * Sets the character encoding using SQL standard SET NAMES statement.
  *
  * This method is invoked from the default initConnection() method and must
  * be overridden for an RDMBS which does _not_ support this SQL standard.
  *
  * @see initConnection()
  *
  * @param ConnectionInterface $con
  * @param string              $charset The $string charset encoding.
  */
 public function setCharset(ConnectionInterface $con, $charset)
 {
     $con->exec(sprintf("SET NAMES '%s'", $charset));
 }
Exemplo n.º 4
0
 protected function tearDown()
 {
     parent::tearDown();
     $this->con->exec("SET FOREIGN_KEY_CHECKS = 1;");
     $this->con->rollback();
 }
Exemplo n.º 5
0
 /**
  * Sets the character encoding using SQL standard SET NAMES statement.
  *
  * This method is invoked from the default initConnection() method and must
  * be overridden for an RDMBS which does _not_ support this SQL standard.
  *
  * @see       initConnection()
  *
  * @param     Propel\Runtime\Connection\ConnectionInterface $con
  * @param     string  $charset  The $string charset encoding.
  */
 public function setCharset(ConnectionInterface $con, $charset)
 {
     $con->exec("SET NAMES '" . $charset . "'");
 }
 /**
  * Unlocks the specified table.
  *
  * @param ConnectionInterface $con   The Propel connection to use.
  * @param string              $table The name of the table to unlock.
  *
  * @throws \PDOException No Statement could be created or executed.
  */
 public function unlockTable($con, $table)
 {
     $con->exec('UNLOCK TABLES');
 }
Exemplo n.º 7
0
 /**
  * @param \Spryker\Zed\Collector\Business\Exporter\Writer\Storage\TouchUpdaterSet $touchUpdaterSet
  * @param int $idLocale
  * @param \Propel\Runtime\Connection\ConnectionInterface|null $connection
  *
  * @return void
  */
 public function bulkDelete(TouchUpdaterSet $touchUpdaterSet, $idLocale, ConnectionInterface $connection = null)
 {
     $idsToDelete = [];
     foreach ($touchUpdaterSet->getData() as $key => $touchData) {
         $idTouch = $touchData[CollectorConfig::COLLECTOR_TOUCH_ID];
         if ($idTouch !== null) {
             $idsToDelete[$idTouch] = $idTouch;
         }
     }
     if (!empty($idsToDelete) && $connection !== null) {
         $sql = $this->bulkTouchDeleteQuery->addQuery($this->touchKeyTableName, static::FK_TOUCH, $idsToDelete)->getRawSqlString();
         $this->bulkTouchDeleteQuery->flushQueries();
         $connection->exec($sql);
     }
 }
Exemplo n.º 8
0
 /**
  * Unlocks the specified table.
  *
  * @param     ConnectionInterface $con  The Propel connection to use.
  * @param     string  $table  The name of the table to unlock.
  *
  * @throws    \PDOException  No Statement could be created or executed.
  */
 public function unlockTable($con, $table)
 {
     $statement = $con->exec("UNLOCK TABLES");
 }