/**
  * order orderdir, offset, limit
  */
 public function getResultByDelivery($delivery, $options = array())
 {
     $returnValue = array();
     $sql = 'SELECT * FROM ' . self::RESULTS_TABLENAME;
     $params = array();
     if (count($delivery) > 0) {
         $sql .= ' WHERE ';
         $inQuery = implode(',', array_fill(0, count($delivery), '?'));
         $sql .= self::DELIVERY_COLUMN . ' IN (' . $inQuery . ')';
         $params = array_merge($params, $delivery);
     }
     if (isset($options['order'])) {
         $sql .= ' ORDER BY ?';
         $params[] = $options['order'];
         if (isset($options['oderdir']) && (strtolower($options['orderdir']) === 'asc' || strtolower($options['orderdir']) === 'desc')) {
             $sql .= ' ?';
             $params[] = $options['orderdir'];
         }
     }
     if (isset($options['offset']) || isset($options['limit'])) {
         $offset = isset($options['offset']) ? $options['offset'] : 0;
         $limit = isset($options['limit']) ? $options['limit'] : 1000;
         $this->persistence->getPlatForm()->limitStatement($sql, $limit, $offset);
     }
     $results = $this->persistence->query($sql, $params);
     foreach ($results as $value) {
         $returnValue[] = array("deliveryResultIdentifier" => $value[self::RESULTS_TABLE_ID], "testTakerIdentifier" => $value[self::TEST_TAKER_COLUMN], "deliveryIdentifier" => $value[self::DELIVERY_COLUMN]);
     }
     return $returnValue;
 }
 /**
  * 
  * @author "Lionel Lecaque, <*****@*****.**>"
  * @param string $id
  * @throws common_Exception
  * @return boolean
  */
 public function exists($id)
 {
     try {
         $statement = 'SELECT kv_value FROM kv_store WHERE kv_id = ?';
         $statement = $this->sqlPeristence->getPlatForm()->limitStatement($statement, 1);
         $sessionValue = $this->sqlPeristence->query($statement, array($id));
         return $sessionValue->fetch() !== false;
     } catch (Exception $e) {
         throw new common_Exception("Unable to read value from key value storage");
     }
 }
 /**
  * Loads the next n results, starting with $offset
  * 
  * @param int $offset
  */
 protected function load($offset)
 {
     $query = $this->persistence->getPlatForm()->limitStatement($this->query, self::CACHE_SIZE, $offset);
     $result = $this->persistence->query($query, $this->params);
     $this->cache = array();
     $pos = $offset;
     while ($statement = $result->fetch()) {
         $this->cache[$pos++] = $statement;
     }
     $this->currentResult = $offset;
 }
 /**
  * 
  * @param Revision $revision
  * @param array $data
  * @return boolean
  */
 protected function saveData(RdsRevision $revision, $data)
 {
     $columns = array(self::DATA_REVISION, self::DATA_SUBJECT, self::DATA_PREDICATE, self::DATA_OBJECT, self::DATA_LANGUAGE);
     $multipleInsertQueryHelper = $this->persistence->getPlatForm()->getMultipleInsertsSqlQueryHelper();
     $query = $multipleInsertQueryHelper->getFirstStaticPart(self::DATA_TABLE_NAME, $columns);
     foreach ($data as $triple) {
         $query .= $multipleInsertQueryHelper->getValuePart(self::DATA_TABLE_NAME, $columns, array(self::DATA_REVISION => $this->persistence->quote($revision->getId()), self::DATA_SUBJECT => $this->persistence->quote($triple->subject), self::DATA_PREDICATE => $this->persistence->quote($triple->predicate), self::DATA_OBJECT => $this->persistence->quote($triple->object), self::DATA_LANGUAGE => $this->persistence->quote($triple->lg)));
     }
     $query = substr($query, 0, strlen($query) - 1);
     $query .= $multipleInsertQueryHelper->getEndStaticPart();
     $success = $this->persistence->exec($query);
     return $success;
 }
 public function quoteIdentifier($parameter)
 {
     return $this->persistence->getPlatForm()->quoteIdentifier($parameter);
 }