Пример #1
0
 /**
  * @throws \Doctrine\DBAL\DBALException
  */
 public function updateCount()
 {
     $sql = 'UPDATE tags
         SET tags.count = (
             SELECT COUNT(review_tag.tag_id)
             FROM review_tag
             WHERE review_tag.tag_id = tags.id
             GROUP BY review_tag.tag_id
         )';
     $this->connection->executeQuery($sql);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function read($id)
 {
     try {
         $data = $this->con->executeQuery("SELECT data FROM {$this->tableName} WHERE id = :id", array('id' => $id))->fetchColumn();
         if (false !== $data) {
             return base64_decode($data);
         }
         // session does not exist, create it
         $this->createNewSession($id);
         return '';
     } catch (\PDOException $e) {
         throw new \RuntimeException(sprintf('PDOException was thrown when trying to read the session data: %s', $e->getMessage()), 0, $e);
     }
 }
 /**
  * {@inheritDoc}
  */
 protected function batchInsertPendingVersions(array $pendingVersions)
 {
     if (count($pendingVersions) === 0) {
         return;
     }
     $versionTable = $this->getVersionTable();
     $insert = sprintf('INSERT INTO %s ', $versionTable);
     $columns = $this->getVersionColumns();
     $placeholders = sprintf('(%s)', implode(',', array_fill(0, count($columns), '?')));
     $multiplePlaceholders = array_fill(0, count($pendingVersions), $placeholders);
     $params = [];
     foreach ($pendingVersions as $pendingVersion) {
         $params = array_merge($params, $this->getSQLParamsFromVersion($pendingVersion));
     }
     $values = implode(',', $multiplePlaceholders);
     $query = sprintf('%s(%s) VALUES %s', $insert, implode(',', $columns), $values);
     $this->connection->executeQuery($query, $params);
 }