本文整理汇总了PHP中SQLSelect函数的典型用法代码示例。如果您正苦于以下问题:PHP SQLSelect函数的具体用法?PHP SQLSelect怎么用?PHP SQLSelect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SQLSelect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getObjectsByClass
/**
* Title
*
* Description
*
* @access public
*/
function getObjectsByClass($class_name)
{
$class_record = SQLSelectOne("SELECT ID FROM classes WHERE TITLE LIKE '" . DBSafe(trim($class_name)) . "'");
if (!$class_record['ID']) {
return 0;
}
$objects = SQLSelect("SELECT ID, TITLE FROM objects WHERE CLASS_ID='" . $class_record['ID'] . "'");
$sub_classes = SQLSelect("SELECT ID, TITLE FROM classes WHERE PARENT_ID='" . $class_record['ID'] . "'");
if ($sub_classes[0]['ID']) {
$total = count($sub_classes);
for ($i = 0; $i < $total; $i++) {
$sub_objects = getObjectsByClass($sub_classes[$i]['TITLE']);
if ($sub_objects[0]['ID']) {
foreach ($sub_objects as $obj) {
$objects[] = $obj;
}
}
}
}
/*
$total=count($objects);
for($i=0;$i<$total;$i++) {
$objects[$i]=getObject($objects[$i]['TITLE'])
}
*/
return $objects;
}
示例2: updateAccess
function updateAccess($cmd_id, $users_id)
{
SQLSelect("DELETE from tlg_user_cmd where CMD_ID=" . $cmd_id);
$users = explode(",", $users_id);
foreach ($users as $value) {
$recCU = array();
$recCU['CMD_ID'] = $cmd_id;
$recCU['USER_ID'] = $value;
$recCU['ID'] = SQLInsert('tlg_user_cmd', $recCU);
}
}
示例3: run
function run()
{
global $session;
if (isset($session->data["AUTHORIZED"])) {
$this->authorized = 1;
}
if ($this->print) {
$out['PRINT'] = 1;
}
$out["TODAY"] = date('l, F d, Y');
$out["AUTHORIZED"] = $this->authorized;
if ($this->authorized) {
include_once DIR_MODULES . "control_access/control_access.class.php";
$acc = new control_access();
if (!$acc->checkAccess($this->action, 1)) {
$this->redirect("?");
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
clearCache(0);
}
$modules = SQLSelect("SELECT * FROM project_modules WHERE `HIDDEN`='0' ORDER BY CATEGORY, `PRIORITY`, `TITLE`");
$old_cat = 'some_never_should_be_category_name';
for ($i = 0; $i < count($modules); $i++) {
if ($modules[$i]['NAME'] == $this->action) {
$modules[$i]['SELECTED'] = 1;
}
if ($modules[$i]['CATEGORY'] != $old_cat) {
$modules[$i]['NEW_CATEGORY'] = 1;
$old_cat = $modules[$i]['CATEGORY'];
if ($i > 0) {
//echo $last_allow."<br>";
$modules[$last_allow]['LAST_IN_CATEGORY'] = 1;
}
}
if (!$acc->checkAccess($modules[$i]['NAME'])) {
$modules[$i]['DENIED'] = 1;
} else {
$last_allow = $i;
}
if (file_exists(ROOT . 'img/admin/icons/ico_' . $modules[$i]['NAME'] . '_sm.gif')) {
$modules[$i]['ICON_SM'] = ROOTHTML . 'img/admin/icons/ico_' . $modules[$i]['NAME'] . '_sm.gif';
} else {
$modules[$i]['ICON_SM'] = ROOTHTML . 'img/admin/icons/ico_default_sm.gif';
}
}
$modules[$last_allow]['LAST_IN_CATEGORY'] = 1;
$out["SUB_MODULES"] = $modules;
}
$out["ACTION"] = $this->action;
$this->data = $out;
$p = new parser(DIR_TEMPLATES . $this->name . ".html", $this->data, &$this);
return $p->result;
}
示例4: verifUser
/**
* Cette fonction vérifie si le login/passe passés en paramètre sont légaux
* Elle stocke le pseudo de la personne dans des variables de session : session_start doit avoir été appelé...
* Elle enregistre aussi une information permettant de savoir si l'utilisateur qui se connecte est administrateur ou non
* Elle enregistre l'état de la connexion dans une variable de session "connecte" = true
* @pre login et passe ne doivent pas être vides
* @param string $login
* @param string $password
* @return false ou true ; un effet de bord est la création de variables de session
*/
function verifUser($login, $password)
{
// NE PAS ETRE UN LOSER
$sql = "SELECT id, pseudo FROM users WHERE pseudo='{$login}' AND passe='{$password}' ";
$rs = SQLSelect($sql);
if ($rs) {
// connexion acceptee
$tabUsers = parcoursRs($rs);
$dataUser = $tabUsers[0];
$_SESSION["connecte"] = true;
$_SESSION["pseudo"] = $dataUser["pseudo"];
$_SESSION["idUser"] = $dataUser["id"];
$_SESSION["heureConnexion"] = date("H:i:s");
return true;
} else {
session_destroy();
return false;
}
}
示例5: removeMissingSubscribers
function removeMissingSubscribers()
{
$settings = SQLSelect("SELECT * FROM settings WHERE NAME LIKE 'HOOK_EVENT_%' AND TYPE='json'");
$total = count($settings);
for ($i = 0; $i < $total; $i++) {
$data = json_decode($settings[$i]['VALUE'], true);
$changed = 0;
if (is_array($data)) {
foreach ($data as $k => $v) {
$module_name = $k;
if (!file_exists(DIR_MODULES . 'modules/' . $module_name . '/' . $module_name . '.class.php')) {
unset($data[$module_name]);
$changed = 1;
}
}
if ($changed) {
$settings[$i]['VALUE'] = json_encode($data);
SQLUpdate('settings', $settings[$i]);
}
}
}
}
示例6: checkFromCache
/**
* Summary of checkFromCache
* @param mixed $key Key
* @return mixed
*/
function checkFromCache($key)
{
global $memory_cache;
if (isset($_SERVER['REQUEST_METHOD']) && !is_array($memory_cache)) {
$tmp = SQLSelect("SELECT KEYWORD, DATAVALUE FROM cached_values");
$total = count($tmp);
for ($i = 0; $i < $total; $i++) {
if ($tmp[$i]['DATAVALUE'] != '(too big)') {
$memory_cache[$tmp[$i]['KEYWORD']] = $tmp[$i]['DATAVALUE'];
}
}
}
if (isset($memory_cache[$key])) {
return $memory_cache[$key];
}
$rec = SQLSelectOne("SELECT * FROM cached_values WHERE KEYWORD = '" . DBSafe($key) . "'");
if ($rec['KEYWORD'] && $rec['DATAVALUE'] != '(too big)') {
return $rec['DATAVALUE'];
} else {
return false;
}
}
示例7: str_replace
if (!$qry) {
$qry = "1";
}
// FIELDS ORDER
global $sortby_system_errors;
if (!$sortby_system_errors) {
$sortby_system_errors = $session->data['system_errors_sort'];
} else {
if ($session->data['system_errors_sort'] == $sortby_system_errors) {
if (Is_Integer(strpos($sortby_system_errors, ' DESC'))) {
$sortby_system_errors = str_replace(' DESC', '', $sortby_system_errors);
} else {
$sortby_system_errors = $sortby_system_errors . " DESC";
}
}
$session->data['system_errors_sort'] = $sortby_system_errors;
}
$sortby_system_errors = "ACTIVE DESC, LATEST_UPDATE DESC, CODE";
$out['SORTBY'] = $sortby_system_errors;
// SEARCH RESULTS
$res = SQLSelect("SELECT * FROM system_errors WHERE {$qry} ORDER BY " . $sortby_system_errors);
if ($res[0]['ID']) {
colorizeArray($res);
$total = count($res);
for ($i = 0; $i < $total; $i++) {
// some action for every record if required
$tmp = explode(' ', $res[$i]['LATEST_UPDATE']);
$res[$i]['LATEST_UPDATE'] = fromDBDate($tmp[0]) . " " . $tmp[1];
}
$out['RESULT'] = $res;
}
示例8: usual
/**
* FrontEnd
*
* Module frontend
*
* @access public
*/
function usual(&$out)
{
global $session;
if ($this->action == 'addevent') {
global $mode;
$this->mode = $mode;
if ($this->mode == 'update') {
global $type;
global $window;
global $details;
global $terminal_to;
global $user_to;
$event = array();
$event['EVENT_TYPE'] = $type;
$event['WINDOW'] = $window;
$event['DETAILS'] = $details;
$event['TERMINAL_TO'] = $terminal_to;
$event['TERMINAL_FROM'] = $session->data['TERMINAL'];
$event['USER_TO'] = $user_to;
$event['USER_FROM'] = $session->data['USERNAME'];
$event['ADDED'] = date('Y-m-d H:i:s');
$event['EXPIRE'] = date('Y-m-d H:i:s', time() + 5 * 60);
//5 minutes expire
SQLInsert('events', $event);
}
$terminals = SQLSelect("SELECT * FROM terminals ORDER BY TITLE");
$total = count($terminals);
for ($i = 0; $i < $total; $i++) {
if ($terminals[$i]['NAME'] == $session->data['TERMINAL']) {
$terminals[$i]['SELECTED'] = 1;
$out['TERMINAL_TITLE'] = $terminals[$i]['TITLE'];
}
}
$out['TERMINALS'] = $terminals;
$users = SQLSelect("SELECT * FROM users ORDER BY NAME");
$total = count($users);
for ($i = 0; $i < $total; $i++) {
if ($users[$i]['USERNAME'] == $session->data['USERNAME']) {
$users[$i]['SELECTED'] = 1;
$out['USER_TITLE'] = $users[$i]['NAME'];
}
}
$out['USERS'] = $users;
}
if ($this->action == 'getnextevent') {
if (!$session->data['TERMINAL']) {
$session->data['TERMINAL'] = 'temp' . date('YmdHis');
}
//echo "next event for ".$session->data['USERNAME']." on ".$session->data['TERMINAL'];//.date('H:i:s')
SQLExec("DELETE FROM events WHERE EXPIRE<NOW() AND EVENT_TYPE!='system'");
$qry = "1";
//$qry.=" AND TERMINAL_FROM!='".DBSafe($session->data['TERMINAL'])."'";
$qry .= " AND EVENT_TYPE!='system'";
$qry .= " AND PROCESSED=0";
$qry .= " AND (TERMINAL_TO='*' OR TERMINAL_TO='" . DBSafe($session->data['TERMINAL']) . "')";
$qry .= " AND (USER_TO='*' OR USER_TO='" . DBSafe($session->data['USERNAME']) . "')";
$event = SQLSelectOne("SELECT * FROM events WHERE {$qry} ORDER BY ADDED");
if ($event['ID']) {
$res = $event['ID'] . '|' . $event['EVENT_TYPE'] . '|' . $event['WINDOW'] . '|' . str_replace("\n", '\\n', $event['DETAILS']);
echo $res;
$event['PROCESSED'] = 1;
SQLUpdate('events', $event);
}
exit;
}
}
示例9: calculateTheDistance
$distance = calculateTheDistance($rec['LAT'], $rec['LON'], $prev_log['LAT'], $prev_log['LON']);
if ($distance > 100) {
//we're moving
$objectIsMoving = $user['LINKED_OBJECT'] . '.isMoving';
setGlobal($objectIsMoving, 1);
clearTimeOut($user['LINKED_OBJECT'] . '_moving');
// stopped after 15 minutes of inactivity
setTimeOut($user['LINKED_OBJECT'] . '_moving', "setGlobal('" . $objectIsMoving . "', 0);", 15 * 60);
}
}
}
}
// checking locations
$lat = (double) $_REQUEST['latitude'];
$lon = (double) $_REQUEST['longitude'];
$locations = SQLSelect("SELECT * FROM gpslocations");
$total = count($locations);
$location_found = 0;
for ($i = 0; $i < $total; $i++) {
if (!$locations[$i]['RANGE']) {
$locations[$i]['RANGE'] = GPS_LOCATION_RANGE_DEFAULT;
}
$distance = calculateTheDistance($lat, $lon, $locations[$i]['LAT'], $locations[$i]['LON']);
//echo ' (' . $locations[$i]['LAT'] . ' : ' . $locations[$i]['LON'] . ') ' . $distance . ' m';
if ($distance <= $locations[$i]['RANGE']) {
//Debmes("Device (" . $device['TITLE'] . ") NEAR location " . $locations[$i]['TITLE']);
$location_found = 1;
if ($user['LINKED_OBJECT']) {
setGlobal($user['LINKED_OBJECT'] . '.seenAt', $locations[$i]['TITLE']);
}
// we are at location
示例10: IN
if ($rec['SUB_LIST']!='') {
$parents=SQLSelect("SELECT ID, TITLE FROM $table_name WHERE ID!='".$rec['ID']."' AND ID NOT IN (".$rec['SUB_LIST'].") ORDER BY TITLE");
} else {
$parents=SQLSelect("SELECT ID, TITLE FROM $table_name WHERE ID!='".$rec['ID']."' ORDER BY TITLE");
}
$out['PARENTS']=$parents;
}
if (is_array($rec)) {
foreach($rec as $k=>$v) {
if (!is_array($v)) {
$rec[$k]=htmlspecialchars($v);
}
}
}
outHash($rec, $out);
$out['SCRIPTS']=SQLSelect("SELECT ID, TITLE FROM scripts ORDER BY TITLE");
if ($out['ID']) {
$same_level=SQLSelect("SELECT * FROM commands WHERE PARENT_ID='".$out['PARENT_ID']."' ORDER BY PRIORITY DESC, TITLE");
$out['SAME_LEVEL']=$same_level;
$children=SQLSelect("SELECT * FROM commands WHERE PARENT_ID='".$out['ID']."' ORDER BY PRIORITY DESC, TITLE");
if ($children) {
$out['CHILDREN']=$children;
}
}
?>
示例11: str_replace
if (!$qry) {
$qry = "1";
}
// FIELDS ORDER
global $sortby_elements;
if (!$sortby_elements) {
$sortby_elements = $session->data['elements_sort'];
} else {
if ($session->data['elements_sort'] == $sortby_elements) {
if (Is_Integer(strpos($sortby_elements, ' DESC'))) {
$sortby_elements = str_replace(' DESC', '', $sortby_elements);
} else {
$sortby_elements = $sortby_elements . " DESC";
}
}
$session->data['elements_sort'] = $sortby_elements;
}
if (!$sortby_elements) {
$sortby_elements = "TITLE";
}
$out['SORTBY'] = $sortby_elements;
// SEARCH RESULTS
$res = SQLSelect("SELECT * FROM elements WHERE {$qry} ORDER BY " . $sortby_elements);
if ($res[0]['ID']) {
colorizeArray($res);
$total = count($res);
for ($i = 0; $i < $total; $i++) {
// some action for every record if required
}
$out['RESULT'] = $res;
}
示例12: propertySetHandle
/**
* Title
*
* Description
*
* @access public
*/
function propertySetHandle($object, $property, $value)
{
$commands = SQLSelect("SELECT * FROM commands WHERE LINKED_OBJECT LIKE '" . DBSafe($object) . "' AND LINKED_PROPERTY LIKE '" . DBSafe($property) . "'");
$total = count($commands);
for ($i = 0; $i < $total; $i++) {
$commands[$i]['CUR_VALUE'] = $value;
SQLUpdate('commands', $commands[$i]);
}
}
示例13: str_replace
if (!$sortby) {
$sortby = $session->data['commands_sort'];
} else {
if ($session->data['commands_sort'] == $sortby) {
if (Is_Integer(strpos($sortby, ' DESC'))) {
$sortby = str_replace(' DESC', '', $sortby);
} else {
$sortby = $sortby . " DESC";
}
}
$session->data['commands_sort'] = $sortby;
}
$sortby = "PRIORITY DESC, TITLE";
$out['SORTBY'] = $sortby;
// SEARCH RESULTS
$res = SQLSelect("SELECT * FROM commands WHERE {$qry} ORDER BY {$sortby}");
if ($res[0]['ID']) {
if ($this->action != 'admin') {
$dynamic_res = array();
$total = count($res);
for ($i = 0; $i < $total; $i++) {
if ($res[$i]['SMART_REPEAT'] && $res[$i]['LINKED_OBJECT']) {
$obj = getObject($res[$i]['LINKED_OBJECT']);
$objects = getObjectsByClass($obj->class_id);
$total_o = count($objects);
for ($io = 0; $io < $total_o; $io++) {
$rec = $res[$i];
$rec['ID'] = $res[$i]['ID'] . '_' . $objects[$io]['ID'];
$rec['LINKED_OBJECT'] = $objects[$io]['TITLE'];
$rec['DATA'] = str_replace('%' . $res[$i]['LINKED_OBJECT'] . '.', '%' . $rec['LINKED_OBJECT'] . '.', $rec['DATA']);
$rec['CUR_VALUE'] = getGlobal($rec['LINKED_OBJECT'] . '.' . $rec['LINKED_PROPERTY']);
示例14: edit_btdevices
/**
* btdevices edit/add
*
* @access public
*/
function edit_btdevices(&$out, $id)
{
$rec = SQLSelectOne("SELECT * FROM btdevices WHERE ID='" . (int) $id . "'");
if ($this->mode == 'update') {
global $title;
global $user_id;
$rec['TITLE'] = $title;
$rec['USER_ID'] = $user_id;
SQLUpdate('btdevices', $rec);
$this->redirect("?");
}
$rec['LOG'] = nl2br($rec['LOG']);
outHash($rec, $out);
$out['USERS'] = SQLSelect("SELECT * FROM users ORDER BY NAME");
}
示例15: getConversation
function getConversation($idConv)
{
// Récupère les données de la conversation (theme, active)
$SQL = "SELECT theme, active FROM conversations WHERE id='{$idConv}'";
$listConversations = parcoursRs(SQLSelect($SQL));
// Attention : parcoursRS nous renvoie un tableau contenant potentiellement PLUSIEURS CONVERSATIONS
// Il faut renvoyer uniquement la première case de ce tableau, c'est à dire la case 0
// OU false si la conversation n'existe pas
if (count($listConversations) == 0) {
return false;
} else {
return $listConversations[0];
}
}