本文整理汇总了PHP中Statement类的典型用法代码示例。如果您正苦于以下问题:PHP Statement类的具体用法?PHP Statement怎么用?PHP Statement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Statement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createStatement
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;
}
示例2: assemble
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);
}
示例3: dumpResult
/**
* 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";
}
}
示例4: __construct
/**
* 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;
}
示例5: courses
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;
}
示例6: fire
/**
* 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.');
}
示例7: actorCount
/**
* 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;
}
示例8: testExecute2
/**
* @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());
}
示例9: __construct
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);
}
示例10: setStatement
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();
}
示例11: testValid
/**
* @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());
}
}
}
示例12: deleteAndSave
/**
* 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);
}
示例13: fire
/**
* 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!');
}
示例14: getID
public function getID()
{
if ($this->id_col === null) {
$this->id_col = $this->_statement->getCriteria()->getTable()->getIdColumn();
}
return $this->get($this->id_col);
}
示例15: array
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);
}