This class is very generic and has no driver-specific implementations. In fact,
it wouldn't be possible to have driver-specific classes, since PHP doesn't support
multiple inheritance. I.e. you couldn't have MySQLPreparedStatement that extended
both the abstract PreparedStatement class and the MySQLStatement class. In Java
this isn't a concern since PreparedStatement is an interface, not a class.
protected function createStatement(\Lrs $lrs, \Client $client, array $statement) { $model = new \Statement(['lrs_id' => new \MongoId($lrs->_id), 'client_id' => $client->_id, 'statement' => $statement, 'active' => true, 'voided' => false, 'refs' => []]); $model->timestamp = new \MongoDate(strtotime($model->statement['timestamp'])); $model->save(); return $model; }
public function assemble(Statement $statement, $useTableNameAsAlias) { $table = $statement->getTable($this->tableAlias); list($referencedDatasetName, $referencedColumnName) = ReferencePathHelper::splitReference($this->columnName); $column = $table->findColumnByAlias($referencedColumnName); return ' = ' . ColumnNameHelper::combineColumnName($table->prepareColumnTableAlias($useTableNameAsAlias), isset($column) && $column instanceof ColumnSection ? $column->name : $referencedColumnName); }
/** * Displays complete result set as HTML table for debug purposes. * @return void */ public static function dumpResult(Statement $statement) { echo "\n<table class=\"dump\">\n<caption>" . htmlSpecialChars($statement->queryString) . "</caption>\n"; if (!$statement->columnCount()) { echo "\t<tr>\n\t\t<th>Affected rows:</th>\n\t\t<td>", $statement->rowCount(), "</td>\n\t</tr>\n</table>\n"; return; } $i = 0; foreach ($statement as $row) { if ($i === 0) { echo "<thead>\n\t<tr>\n\t\t<th>#row</th>\n"; foreach ($row as $col => $foo) { echo "\t\t<th>" . htmlSpecialChars($col) . "</th>\n"; } echo "\t</tr>\n</thead>\n<tbody>\n"; } echo "\t<tr>\n\t\t<th>", $i, "</th>\n"; foreach ($row as $col) { //if (is_object($col)) $col = $col->__toString(); echo "\t\t<td>", htmlSpecialChars($col), "</td>\n"; } echo "\t</tr>\n"; $i++; } if ($i === 0) { echo "\t<tr>\n\t\t<td><em>empty result set</em></td>\n\t</tr>\n</table>\n"; } else { echo "</tbody>\n</table>\n"; } }
/** * Constructs a conditional statement. * * @param string $condition The condition statement * @param \Helmich\TypoScriptParser\Parser\AST\Statement[] $ifStatements The statements in the if-branch. * @param \Helmich\TypoScriptParser\Parser\AST\Statement[] $elseStatements The statements in the else-branch (may be empty). * @param int $sourceLine The original source line. */ public function __construct($condition, array $ifStatements, array $elseStatements, $sourceLine) { parent::__construct($sourceLine); $this->condition = $condition; $this->ifStatements = $ifStatements; $this->elseStatements = $elseStatements; }
public function getID() { if ($this->id_col === null) { $this->id_col = $this->_statement->getCriteria()->getTable()->getIdColumn(); } return $this->get($this->id_col); }
public function courses() { $courses = array(); $return_results = array(); foreach ($this->data as $d) { if (isset($d['context']['contextActivities'])) { foreach ($d['context']['contextActivities']['grouping'] as $key => $value) { if ($key === 'type' && $value == 'http://adlnet.gov/expapi/activities/course') { $courses[] = $d['context']['contextActivities']['grouping']['id']; } } } } $array = array_count_values($courses); arsort($array); $results = array_slice($array, 0, 4); foreach ($results as $key => $value) { $get_name = \Statement::where('context.contextActivities.grouping.id', $key)->first(); if (isset($get_name['context']['contextActivities']['grouping']['definition']['name']['en-gb'])) { $return_results[] = array('name' => $get_name['context']['contextActivities']['grouping']['definition']['name']['en-gb'], 'count' => $value); } else { $return_results[] = array('name' => $get_name['context']['contextActivities']['grouping']['definition']['name']['en-GB'], 'count' => $value); } } $this->results = $return_results; }
/** * Execute the console command. * * @return mixed */ public function fire() { $lrs_collection = (new Lrs())->get(); // Remove all inactive statements. Statement::where('active', '=', false)->delete(); // Migrates the statements for each LRS. foreach ($lrs_collection as $lrs) { Statement::where('lrs._id', $lrs->_id)->chunk(500, function ($statements) use($lrs) { $statements_array = []; // Sets `active` and `voided` properties. // Ensures that statement is an associative array. $statements = $statements->each(function ($statement) { $statement->voided = isset($statement->voided) ? $statement->voided : false; $statement->active = isset($statement->active) ? $statement->active : true; $statement->save(); $statements_array[] = (array) json_decode($statement->toJSON()); }); // Uses the repository to migrate the statements. $repo = App::make('Locker\\Repository\\Statement\\EloquentVoider'); $repo->updateReferences($statements_array, $lrs); $repo->voidStatements($statements_array, $lrs); // Outputs status. $statement_count = $statements->count(); $this->info("Migrated {$statement_count} statements in `{$lrs->title}`."); }); } $this->info('All statements migrated.'); }
function __construct($name, $value, $operator = null, \Kinesis\Task $parent = null) { if (is_null($operator)) { $operator = '='; } $params = array('Name' => $name, 'Value' => $value, 'Operator' => $operator); parent::__construct($params, $parent); }
/** * Count the number of distinct actors within Learning Locker statements. * * @return count. * **/ public function actorCount() { $mbox = intval(\Statement::distinct('statement.actor.mbox')->remember(5)->get()->count()); $openid = intval(\Statement::distinct('statement.actor.openid')->remember(5)->get()->count()); $mbox_sha1sum = intval(\Statement::distinct('statement.actor.mbox_sha1sum')->remember(5)->get()->count()); $account = intval(\Statement::distinct('statement.actor.account.name')->remember(5)->get()->count()); return $mbox + $openid + $mbox_sha1sum + $account; }
/** * @covers Phossa\Db\Pdo\Statement::prepare() * @covers Phossa\Db\Pdo\Statement::execute() */ public function testExecute2() { // must emulate $this->driver->setAttribute('PDO::ATTR_EMULATE_PREPARES', true); $this->statement->prepare("SELECT :idx, :color"); $res = $this->statement->execute(['idx' => 1, 'color' => 'red']); $this->assertEquals([[1 => "1", "red" => "red"]], $res->fetchRow()); }
public function __construct($string, $token = self::SEMICOLON_TOKEN, $raw = null) { parent::__construct($raw); $this->string = $string; $this->token = $token; if ($this->token !== self::NUMBER_TOKEN && $this->token !== self::SEMICOLON_TOKEN) { $this->token = self::SEMICOLON_TOKEN; } }
function __construct($surname, $name, $patronymic, $email, $tel, $form) { $this->surname = Statement::checkData($surname); $this->name = Statement::checkData($name); $this->patronymic = Statement::checkData($patronymic); $this->email = Statement::checkData($email); $this->tel = Statement::checkData($tel); $this->form = Statement::checkData($form); }
public function __get($name) { switch ($name) { case 'insertID': return $this->statement->insert_id; default: return parent::__get($name); } }
public function setStatement(Statement $st) { $this->_statement = $st; $this->_original_data['id'] = $st->getId(); $this->_original_data['answer'] = $st->getAnswer(); $this->_original_data['text'] = $this->getParse()->decodeBBCodes($st->getText(), false); $this->_original_data['title'] = $st->getTitle(); $this->_original_data['type'] = $st->getType(); $this->_original_data['category'] = $st->getCategory(); $this->_original_data['status'] = $st->getStatus(); }
/** * @covers Gacela\Collection\Statement::valid */ public function testValid() { foreach ($this->collection as $obj) { if ($this->collection->key() < 7) { $this->assertTrue($this->collection->valid()); } else { $this->assertFalse($this->collection->valid()); } } }
public function __construct($key, $value, $delimiter = self::EQUALSIGN_DELIMITER, $raw = null) { parent::__construct($raw); $this->key = $key; $this->value = $value; $this->delimiter = $delimiter; if ($this->delimiter !== self::EQUALSIGN_DELIMITER && $this->delimiter !== self::COLON_DELIMITER) { $this->delimiter = self::EQUALSIGN_DELIMITER; } }
function __construct($name, $value = null, \Kinesis\Task $parent) { if (is_array($name) && is_null($value)) { $params = array('Data' => $name); } elseif (is_scalar($name) && !is_null($value)) { $params = array('Data' => array($name => $value)); } $parent->Parameters['Container']->addChild($this); parent::__construct($params, $parent->Parameters['Container']); }
/** * @param array $configuration */ public function __construct($configuration) { parent::construct($configuration); $this->serverReference = $configuration['mail_server']; $this->connection = imap_open('{' . $configuration['mail_server'] . '}' . $configuration['mail_mailbox'], $configuration['mail_username'], $configuration['mail_password']); if (!$this->connection) { throw new Exception('Nepovedlo se připojit k poštovnímu serveru.'); } $this->checkToDate = strtotime($configuration['mail_checktodate']); }
/** * Delete the reference and push the change to the database * * @param string $summary summary for the change * @throws Exception */ public function deleteAndSave($summary = '') { $id = $this->statement->getId(); if ($id === null) { throw new Exception('Statement has no Id. Please save the statement first.'); } if ($this->hash !== null) { $this->statement->getEntity()->getApi()->removeReferences($id, array($this->hash), $this->statement->getEntity()->getLastRevisionId(), $summary); } $this->statement->removeReference($this); }
/** * Execute the console command. * * Loop through all statements and create a new key in the document route. * This key 'convertedTimestamp' is the same as the statement timestamp but in a * data format the MongoDB aggregation function needs. * * @return string */ public function fire() { Statement::chunk(1000, function ($statements) { foreach ($statements as $s) { $s->timestamp = new \MongoDate(strtotime($s->statement['timestamp'])); $s->save(); } $this->info(count($statements) . ' converted.'); }); $this->info('All finished, hopefully!'); }
/** * Constructor * * @param resource $pdooci PDOOCI connection * @param string $statement sql statement * * @return Statement $statement created */ public function __construct($pdooci, $statement) { try { $this->_pdooci = $pdooci; $this->_con = $pdooci->getConnection(); $this->_statement = Statement::insertMarks($statement); $this->_stmt = \oci_parse($this->_con, $this->_statement); $this->_fetch_sty = \PDO::FETCH_BOTH; } catch (\Exception $e) { throw new \PDOException($e->getMessage()); } }
public function logQuery(Statement $result, array $params = NULL) { if ($this->disabled) { return; } $source = NULL; foreach (PHP_VERSION_ID < 50205 ? debug_backtrace() : debug_backtrace(FALSE) as $row) { if (isset($row['file']) && is_file($row['file']) && strpos($row['file'], NETTE_DIR . DIRECTORY_SEPARATOR) !== 0) { if (isset($row['function']) && strpos($row['function'], 'call_user_func') === 0) { continue; } if (isset($row['class']) && is_subclass_of($row['class'], '\\Nette\\Database\\Connection')) { continue; } $source = array($row['file'], (int) $row['line']); break; } } $this->totalTime += $result->getTime(); $this->queries[] = array($result->queryString, $params, $result->getTime(), $result->rowCount(), $result->getConnection(), $source); }
public function equals(Statement $toTest) { if ($toTest instanceof Statement && $this->getSubject()->equals($toTest->getSubject()) && $this->getPredicate()->equals($toTest->getPredicate()) && $this->getObject()->equals($toTest->getObject())) { if ($this->isQuad() && $toTest->isQuad() && $this->getGraph()->equals($toTest->getGraph())) { return true; } elseif ($this->isTriple() && $toTest->isTriple()) { return true; } } return false; }
public function up() { Statement::chunk(1000, function ($statements) { foreach ($statements as $statement) { if (is_object($statement->refs) || is_array($statement->refs) && isset($statement->refs['id'])) { $statement->refs = [$statement->refs]; $statement->save(); } } echo count($statements) . ' converted.'; }); echo 'All finished, hopefully!'; }
public function __construct(Statement $statement) { try { $this->crit = $statement->getCriteria(); if ($this->crit instanceof Criteria) { if ($this->crit->action == 'insert') { $this->insert_id = $statement->getInsertID(); } elseif ($this->crit->action == 'select') { while ($row = $statement->fetch()) { $this->rows[] = new Row($row, $statement); } $this->max_ptr = count($this->rows); $this->int_ptr = 0; } elseif ($this->crit->action = 'count') { $value = $statement->fetch(); $this->max_ptr = $value['num_col']; } } } catch (\Exception $e) { throw $e; } }
public function find() { $f = []; /* get all fields and build a sentence to AQL find with params */ if (!empty($this->post)) { foreach ($this->post as $k => $v) { $f[] = "u.{$k} == @{$k}"; } } $filter = !empty($f) ? ' filter ' . implode($f, ' && ') : ''; $query = "FOR u IN " . COLLECTION_NAME . $filter . $this->limit . $this->sort . " RETURN u"; $statement = new Statement($this->connection, ["query" => $query, "count" => true, "bindVars" => $this->post]); $cursor = $statement->execute(); $total = $this->collectionHandler->count(COLLECTION_NAME); $result = ['count' => $cursor->getCount(), 'total' => $total, 'pages' => $total > 0 ? $total / PER_PAGE : $total]; /* transform in array */ foreach ($cursor->getAll() as $key => $value) { if (is_object($cursor->getAll()[$key])) { $result["result"][$key] = get_object_vars($cursor->getAll()[$key]); } } echo json_encode($result); }
/** * @param Connection $connection * @param null $paging * @param null $resource */ public function __construct(Connection $connection, $paging = null, &$resource = null) { parent::__construct($connection, $paging, $resource); if (isset($resource)) { if (is_resource($resource)) { $this->resource = $resource; } else { $this->resource = oci_new_cursor($this->connection->resource); $trace = debug_backtrace(); trigger_error('Invalid input via __construct(): value is not a valid resource for ("this->resource' . '") in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); } } else { $this->resource = oci_new_cursor($this->connection->resource); } }
function generateResultStatementsFromVarResult(&$result, $parsedq, &$outm, $closure, &$model) { foreach ($parsedq['patterns'] as $n => $pattern) { if (substr($pattern['subject']['value'], 0, 1) == '?') { $subj = $result[$pattern['subject']['value']]; } else { $subj = new Resource($pattern['subject']['value']); } if (substr($pattern['predicate']['value'], 0, 1) == '?') { $pred = $result[$pattern['predicate']['value']]; } else { $pred = new Resource($pattern['predicate']['value']); } if (substr($pattern['object']['value'], 0, 1) == '?') { $obj = $result[$pattern['object']['value']]; } else { if ($pattern['object']['is_literal']) { $obj = new Literal($pattern['object']['value']); $obj->setDatatype($pattern['object']['l_dtype']); $obj->setLanguage($pattern['object']['l_lang']); } else { $obj = new Resource($pattern['object']['value']); } } $stmt = new Statement($subj, $pred, $obj); // bNode closure if (is_a($stmt->object(), 'BlankNode') && $closure == True) { getBNodeClosure($stmt->object(), $model, $outm); } if (is_a($stmt->subject(), 'BlankNode') && $closure == True) { getBNodeClosure($stmt->subject(), $model, $outm); } // Add statement to model $outm->add($stmt); } }
function __construct() { $params = array(); if (func_num_args() > 0) { $args = func_get_args(); if (is_array($args[0])) { $params = $args[0]; } if (is_string($args[0])) { if (strpos($args[0], ',') !== false) { $params = explode(',', $args[0]); } else { $parent = array_pop($args); $params = $args; } } } parent::__construct($params, $parent); }
/** * Gets statement documents based on a filter. * * @param $lrs id The Lrs to search in (required) * @param $filter array The filter array * @param $raw boolean Pagination or raw statements? * @param $sections array Sections of the statement to return, default = all * * @return Statement query */ public function selectStatementDocs($lrs = '', $filter, $raw = false, $sections = []) { //var_dump( $filter );exit; $statements = \Statement::where('lrs._id', $lrs); if (!empty($filter)) { foreach ($filter as $key => $value) { if (is_array($value)) { //does the array contain between values? e.g. <> 3, 6 if ($value[0] === '<>') { $statements->whereBetween($key, array((int) $value[1], (int) $value[2])); } else { $statements->whereIn($key, $value); //where key is in array } } else { $statements->where($key, $value); } } } return $statements; }