本文整理汇总了PHP中db::q方法的典型用法代码示例。如果您正苦于以下问题:PHP db::q方法的具体用法?PHP db::q怎么用?PHP db::q使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db
的用法示例。
在下文中一共展示了db::q方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: availableElems
function availableElems()
{
$db = new db();
$log = ADLog::getInstance();
/*
* Extract all Policy Elements for select list below
*/
$q = "SELECT id, elementName FROM compliancePolElem WHERE status = 1 ORDER BY elementName ASC";
$result = $db->q($q);
$num_rows = mysql_numrows($result);
if (!$result || $num_rows < 0) {
$log->Warn("Failure: Problem Displaying compliancePolElem options (File: " . $_SERVER['PHP_SELF'] . ")");
echo "Error displaying info for availableElems() function";
return;
}
if ($num_rows == 0) {
$log->Warn("Failure: Problem Displaying availableElems() - no options returned (File: " . $_SERVER['PHP_SELF'] . ")");
echo "Database table empty";
return;
}
for ($i = 0; $i < $num_rows; $i++) {
$id = mysql_result($result, $i, "id");
$elementName = mysql_result($result, $i, "elementName");
echo "<option value=" . $id . ">" . $elementName . "</option>";
}
}
示例2: snippetsOptions
function snippetsOptions()
{
$db = new db();
$log = ADLog::getInstance();
/*
* Extract all snippets for select list below
*/
$q = "SELECT id, snippetName\n\t\t\t\t\t\tFROM snippets \n\t\t\t\t\t\tORDER BY snippetName ASC";
$result = $db->q($q);
$num_rows = mysql_numrows($result);
if (!$result || $num_rows < 0) {
$log->Warn("Failure: Problem Displaying snippetsOptions() options (File: " . $_SERVER['PHP_SELF'] . ")");
echo "Error displaying info for reportsOptions() function";
return;
}
if ($num_rows == 0) {
$log->Warn("Failure: Problem Displaying snippetsOptions() - no options returned (File: " . $_SERVER['PHP_SELF'] . ")");
echo "Database table empty";
return;
}
for ($i = 0; $i < $num_rows; $i++) {
$id = mysql_result($result, $i, "id");
$snippetName = mysql_result($result, $i, "snippetName");
echo "<option value=snippetId-" . $id . ">" . $snippetName . "</option>";
}
}
示例3: view
public function view()
{
if (user::issetRight('delete')) {
ui::newButton(lang::get('BTN_CLEAR_JORNAL'), 'javascript:clearJornal();');
}
ui::addLeftButton('Системный журнал', 'system_view');
ui::addLeftButton('Журнал БД', 'db_view');
function getState($val)
{
if ($val == info) {
return 'info';
} else {
if ($val == error) {
return 'error';
} else {
if ($val == warning) {
return 'warning';
}
}
}
}
function getEditUser($val, $obj)
{
if (user::issetRight('user_upd', 'users')) {
return '<a href="' . system::au() . '/users/user_upd/' . $obj['rev_user_id'] . '" target="_blank">' . $val . '</a>';
} else {
return $val;
}
}
$count = db::q('SELECT count(rev_id) count FROM <<revue>>, <<objects>> WHERE rev_obj_id = o_id;', value);
$max_count = uiTable::getMaxCount();
if (uiTable::getCurPage() != 1) {
$niz = empty($start_pos) ? uiTable::getCurPage() * $max_count - $max_count : 0;
$limit = ' LIMIT ' . $niz . ', ' . $max_count;
} else {
$limit = ' LIMIT ' . $max_count;
}
$mas = db::q('SELECT rev_state, rev_user, rev_user_id, rev_datetime,
concat(rev_message, " <b>", o_name, "</b>") rev_msg, rev_ip
FROM <<revue>>, <<objects>>
WHERE rev_obj_id = o_id
ORDER BY rev_datetime DESC ' . $limit, records);
/*
Сделать фильтры:
- важность
- пользователь
- тип данных
- периуд времени
- IP
*/
$table = new uiTable($mas, $count);
$table->addColumn('rev_state', 'Важность', 0, false, false, 'getState');
$table->addColumn('rev_user', 'Пользователь', 0, false, false, 'getEditUser');
$table->addColumn('rev_msg', 'Действие', 400);
$table->addColumn('rev_datetime', 'Дата / Время', 0, false, false, 'viewDateTime2');
$table->addColumn('rev_ip', 'IP');
$table->emptyText('В журнале нет записей!');
return $table->getHTML();
}
示例4: defAction
public function defAction()
{
$file = @fopen(ROOT_DIR . "/revue.log", "w");
@fclose($file);
db::q('DELETE FROM <<revue>>');
echo 'delete';
system::stop();
}
示例5: getAll
/**
* @return array
* @param boolean $prinud - Если true, принудительно читает данные из БД.
* @desc Вернет все языковые версии системы
*/
static function getAll($prinud = false)
{
if (empty(self::$langs) || $prinud) {
$mas = db::q('SELECT *, l_id id FROM <<langs>>;', records);
self::$langs = array();
while (list($key, $lang) = each($mas)) {
self::$langs[$lang['l_id']] = $lang;
self::$langs_rel[$lang['l_prefix']] = $lang['l_id'];
}
}
return self::$langs;
}
示例6: deleteKey
private static function deleteKey($id)
{
$num = self::findInMas($id);
if ($num !== false) {
$child = db::q('SELECT r_id FROM <<register>> WHERE r_section_id="' . $id . '";', records);
for ($i = 0; $i < count($child); $i++) {
self::deleteKey($child[$i]['r_id']);
}
db::q('DELETE FROM <<register>> WHERE r_id="' . $id . '";');
array_splice(self::$keys, $num, 1);
return true;
} else {
return false;
}
}
示例7: getPopularForSection
/**
* @return integer - ID шаблона
* @param integer $obj_id - ID раздела сайта
* @desc Определяет популярный (часто используемый) шаблон в указанном разделе
*/
static function getPopularForSection($obj_id)
{
$sql = empty($obj_id) ? ' r_parent_id is NULL and ' : ' r_parent_id = "' . $obj_id . '" and ';
$mas = db::q('SELECT template_id, template2_id
FROM <<pages>>, <<objects>>, <<rels>>
WHERE ' . $sql . '
r_field_id is NULL and
r_children_id = o_id and
p_obj_id = o_id and
o_to_trash = 0
GROUP BY o_id;', records);
if (count($mas) > 0) {
return array(self::getPopTemplate($mas, 'template_id'), self::getPopTemplate($mas, 'template2_id'));
} else {
if (!empty($obj_id)) {
return array(ormPages::get($obj_id)->__get('template_id'), ormPages::get($obj_id)->__get('template2_id'));
} else {
return array(0, 0);
}
}
}
示例8: defAction
public function defAction()
{
function getUserName($val, $obj)
{
$name = $val . ' (' . $obj['c_email'] . ')';
if (!empty($obj['c_user_id']) && user::issetRight('user_upd', 'users')) {
$url = system::au() . '/users/user_upd/' . $obj['c_user_id'];
$name = '<a href="' . $url . '" target="_blank">' . $name . '</a>';
}
return $name;
}
function getCommentText($val, $obj)
{
return strip_tags($val);
}
$count = db::q('SELECT count(c_id) count FROM <<comments>>;', value);
$max_count = uiTable::getMaxCount();
if (uiTable::getCurPage() != 1) {
$niz = empty($start_pos) ? uiTable::getCurPage() * $max_count - $max_count : 0;
$limit = 'LIMIT ' . $niz . ', ' . $max_count;
} else {
$limit = 'LIMIT ' . $max_count;
}
$sql = 'SELECT c_id id, c_active active, c_text, c_username, c_publ_date, c_email, c_user_id
FROM <<comments>> ORDER BY c_publ_date DESC ' . $limit . ';';
$mas = db::q($sql, records);
$table = new uiTable($mas, $count);
$table->addColumn('c_text', 'Текст', 500, 0, 1, 'getCommentText');
$table->addColumn('c_username', 'Пользователь', 200, 0, 0, 'getUserName');
$table->addColumn('c_publ_date', 'Дата создания', 200, 0, 1, 'viewDateTime');
$table->defaultRight('comment_upd');
$table->addRight('comment_upd', 'edit', single);
$table->addRight('comment_act', 'active', multi);
$table->addRight('comment_del', 'drop', multi);
return $table->getHTML();
}
示例9: modBindsList
public static function modBindsList($mod="",$method="",$cid=0)
{
$binds=array();
if(!$mod)return $binds;
$hookRender=self::$c->modHookName(self::$class);
if(!$method || ($method==$hookRender))$methodSql="((`b`.`method`='') OR (`b`.`method`='{$hookRender}'))";
else $methodSql="`b`.`method`='{$method}'";
$q="SELECT `c`.`id`,`c`.`alias`,`b`.`sid`,`b`.`ord`,`b`.`pages`,`b`.`args` FROM ".db::tnm(self::$class."_binds")." `b`
INNER JOIN ".db::tn("mods")." `m` ON `m`.`id`=`b`.`mid`
LEFT JOIN ".db::tnm(self::$class."_bind_adds")." `ba` ON `ba`.`bid`=`b`.`id`
LEFT JOIN ".db::tnm("content")." `c` ON `c`.`id`=`ba`.`cid`
WHERE `m`.`class`='{$mod}' AND {$methodSql}".($cid?(" AND (ISNULL(`c`.`id`) OR (`c`.`id`={$cid}))"):"");
$r=db::q($q,true);
while($rec=@mysql_fetch_assoc($r))
{
$rec["id"]=0+$rec["id"];
$rec["alias"]="".$rec["alias"];
$rec["sid"]=0+$rec["sid"];
$rec["ord"]=0+$rec["ord"];
$rec["pages"]="".$rec["pages"];
$rec["args"]="".$rec["args"];
if($rec["pages"]=="none" && (!$rec["id"]))continue;
$binds[]=@array_merge(array(),$rec);
}
return $binds;
}
示例10: getGroupBySName
function getGroupBySName($name, $only_id = false)
{
$sname = system::checkVar($name, isVarName);
if ($sname !== false) {
$sql = 'SELECT fg_id FROM <<fgroup>>
WHERE fg_class_id = "' . $this->id . '" and fg_sname="' . $sname . '";';
$id = db::q($sql, value);
if ($id !== false) {
if (!$only_id) {
return new ormFieldsGroup($id);
} else {
return $id;
}
} else {
return false;
}
}
}
示例11: modsListAll
public function modsListAll($fields=array(),$filters=array())
{
if(is_string($fields))$fields=array($fields);
$len=count($fields);
if($len)
{
$known=db::tFields("mods");
for($c=($len-1);$c>0;$c--)
{
$name=trim($fields[$c],"`");
if(!in_array($name,$known))unset($fields[$c]);
}
}
if(!count($fields))$fields=array("id","class");
if($filters)$filtersSQL=db::filtersMake($filters,true);
else $filtersSQL="";
$r=db::q("SELECT `".implode("`,`",$fields)."` FROM ".db::tn("mods").($filtersSQL?(" WHERE".$filtersSQL):""),true);
while($rec=@mysql_fetch_assoc($r))$recs[]=$rec;
return $recs;
}
示例12: delete
public function delete()
{
if (!empty($this->id) && $this->id != 1) {
$is_ok = true;
$list = languages::getAll();
while (list($key, $val) = each($list)) {
// Удаление страниц
$tmp = ormPages::delAllFor($this->id, $val['id']);
if (!$tmp) {
$is_ok = $tmp;
} else {
// Удаление прав на домен
db::q('DELETE FROM <<modules_rights>>
WHERE mr_name = "' . $val['id'] . ' ' . $this->id . '"
and mr_mod_id = "3";');
}
}
// Удаление домена
if ($is_ok) {
$is_ok = db::q('DELETE FROM <<domains>> WHERE d_id = "' . $this->id . '";');
if ($is_ok !== false) {
// Удаление настроек
reg::delKey('/structure/' . $this->id);
system::log('Удален домен "' . $this->values['d_name'] . '" (id:' . $this->id . ')', warning);
return true;
} else {
system::log('Произошла ошибка при удалении домена "' . $this->values['d_name'] . '" (id:' . $this->id . ')', error);
$this->newError(12, 'Произошла ошибка при удалении домена "' . $this->values['d_name'] . '"!');
}
} else {
system::log('Пользователь пытался удалить домен "' . $this->values['d_name'] . '" (id:' . $this->id . '), но ему не хватило прав на удаление всех страниц!', error);
$this->newError(63, 'Вы не можете удалить домен "' . $this->values['d_name'] . '", т.к. не имеете прав на удаление некоторых страниц!');
}
}
return false;
}
示例13: db
border-radius: 8px;
background-image: linear-gradient(#FFF, #ECF1F7);
background-clip: padding-box;
box-shadow: 2px 2px 4px #999;
max-width:150px;
}
</style>
</head>
<body>
<?php
$db = new db();
/* Get all snippets for the snippetSelect Selection list */
$snippetQ = $db->q('SELECT `id`, `snippetName` FROM `snippets`
ORDER BY `snippetName` ASC');
?>
<div id="snippetSelectDiv" style="width:500px;">
<fieldset style="width:500px;">
<label for="snippetSelect" style="font-size:12px; float:left;">Snippet Name:</label>
<legend>Select Config Snippet</legend>
<select name="snippetSelect[]" id ="snippetSelect" style="font-size:14px; float:left;margin-left:10px;" onchange="switchSnippet(this.value)">
<?php
echo "<option value=\"\"> Select </option>";
while ($row = mysql_fetch_assoc($snippetQ)) {
echo "<option value=" . $row['id'] . ">" . $row['snippetName'] . "</option>";
}
?>
</select>
<div style="clear:both;"></div>
示例14: header
*/
/* begin delete check */
if (isset($_POST['delete'])) {
if (ctype_digit($_POST['id'])) {
$id = $_POST['id'];
} else {
$errors['Fail'] = "Fatal: id not of type int for getRow";
$log->Fatal("Fatal: id not of type int for getRow - " . $_SERVER['PHP_SELF'] . ")");
$_SESSION['errors'] = $errors;
session_write_close();
header("Location: " . $config_basedir . "useradmin.php?error");
exit;
}
/* the query*/
$q = "UPDATE users SET status = 2 WHERE id = " . $id . ";";
if ($result = $db->q($q)) {
$log->Info("Success: Deleted user of ID: " . $id . " in DB (File: " . $_SERVER['PHP_SELF'] . ")");
$response = json_encode(array('success' => true));
} else {
$log->Warn("Failure: Unable to delete user of ID: " . $id . " in DB (File: " . $_SERVER['PHP_SELF'] . ")");
$response = json_encode(array('failure' => true));
}
echo $response;
} elseif (isset($_GET['getRow']) && isset($_GET['id'])) {
if (ctype_digit($_GET['id'])) {
$id = $_GET['id'];
} else {
$errors['Fail'] = "Fatal: id not of type int for getRow";
$log->Fatal("Fatal: id not of type int for getRow - " . $_SERVER['PHP_SELF'] . ")");
$_SESSION['errors'] = $errors;
session_write_close();
示例15: getAllCount
/**
* @return integer
* @param integer $obj_id - ID объекта
* @param boolean $only_active - Если true - вернет количество активных (проверенных) комментариев
* @desc Вернет общее количество комментариев для указанного объекта
*/
public static function getAllCount($obj_id, $only_active = false)
{
$obj_id = system::checkVar($obj_id, isInt);
if ($obj_id) {
$where = $only_active ? ' and c_active = 1' : '';
$count = db::q('SELECT count(c_id) FROM <<comments>> WHERE c_obj_id = "' . $obj_id . '" ' . $where . ';', value);
if ($count) {
return $count;
}
}
return 0;
}