本文整理匯總了PHP中Db::fetchOne方法的典型用法代碼示例。如果您正苦於以下問題:PHP Db::fetchOne方法的具體用法?PHP Db::fetchOne怎麽用?PHP Db::fetchOne使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Db
的用法示例。
在下文中一共展示了Db::fetchOne方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setPopularVideo
/**
* Записывает видео в топ саммых папулярных видео если оно подходит по балам или видео в топе не привышает MAX_POPULAR_VIDEO_IN_CATEGORY
* @param $videoId
* @param $categoriesIds
* @param $balls
* @throws Exception
*/
public function setPopularVideo($videoId, $categoriesIds, $balls)
{
if (!empty($categoriesIds)) {
$categories = explode(',', $categoriesIds);
foreach ($categories as $category) {
// Если видео есть в списке популярных то в нем просто обновляются баллы
$this->db->query("UPDATE video_popular SET balls = :balls WHERE video_id = :videoId AND category_id = :categoryId", ['videoId' => $videoId, 'categoryId' => $category, 'balls' => $balls]);
if ($this->db->getConnect()->affected_rows < 1) {
// если нет видео, получается видео с самым меньшим колличеством баллов
$minBallsVideo = $this->db->fetchRow("SELECT SQL_CALC_FOUND_ROWS * FROM video_popular WHERE category_id = :categoryId ORDER BY balls ASC LIMIT 1", ['categoryId' => $category]);
$foundRows = $this->db->fetchOne("SELECT FOUND_ROWS();");
$insertVideo = false;
// если популярных видео в категории меньше чем значение это значит что мы можем просто добавить видео в популярные
if ($foundRows < self::MAX_POPULAR_VIDEO_IN_CATEGORY) {
$insertVideo = true;
} else {
if ($minBallsVideo['balls'] < $balls) {
// если у текущего видео балл выше чем у видео с наименьшим балом, то заменяем видео с наименьшим балом на текущее.
$insertVideo = true;
$this->db->query("DELETE FROM video_popular WHERE video_id = :videoId AND category_id = :categoryId", ['videoId' => $minBallsVideo['video_id'], 'categoryId' => $minBallsVideo['category_id']]);
}
}
if ($insertVideo) {
$this->db->query("INSERT INTO video_popular (video_id, category_id, balls) VALUES (:videoId, :categoryId, :balls)", ['videoId' => $videoId, 'categoryId' => $category, 'balls' => $balls]);
}
}
}
}
}
示例2: pos
public static function pos($inmueble)
{
$pos = Db::fetchOne(Db::select(array('pos' => 'MAX(posicion)'), 'inmuebles_paginas', array('inmueble_id' => $inmueble)));
if (empty($pos)) {
$pos = 0;
}
return $pos;
}
示例3: strtolower
if (!empty($_POST)) {
$email = strtolower($_POST['email']);
$password = $_POST['password'];
$passwordagain = $_POST['passwordagain'];
$captcha = strtolower($_POST['captcha']);
if (!Session::captchaCompare('signup', $captcha)) {
$error['captcha'] = true;
}
if (!isEmail($email)) {
$error['email'] = true;
}
if (strlen($password) < 6) {
$error['password'] = true;
}
if ($passwordagain != $password) {
$error['passwordagain'] = true;
}
if (empty($error)) {
$emailexists = Db::fetchOne("SELECT email FROM users\n WHERE email = '{$email}'");
if (!empty($emailexists)) {
$error['email'] = true;
}
}
if (empty($error)) {
Db::insert('users', array('email' => $email, 'password' => md5($password)));
$uid = Db::inserted();
Db::update('projects_access', array('uid' => $uid), "email = '{$email}'");
header("Location: {$config['root']}signin/?email={$email}");
}
}
require_once "{$root}/themes/{$theme}/signup.php";
示例4: __
include_once "{$root}/common.php";
$title = __('TLDsSuggest');
if (!empty($_POST)) {
$domain = $_POST['domain'];
$description = $_POST['description'];
$captcha = strtolower($_POST['captcha']);
if (substr($domain, 0, 1) == '.') {
$domain = substr($domain, 1);
}
$domain = strtolower($domain);
if (!Session::captchaCompare('tldssuggest', $captcha)) {
$error['captcha'] = true;
}
if (strlen($domain) < 2 || !isTLD($domain)) {
$error['domain'] = true;
}
if (!empty($description) && strlen($description) > 140) {
$error['description'] = true;
}
if (empty($error)) {
$tldexists = Db::fetchOne("SELECT domain FROM tlds\n WHERE LCASE(domain) = '{$domain}'");
if (!empty($tldexists)) {
$error['domainexists'] = true;
}
}
if (empty($error)) {
Db::insert('tlds', array('domain' => $domain, 'description' => $description, 'suggest' => 1));
header("Location: {$config['root']}tlds/");
}
}
require_once "{$root}/themes/{$theme}/tldssuggest.php";
示例5: header
include_once "{$root}/config.php";
include_once "{$root}/common.php";
if (Session::$logged) {
header("Location: {$config['root']}dd/");
}
$title = __('RestoreTitle');
$error = array();
if (isset($_GET['email']) && isEmail($_GET['email'])) {
$email = $_GET['email'];
}
if (!empty($_POST)) {
$email = $_POST['email'];
if (!isEmail($email)) {
$error['email'] = true;
} else {
$uid = Db::fetchOne("SELECT uid FROM users\n WHERE email = '{$email}'");
if (empty($uid)) {
$error['email'] = true;
}
}
if (empty($error)) {
$password = '';
for ($i = 0; $i < 8; $i++) {
$password .= rand(0, 9);
}
Db::update('users', array('password' => md5($password)), "uid = '{$uid}'");
/**
* @todo Send email.
*/
header("Location: {$config['root']}signin/?email={$email}");
}
示例6: foreach
if (!empty($_POST)) {
$name = $_POST['name'];
$description = $_POST['description'];
$public = $_POST['public'] ? 1 : 0;
$domains = $_POST['domain'];
if (strlen($name) < 3) {
$error['name'] = true;
}
if (!empty($description) && strlen($description) > 140) {
$error['description'] = true;
}
if (empty($error)) {
if ($pid) {
if (!empty($domains) && is_array($domains)) {
foreach ($domains as $tid => $active) {
if (!$active) {
continue;
}
$tldexists = Db::fetchOne("SELECT tid FROM projects_tlds\n WHERE pid = '{$pid}' AND tid = '{$tid}'");
if (empty($tldexists)) {
Db::insert('projects_tlds', array('pid' => $pid, 'tid' => $tid));
}
}
Db::query("DELETE FROM projects_tlds\n WHERE pid = '{$pid}'\n AND tid NOT IN ( '" . implode("', '", array_keys($domains)) . "' )");
}
Db::update('projects', array('name' => $name, 'description' => $description, 'public' => $public), "pid = '{$pid}'");
}
header("Location: {$config['root']}dd/projects/");
}
}
require_once "{$root}/themes/{$theme}/ddprojectsedit.php";
示例7: getValue
protected function getValue($name)
{
$this->autoload();
if (isset($this->all[$name])) {
return $this->all[$name];
}
$value = Db::fetchOne('SELECT option_value FROM `' . Common::prefixTable('option') . '` ' . 'WHERE option_name = ?', $name);
if ($value === false) {
return false;
}
$this->all[$name] = $value;
return $value;
}
示例8: count
/**
* Devuelve la cantidad de registros en una tabla.
*
* @param string $table
* @param string|array|null $where
* @return integer
*/
public static function count($table, $where = null)
{
$where = self::where($where);
return Db::fetchOne("SELECT COUNT(*) FROM {$table}\n WHERE {$where}");
}
示例9: header
<?php
$root = '.';
include_once "{$root}/config.php";
include_once "{$root}/common.php";
if (!Session::$logged) {
header("Location: {$config['root']}signin/?next={$config['root']}dd/projects/");
}
$title = __('ProjectsTitle');
$count = Db::fetchOne("SELECT COUNT(*) FROM projects WHERE uid = '" . Session::_('uid') . "'");
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$start = ($page - 1) * $config['perpage'];
$projects = Db::fetchAssoc("SELECT pid, name, description\n FROM projects\n WHERE uid = '" . Session::_('uid') . "'\n ORDER BY name\n LIMIT {$start},{$config['perpage']}");
$pagination = pagination("{$config['root']}dd/projects/", $count, $config['perpage'], $page);
require_once "{$root}/themes/{$theme}/ddprojects.php";
示例10: exists
protected function exists($id)
{
$exists = Db::fetchOne("SELECT COUNT(id_user)\n FROM twcensus_users\n WHERE id_user = '{$id}'");
return $exists > 0;
}
示例11: getSiteId
/**
* Get the SiteId from the given site url using mysql
* driver.
*
* @param string $domain
*
* @return int $id
*/
public function getSiteId($domain)
{
$parsedDomain = parse_url($domain);
$domain = 'http://' . $parsedDomain['path'];
$siteId = Db::fetchOne('SELECT idsite FROM piwik_site WHERE main_url=?', array($domain));
if (!$siteId) {
$siteId = Db::fetchOne('SELECT idsite FROM piwik_site_url WHERE url=?', array($domain));
}
return $siteId;
}