本文整理汇总了PHP中DibiConnection::query方法的典型用法代码示例。如果您正苦于以下问题:PHP DibiConnection::query方法的具体用法?PHP DibiConnection::query怎么用?PHP DibiConnection::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DibiConnection
的用法示例。
在下文中一共展示了DibiConnection::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
$this->db = dibi::getConnection("ormion");
$this->db->delete("pages")->execute();
// id, name, description, text, created, allowed
$this->db->query("insert into [pages]", array("name" => "Clanek", "description" => "Popis", "text" => "Text", "allowed" => true), array("name" => "Article", "description" => "Description", "text" => "Text emericky.", "allowed" => false), array("name" => "Nepovolený článek", "description" => "Popis nepovoleného článku", "text" => "Dlouhý text. By byl delší než tento.", "allowed" => false), array("name" => "Jinačí článek", "description" => "Ryze alternativní popis", "text" => "Duchaplný text.", "allowed" => true));
$this->object = new Page();
}
示例2: count
/**
* @return int
*/
public function count()
{
if ($this->count === NULL) {
$this->count = $this->connection->query('
SELECT COUNT(*) FROM', $this->sql)->fetchSingle();
}
return $this->count;
}
示例3: setUp
protected function setUp()
{
$this->db = dibi::getConnection("ormion");
$this->db->delete("pages")->execute();
$this->db->delete("connections")->execute();
$this->db->delete("tags")->execute();
$this->db->query("insert into [pages]", array("name" => "Clanek", "description" => "Popis", "text" => "Text", "visits" => 0, "allowed" => true), array("name" => "Article", "description" => "Description", "text" => "Text emericky.", "visits" => 5, "allowed" => false), array("name" => "Nepovolený článek", "description" => "Popis nepovoleného článku", "text" => "Dlouhý text. By byl delší než tento.", "visits" => 3, "allowed" => false), array("name" => "Jinačí článek", "description" => "Ryze alternativní popis", "text" => "Duchaplný text.", "visits" => 8, "allowed" => true));
$this->db->query("insert into [tags]", array("name" => "Osobní", "url" => "osobni"), array("name" => "Technologie", "url" => "technologie"), array("name" => "Společnost", "url" => "spolecnost"));
}
示例4: canUseGrantType
/**
* Can client use given grant type
* @param string $clientId
* @param string $grantType
* @return bool
*/
public function canUseGrantType($clientId, $grantType)
{
$result = $this->context->query('
SELECT g.name
FROM oauth_client_grant AS cg
RIGHT JOIN oauth_grant AS g ON cg.grant_id = cg.grant_id AND g.name = %s
WHERE cg.client_id = %i
', $grantType, $clientId);
return (bool) $result->fetch();
}
示例5: update
public function update($values)
{
if (empty($this->table)) {
throw new \Natsu\Model\Exception('Cannot update - missing table name in model class');
}
//die('update');
$this->database->query("UPDATE `{$this->table}` SET ", $values, ' WHERE `id`= ?', $values->id);
// $context = new Nette\Database\Context($this->database);
// $context->table($this->table)->getPrimary($values->id)->update($values);
// $this->table()->wherePrimary($values->id)->update($values);
}
示例6: setup
protected function setup()
{
parent::setup();
// Load from DB
$rules = $this->db->query("SELECT * FROM %n", $this->tableName);
foreach ($rules as $rule) {
// If querying the compound name, ensure it exists
if ($rule->type == 'allow') {
$this->allow($rule->role, $rule->resource, $rule->privilege);
} else {
$this->deny($rule->role, $rule->resource, $rule->privilege);
}
}
}
示例7: authenticate
/**
* @inheritDoc
*/
public function authenticate($clientId, $clientSecret = NULL)
{
$clientData = $this->dbConnection->query("SELECT * FROM %n", $this->tableName, "WHERE [clientId] = %s", $clientId)->fetch();
if ($clientData === FALSE) {
return FALSE;
}
// Check client secret
if ($clientData->secret !== NULL || $clientSecret !== NULL) {
if (!$this->hasher->checkPassword($clientSecret, $clientData->secret)) {
return FALSE;
}
}
return new Client($clientData->clientId);
}
示例8: fetch
/**
* Generates, executes SQL query and fetches the single row.
* @return array|FALSE array on success, FALSE if no next record
* @throws DibiException
*/
public function fetch()
{
if ($this->command === 'SELECT') {
$this->clauses['LIMIT'] = array(1);
}
return $this->connection->query($this->_export())->fetch();
}
示例9: fetch
/**
* Fetches single row.
* @param scalar|array primary key value
* @return array|object row
*/
public function fetch($conditions)
{
if (is_array($conditions)) {
return $this->complete($this->connection->query('SELECT * FROM %n', $this->name, 'WHERE %and', $conditions))->fetch();
}
return $this->complete($this->connection->query('SELECT * FROM %n', $this->name, 'WHERE %n=' . $this->primaryModifier, $this->primary, $conditions))->fetch();
}
示例10: finishSmokeTest
/**
* Run after smoke test
*
* Drop test database.
*
* @return NULL
*/
private function finishSmokeTest()
{
if (!$this->smokeTest) {
return;
}
$this->dibi->query('DROP DATABASE IF EXISTS %n;', $this->databaseName);
}
示例11: query
/**
* @return DibiResult
*/
private function query($args)
{
$res = $this->connection->query($args);
foreach ($this->setups as $setup) {
call_user_func_array(array($res, array_shift($setup)), $setup);
}
return $res;
}
示例12: match
public function match(\Nette\Http\IRequest $request)
{
/**
* @var $appRequest \Nette\Application\Request
*/
$appRequest = parent::match($request);
if (!isset($appRequest->parameters['id'])) {
return NULL;
}
if (!is_numeric($appRequest->parameters['id'])) {
$page = $this->database->query("SELECT contentId FROM route WHERE url = ?", $appRequest->parameters['id'])->fetch();
if ($page == NULL) {
return NULL;
}
$appRequest->parameters['id'] = $page->contentId;
}
return $appRequest;
}
示例13: addContact
public function addContact($contact)
{
try {
$this->database->query('INSERT INTO [' . self::TABLE_NAME_CONTACT . ']', [self::COLUMN_ID => $contact['id'], self::COLUMN_EMAIL => $contact['email']]);
return $this->database->getInsertId();
} catch (Nette\Database\DriverException $e) {
throw new \Nette\Database\DriverException();
}
}
示例14: __construct
public function __construct(\DibiConnection $db)
{
//static roles
$this->addRole('guest');
$this->addRole('authenticated', 'guest');
$this->addRole('manager', 'authenticated');
$this->addRole('administrator', 'manager');
$this->addRole('student', 'authenticated');
$this->addRole('teacher', 'authenticated');
//dynamic roles
$groups = $db->query("SELECT * FROM `group`")->fetchAll();
foreach ($groups as $group) {
if (!$this->hasRole($group->role_name)) {
$this->addRole($group->role_name, 'authenticated');
}
}
// resources
$this->addResource('Front:Homepage');
$this->addResource('Front:Files');
$this->addResource('Service:Sign');
$this->addResource('Service:Error');
$this->addResource('Dashboard:Homepage');
$this->addResource('Dashboard:Users');
$this->addResource('Dashboard:Groups');
$this->addResource('Dashboard:My');
$this->addResource('Dashboard:Files');
$this->addResource('Works:Homepage');
$this->addResource('Works:Sets');
$this->addResource('Works:Ideas');
$this->addResource('Works:Assignments');
$this->addResource('School:Homepage');
$this->addResource('School:Classes');
$this->addResource('School:Students');
$this->addResource('School:Teachers');
$this->addResource('School:Subjects');
$this->addResource('School:Groups');
$this->addResource('School:Import');
$this->addResource('Delivery:Homepage');
$this->addResource('Practice:Homepage');
$this->addResource('Activity:Homepage');
// privileges
$this->allow('guest', array('Front:Homepage', 'Service:Sign', "Service:Error"), Permission::ALL);
$this->allow('authenticated', array('Dashboard:My'), Permission::ALL);
$this->allow('authenticated', array('Dashboard:Groups'), Permission::ALL);
$this->allow('authenticated', array('Dashboard:Files'), Permission::ALL);
$this->allow('authenticated', array('Dashboard:Homepage'), array('default'));
$this->allow('student', array('Works:Homepage'), array('default'));
$this->allow('teacher', array('Works:Homepage'), Permission::ALL);
$this->allow('student', array('Works:Ideas'), array('default', 'add', 'id', 'edit', 'delete', 'clone'));
$this->allow('teacher', array('Works:Ideas'), Permission::ALL);
$this->allow('student', array('Works:Assignments'), array('default', 'application'));
$this->allow('teacher', array('Works:Assignments'), array('default', 'add', 'id', 'edit', 'delete', 'print'));
$this->allow('teacher', array('School:Homepage', 'School:Teachers', 'School:Classes', 'School:Students', 'School:Subjects', 'School:Groups'), Permission::ALL);
$this->allow('administrator', Permission::ALL, Permission::ALL);
}
示例15: createConnection
public static function createConnection(DI\Container $container)
{
$dibiConnection = new \DibiConnection($container->params['database']);
$dibiConnection->query('SET NAMES UTF8');
$substitutions = array('core' => 'cms_', 'vd' => 'cms_vd_', 'c' => 'cgf_', 'media' => 'media_');
foreach ($substitutions as $sub => $prefix) {
$dibiConnection->getSubstitutes()->{$sub} = $prefix;
}
// $profiler = new \DibiProfiler();
// $dibiConnection->setProfiler($profiler);
// $dibiConnection->setFile(APP_DIR.'/../log/dibi.log');
return $dibiConnection;
}