/**
  * Remove the result and all the related variables
  * @param $deliveryResultIdentifier
  * @return bool
  */
 public function deleteResult($deliveryResultIdentifier)
 {
     // get all the variables related to the result
     $sql = 'SELECT ' . self::VARIABLES_TABLE_ID . ' FROM ' . self::VARIABLES_TABLENAME . '
     WHERE ' . self::VARIABLES_FK_COLUMN . ' = ?';
     $variables = $this->persistence->query($sql, array($deliveryResultIdentifier));
     // delete key/value for each variable
     foreach ($variables as $variable) {
         $sql = 'DELETE FROM ' . self::RESULT_KEY_VALUE_TABLE_NAME . '
         WHERE ' . self::RESULTSKV_FK_COLUMN . ' = ?';
         if ($this->persistence->exec($sql, array($variable[self::VARIABLES_TABLE_ID])) === false) {
             return false;
         }
     }
     // remove variables
     $sql = 'DELETE FROM ' . self::VARIABLES_TABLENAME . '
         WHERE ' . self::VARIABLES_FK_COLUMN . ' = ?';
     if ($this->persistence->exec($sql, array($deliveryResultIdentifier)) === false) {
         return false;
     }
     // remove results
     $sql = 'DELETE FROM ' . self::RESULTS_TABLENAME . '
         WHERE ' . self::RESULTS_TABLE_ID . ' = ?';
     if ($this->persistence->exec($sql, array($deliveryResultIdentifier)) === false) {
         return false;
     }
     return true;
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 /**
  * 
  * @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");
     }
 }
 public function countResultByDelivery($delivery)
 {
     $sql = 'SELECT COUNT(*) 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);
     }
     return $this->persistence->query($sql, $params)->fetchColumn();
 }
예제 #5
0
 /**
  * Loads the next n triples, startign with $id
  * 
  * @param int $id
  */
 protected function load($id)
 {
     $query = 'SELECT * FROM statements WHERE id > ? ' . (is_null($this->modelIds) ? '' : 'AND modelid IN (' . implode(',', $this->modelIds) . ') ') . 'ORDER BY id LIMIT ?';
     $result = $this->persistence->query($query, array($id, self::CACHE_SIZE));
     $this->cache = array();
     while ($statement = $result->fetch()) {
         $triple = new core_kernel_classes_Triple();
         $triple->modelid = $statement["modelid"];
         $triple->subject = $statement["subject"];
         $triple->predicate = $statement["predicate"];
         $triple->object = $statement["object"];
         $triple->id = $statement["id"];
         $triple->lg = $statement["l_language"];
         $this->cache[] = $triple;
     }
     $this->currentTriple = 0;
 }
예제 #6
0
 public function getData(RdsRevision $revision)
 {
     $localModel = \common_ext_NamespaceManager::singleton()->getLocalNamespace();
     // retrieve data
     $query = 'SELECT * FROM ' . self::DATA_TABLE_NAME . ' WHERE ' . self::DATA_REVISION . ' = ?';
     $result = $this->persistence->query($query, array($revision->getId()));
     $triples = array();
     while ($statement = $result->fetch()) {
         $triple = new \core_kernel_classes_Triple();
         $triple->modelid = $localModel->getModelId();
         $triple->subject = $statement[self::DATA_SUBJECT];
         $triple->predicate = $statement[self::DATA_PREDICATE];
         $triple->object = $statement[self::DATA_OBJECT];
         $triple->lg = $statement[self::DATA_LANGUAGE];
         $triples[] = $triple;
     }
     return $triples;
 }
 /**
  * Get the row count of a given table. The column to count is specified for
  * performance reasons.
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @param  string tableName The name of the table.
  * @param  string column The column name on wich the COUNT sql statement must be performed.
  * @return int
  */
 public function getRowCount($tableName, $column = 'id')
 {
     $sql = 'SELECT count("' . $column . '") FROM "' . $tableName . '"';
     $result = $this->persistence->query($sql);
     $returnValue = intval($result->fetchColumn(0));
     $result->closeCursor();
     return (int) $returnValue;
 }