本文整理汇总了PHP中DB::getOne方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::getOne方法的具体用法?PHP DB::getOne怎么用?PHP DB::getOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::getOne方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFaxFolder
function getFaxFolder($fax_id)
{
$sql = 'SELECT fax_folder FROM hylax_faxes WHERE fax_id = ?';
$values = array($fax_id);
$fax_folder = $this->_db->getOne($sql, $values);
if (empty($fax_folder)) {
return PEAR::raiseError(_("No such fax found."));
}
return $fax_folder;
}
示例2: run
function run($row)
{
$row['slideshowGroup'] = GalleryWidget::$slideshowGroup;
GalleryWidget::$slideshowGroup++;
$row['files'] = array();
if (is_numeric($row['tree'])) {
$sql = '
SELECT id FROM {{data}}
WHERE tree=' . $row['tree'] . ' AND path=\'' . $row['path'] . '\' AND type=\'gallery\'
';
$dataId = DB::getOne($sql);
if ($dataId) {
$sql = '
SELECT id2 FROM {{relations}}
WHERE modul1=\'data\' AND modul2=\'files\' AND id1=' . $dataId . '
';
$fileId = DB::getAll($sql, 'id2');
if (count($fileId) > 0) {
$sql = '
SELECT * FROM {{files}}
WHERE id IN (' . implode(',', $fileId) . ')
ORDER BY num
';
$temp = DB::getAll($sql);
foreach ($temp as $item) {
$item['file'] = Funcs::getFileInfo($item['path']);
$row['files'][$item['mime']][] = $item;
}
}
}
}
GalleryWidget::$files = $row['files'];
return View::getWidget('galleryWidget', $row);
}
示例3: getValuesNumber
public static function getValuesNumber($path)
{
$data = array();
$tree = Tree::getTreeByUrl();
$ids[] = $tree['id'];
$ids = array_merge($ids, Tree::getChilds($tree['id']));
$sql = '
SELECT DISTINCT type FROM {{data}}
WHERE path=\'' . $path . '\' AND tree IN (' . implode(',', $ids) . ')
';
$type = DB::getOne($sql);
if ($type) {
$sql = '
SELECT MAX(' . Fields::$fieldsName[$type] . ') AS maxv, MIN(' . Fields::$fieldsName[$type] . ') AS minv FROM {{data}}
WHERE path=\'' . $path . '\' AND tree IN (' . implode(',', $ids) . ')
';
$data = DB::getRow($sql);
$data['type'] = substr($type, 0, 1);
}
if ($data['maxv'] > 0) {
return $data;
} else {
return array();
}
}
示例4: getPagi
public function getPagi($sql)
{
$perpage = $_SESSION['user']['perpage'];
$page = $_GET['p'];
if ($page == '') {
$page = 1;
}
$data = array();
$sql = DB::prefix($sql);
$sqlcount = substr($sql, strpos($sql, ' FROM '), strlen($sql));
$tab = substr($sqlcount, strpos($sqlcount, ' ', 1), strpos($sqlcount, ' ', 6) - 1);
if (strpos($sql, 'SELECT DISTINCT') !== false) {
$sqlcount = 'SELECT COUNT(DISTINCT ' . $tab . '.id) ' . $sqlcount;
} else {
$sqlcount = 'SELECT count(*) ' . $sqlcount;
}
if (class_exists(PaginationWidget)) {
PaginationWidget::$count = DB::getOne($sqlcount);
}
$sql = $sql . ' LIMIT ' . ($page - 1) * $perpage . ',' . $perpage . '';
$q = DB::$pdo->query($sql) or die(DB::error($sql, debug_backtrace()));
foreach ($q as $row) {
$data[] = $row;
}
return $data;
}
示例5: getTop
function getTop()
{
if (Funcs::$uri[2]) {
$sql = 'SELECT parent FROM {{forum}} WHERE id=' . Funcs::$uri[2] . '';
return DB::getOne($sql);
}
}
示例6: __construct
public function __construct()
{
if ($_GET['ref']) {
$sql = 'SELECT iuser FROM {{iusers_options}} WHERE selfcode=\'' . $_GET['ref'] . '\'';
$iuser = DB::getOne($sql);
if ($iuser) {
$_SESSION['referal'] = $iuser;
}
}
$sql = 'SELECT * FROM {{tree}} WHERE parent=410 AND visible=1 ORDER BY num';
$list = DB::getAll($sql);
foreach ($list as $item) {
$fields = Fields::getFieldsByTree($item['id'], 'wide');
$item['pic'] = $fields['files_gal']['image'][0]['path'];
$multi = Fields::getMultiFields($item['id']);
foreach ($multi['color'] as $row) {
$item['list'][$row] = Funcs::$referenceId['color'][$row]['name'];
}
Run::$colors[$item['id']] = $item;
}
//print '<pre>';print_r(Run::$colors);die;
$sql = 'SELECT * FROM {{tree}} WHERE id=1';
$row = DB::getRow($sql);
Run::$socTitle = $row['seo_title'];
Run::$socDescription = $row['seo_description'];
}
示例7: setList
public static function setList($list)
{
$sql = 'UPDATE {{catalog}} SET available=0';
DB::exec($sql);
foreach ($list as $partname => $items) {
$sql = 'SELECT tree FROM {{catalog}} WHERE partname="' . $partname . '"';
$parent = DB::getOne($sql);
if ($parent) {
$available = 0;
foreach ($items as $size => $item) {
$sql = 'SELECT id FROM {{tree}} WHERE parent=' . $parent . ' AND name="' . $size . '"';
$tree = DB::getOne($sql);
if (!$tree) {
$sql = 'SELECT id FROM {{tree}} WHERE parent=' . $parent . ' AND path="' . $size . '"';
$tree = DB::getOne($sql);
}
foreach ($item as $k => $f) {
$sql = 'SELECT type FROM {{fields}} WHERE module=6 AND path="' . $k . '"';
$r = DB::getOne($sql);
$row = array('field' => Fields::$types[$r]['type'], 'path' => $k, 'value' => $f);
Price::updateField($tree, $row);
if ($k == 'numberRetailSales' && $f > 0) {
$available = 1;
}
}
}
$sql = 'UPDATE {{catalog}} SET available=' . $available . ' WHERE tree=' . $parent;
DB::exec($sql);
}
}
}
示例8: getSearch
function getSearch()
{
$data = array();
$sql = 'SELECT COUNT(*) FROM {{search}}';
$data['search'] = DB::getOne($sql);
$sql = 'SELECT COUNT(*) FROM ' . BDPREFIX . 'tree WHERE visible=1 and path<>\'index\' and path<>\'search\' and path<>\'sitemap\'';
$data['tree'] = DB::getOne($sql, 1);
return $data;
}
示例9: getOne
/**
* Returns single scalar value from the first column, first record
*
* The returned value will be based upon the sql specified by $sql. This is
* basically a wrapper for the
* {@link http://pear.php.net/manual/en/package.database.db.db-common.getone.php DB_common::getOne}
* method of the Pear DB module.
*
* @param string $sql The SQL code to be executed
* @param array $data If $sql is a paramatised query, then the data for each parameter goes in this array
* @return string
*
*/
public function getOne($sql, $data = array())
{
$result = $this->conn->getOne($sql, $data);
self::logQuery();
if (DB::isError($result)) {
throw new LoggedException($result->getMessage() . ". SQL: {$sql}", $result->getCode(), self::module);
}
return $result;
}
示例10: getStoryCount
/**
* Returns the total number of stories in the specified channel.
*
* @param integer $channel_id The Channel Id
*
* @return integer The count
*/
public function getStoryCount($channel_id)
{
$sql = 'SELECT count(*) FROM jonah_stories WHERE channel_id = ?';
$result = $this->_db->getOne($sql, $channel_id);
if ($result instanceof PEAR_Error) {
throw new Jonah_Exception($result);
}
return (int) $result;
}
示例11: getDB
public static function getDB($name)
{
$sql = 'SELECT value FROM {{cashe}} WHERE name=\'' . substr($name, 0, 256) . '\' AND cdate>=' . (time() - 60 * 60 * 24 * 7) . '';
//print DB::prefix($sql);
$value = DB::getOne($sql);
if ($value) {
return unserialize($value);
} else {
return false;
}
}
示例12: login
public function login($email, $password)
{
$db = new DB();
$user = $db->getOne('users', array('email' => $email, 'password' => sha1($password)));
if ($user !== null) {
$_SESSION['user'] = $user;
return true;
} else {
return false;
}
}
示例13: updateTerminals
public static function updateTerminals()
{
$data = array();
$DPD = new DPD_service();
try {
$arTerminalsList = $DPD->getTerminalsSelfDelivery();
//print '<pre>';print_r($arTerminalsList);die;
$i = 0;
$errors;
$sql = 'UPDATE {{terminals}} SET visible=0 AND company=\'DPD\'';
DB::exec($sql);
foreach ($arTerminalsList as $item) {
$sql = 'SELECT id FROM {{terminals}} WHERE code=\'' . $item['terminal']['terminalCode'] . '\'';
$id = DB::getOne($sql);
if (!$id) {
$temp['terminalCode'] = iconv('windows-1251', 'utf-8', $item['terminal']['terminalCode']);
$temp['terminalName'] = iconv('windows-1251', 'utf-8', $item['terminal']['terminalName']);
$temp['terminalAddress'] = iconv('windows-1251', 'utf-8', $item['terminal']['terminalAddress']);
$cityId = '';
$regionId = '';
$sql = 'SELECT id FROM {{regions}} WHERE cityId=' . $item['city']['cityId'] . '';
$cityId = DB::getOne($sql);
$sql = 'SELECT id FROM {{regions}} WHERE regionCode=' . $item['city']['regionCode'] . '';
$regionId = DB::getOne($sql);
if ($cityId && $regionId) {
$sql = '
INSERT INTO {{terminals}}
SET
region=' . $regionId . ',
city=\'' . $cityId . '\',
code=\'' . $temp['terminalCode'] . '\',
name=\'' . $temp['terminalName'] . '\',
address=\'' . $temp['terminalAddress'] . '\',
company=\'DPD\',
visible=1
';
DB::exec($sql);
} else {
$i++;
$errors[] = $item['regionName'];
}
} else {
$sql = 'UPDATE {{terminals}} SET visible=1 WHERE code=\'' . $item['terminal']['terminalCode'] . '\'';
DB::exec($sql);
}
}
//print 'Ошибок :'.$i;
//print '<pre>'; print_r($errors);
} catch (Exception $e) {
print '<pre>';
print_r($e);
}
}
示例14: run
function run()
{
$id = 1;
if (is_numeric(Funcs::$uri[2])) {
$id = Funcs::$uri[2];
} elseif (is_numeric($_GET['parent'])) {
$id = $_GET['parent'];
} elseif (is_numeric($_GET['id'])) {
$sql = 'SELECT parent FROM {{tree}} WHERE id=' . $_GET['id'];
$id = DB::getOne($sql);
}
View::$layout = 'empty';
View::render('tree/tree', array('tree' => TreeWidget::getTree($id)));
}
示例15: ajax
function ajax()
{
$data = array();
$sql = 'SELECT * FROM {{tree}} WHERE parent=' . $_POST['id'] . ' ORDER BY num';
$list = DB::getAll($sql);
foreach ($list as $item) {
$sql = 'SELECT COUNT(*) FROM {{tree}} WHERE parent=' . $item['id'] . '';
$count = DB::getOne($sql);
if ($count > 0) {
$item['inner'] = 'inner';
}
$data[] = $item;
}
print View::getRenderEmpty('tree/branch', array('sub' => $data));
die;
}