本文整理汇总了PHP中SwatDB::queryOne方法的典型用法代码示例。如果您正苦于以下问题:PHP SwatDB::queryOne方法的具体用法?PHP SwatDB::queryOne怎么用?PHP SwatDB::queryOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SwatDB
的用法示例。
在下文中一共展示了SwatDB::queryOne方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCommentCount
protected function getCommentCount()
{
$sql = 'select count(1) from BlorgComment
left outer join BlorgAuthor on BlorgComment.author = BlorgAuthor.id
where ' . $this->getWhereClause();
return SwatDB::queryOne($this->app->db, $sql);
}
示例2: getCommentCount
protected function getCommentCount()
{
$sql = 'select count(1) from PinholeComment
left outer join PinholePhotographer on PinholeComment.photographer = PinholePhotographer.id
where ' . $this->getWhereClause();
return SwatDB::queryOne($this->app->db, $sql);
}
示例3: processInternal
protected function processInternal()
{
parent::processInternal();
$pager = $this->ui->getWidget('pager');
$pager->total_records = SwatDB::queryOne($this->app->db, sprintf('select count(id) from Newsletter where %s', $this->getWhereClause()));
$pager->process();
}
示例4: hasAttested
public function hasAttested(CMEFrontMatter $front_matter)
{
$this->checkDB();
$sql = sprintf('select count(1) from AccountAttestedCMEFrontMatter
where account = %s and front_matter = %s', $this->db->quote($this->id, 'integer'), $this->db->quote($front_matter->id, 'integer'));
return SwatDB::queryOne($this->db, $sql) > 0;
}
示例5: getVisiblePostCount
/**
* Gets the number of visible posts this tag applies to
*
* This is more efficient than getting the set of posts and counting the
* set. Use this method if you don't need the actual post objects.
*
* @return integer the number of posts this tag applies to.
*/
public function getVisiblePostCount()
{
$sql = 'select count(id) from BlorgPost
inner join BlorgPostTagBinding on id = post
where tag = %s and BlorgPost.enabled = %s';
return SwatDB::queryOne($this->db, sprintf($sql, $this->db->quote($this->id, 'integer'), $this->db->quote(true, 'boolean')));
}
示例6: initStartDate
protected function initStartDate()
{
$oldest_date_string = SwatDB::queryOne($this->app->db, 'select min(complete_date) from InquisitionResponse
where complete_date is not null
and inquisition in (select evaluation from AccountCMEProgress)');
$this->start_date = new SwatDate($oldest_date_string);
$this->start_date->setTimezone($this->app->default_time_zone);
}
示例7: validateShortname
protected function validateShortname($shortname)
{
$instance_id = $this->app->getInstanceId();
$sql = sprintf('select count(id) from Article
where shortname = %s and
instance %s %s and
parent %s %s
and id %s %s', $this->app->db->quote($shortname, 'text'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), SwatDB::equalityOperator($this->parent), $this->app->db->quote($this->parent, 'integer'), SwatDB::equalityOperator($this->id, true), $this->app->db->quote($this->id, 'integer'));
return SwatDB::queryOne($this->app->db, $sql) == 0;
}
示例8: loadData
protected function loadData()
{
$instance_id = $this->app->getInstanceId();
$where_clause = sprintf('visible = %s and instance %s %s', $this->app->db->quote($this->parent, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
$order_widget = $this->ui->getWidget('order');
$order_widget->addOptionsByArray(SwatDB::getOptionArray($this->app->db, 'PinholeMetaData', 'title', 'id', 'displayorder, title', $where_clause));
$sql = 'select sum(displayorder) from PinholeMetaData where ' . $where_clause;
$sum = SwatDB::queryOne($this->app->db, $sql, 'integer');
$options_list = $this->ui->getWidget('options');
$options_list->value = $sum == 0 ? 'auto' : 'custom';
}
示例9: initInquisition
protected function initInquisition()
{
parent::initInquisition();
if (!$this->inquisition instanceof InquisitionInquisition) {
// if we got here from the question index, load the inquisition
// from the binding as we only have one inquisition per question
$sql = sprintf('select inquisition from InquisitionInquisitionQuestionBinding
where question = %s', $this->app->db->quote($this->question->id));
$inquisition_id = SwatDB::queryOne($this->app->db, $sql);
$this->inquisition = $this->loadInquisition($inquisition_id);
}
}
示例10: processDBData
protected function processDBData()
{
AdminDBDelete::processDBData();
$instance_id = $this->app->getInstanceId();
$sql = sprintf('select parent from Article
where id = %s and instance %s %s', $this->app->db->quote($this->getFirstItem(), 'integer'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
$this->parent_id = SwatDB::queryOne($this->app->db, $sql);
$item_list = $this->getItemList('integer');
$sql = sprintf('delete from Article
where id in (%s) and instance %s %s', $item_list, SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
$num = SwatDB::exec($this->app->db, $sql);
$message = new SwatMessage(sprintf(Site::ngettext('One article has been deleted.', '%s articles have been deleted.', $num), SwatString::numberFormat($num)));
$this->app->messages->add($message);
}
示例11: getDefaultList
public static function getDefaultList(SiteApplication $app, SiteInstance $instance = null)
{
$default_list = $app->config->mail_chimp->default_list;
if ($app->hasModule('SiteMultipleInstanceModule') && $app->getInstance() === null) {
if ($instance === null) {
throw new DeliveranceException('Instance must be set.');
}
$sql = 'select value from InstanceConfigSetting
where name = %s and instance = %s';
$sql = sprintf($sql, $app->db->quote('mail_chimp.default_list', 'text'), $app->db->quote($instance->id, 'integer'));
$default_list = SwatDB::queryOne($app->db, $sql);
}
return $default_list;
}
示例12: getTableModel
protected function getTableModel(SwatView $view)
{
$sql = sprintf('select count(id) from BlorgTag where %s', $this->getWhereClause());
$pager = $this->ui->getWidget('pager');
$pager->total_records = SwatDB::queryOne($this->app->db, $sql);
$sql = sprintf('select id, title, shortname
from BlorgTag
where %s
order by %s', $this->getWhereClause(), $this->getOrderByClause($view, 'title'));
$tags = SwatDB::query($this->app->db, $sql, 'BlorgTagWrapper');
if (count($tags) > 0) {
$this->ui->getWidget('results_frame')->visible = true;
$this->ui->getWidget('results_message')->content = $pager->getResultsMessage(Blorg::_('result'), Blorg::_('results'));
}
return $tags;
}
示例13: loadData
protected function loadData()
{
$instance_id = $this->app->getInstanceId();
if ($instance_id === null) {
$where_clause = '1 = 1';
} else {
$where_clause = sprintf('instance %s %s', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
}
$order_widget = $this->ui->getWidget('order');
$sql = sprintf('select * from BlorgAuthor where %s
order by displayorder, name', $where_clause);
$authors = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgAuthorWrapper'));
foreach ($authors as $author) {
$order_widget->addOption($author->id, $author->name);
}
$sql = 'select sum(displayorder) from BlorgAuthor where ' . $where_clause;
$sum = SwatDB::queryOne($this->app->db, $sql, 'integer');
$options_list = $this->ui->getWidget('options');
$options_list->value = $sum == 0 ? 'auto' : 'custom';
}
示例14: login
/**
* Logs the current session into a {@link SiteAccount}
*
* @param string $email the email address of the account to login.
* @param string $password the password of the account to login.
*
* @return boolean true if the session was successfully logged in and false
* if the passphrase is incorrect.
*/
public function login($passphrase)
{
// TODO: should passphrase be salted?
$passphrase = md5($passphrase);
$instance = $this->getInstanceId();
$sql = sprintf('select instance from InstanceConfigSetting
where instance %s %s and name = %s and value = %s', SwatDB::equalityOperator($instance), $this->app->db->quote($instance, 'integer'), $this->app->db->quote('pinhole.passphrase', 'text'), $this->app->db->quote($passphrase, 'text'));
$id = SwatDB::queryOne($this->app->db, $sql);
if ($id !== null) {
$this->activate();
if (!isset($this->authenticated_instances) || !$this->authenticated_instances instanceof ArrayObject) {
$this->authenticated_instances = new ArrayObject();
}
$this->authenticated_instances[$this->getInstanceId()] = true;
$logged_in = true;
} else {
$this->logout();
$logged_in = false;
}
return $logged_in;
}
示例15: initLastSegments
protected function initLastSegments()
{
for ($rating = 1; $rating <= 5; $rating++) {
$use_random_start = true;
if ($this->incremental === true) {
$sql = sprintf('select value
from MailingListMemberUpdaterCache
where rating = %s and field = %s
order by id desc
limit 1', $this->db->quote($rating, 'integer'), $this->db->quote($this->field, 'text'));
$segment = SwatDB::queryOne($this->db, $sql);
if ($segment !== null) {
$use_random_start = false;
$this->last_segment[$rating] = $this->getNumericSegment($segment);
}
}
// random the starting last segment, so as to not bias when running
// incremental updates. is rand() good enough for this?
if ($use_random_start === true) {
$this->last_segment[$rating] = rand(0, $this->number_of_segments);
}
}
}