本文整理汇总了PHP中SQLExec函数的典型用法代码示例。如果您正苦于以下问题:PHP SQLExec函数的具体用法?PHP SQLExec怎么用?PHP SQLExec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SQLExec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveToCache
function saveToCache($key, $value, $ttl = 60)
{
if (isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST')) {
global $memory_cache;
$memory_cache[$key] = $value;
}
if (strlen($value) <= 255) {
$rec = array('KEYWORD' => $key, 'DATAVALUE' => $value, 'EXPIRE' => date('Y-m-d H:i:s', time() + $ttl));
} else {
$rec = array('KEYWORD' => $key, 'DATAVALUE' => '(too big)', 'EXPIRE' => date('Y-m-d H:i:s', time() + $ttl));
}
SQLExec("REPLACE INTO cached_values (KEYWORD, DATAVALUE, EXPIRE) VALUES('" . DBSafe($rec['KEYWORD']) . "', '" . DBSafe($rec['DATAVALUE']) . "', '" . $rec['EXPIRE'] . "')");
}
示例2: SQLSelectOne
*/
$value['VALUE'] = ${"value" . $props[$i]['ID']};
}
$props[$i]['VALUE'] = $value['VALUE'];
$props[$i]['LINKED_MODULES'] = $value['LINKED_MODULES'];
}
$out['PROPERTIES'] = $props;
}
// step: methods
if ($this->tab == 'methods') {
global $overwrite;
global $delete_meth;
if ($delete_meth) {
$method = SQLSelectOne("SELECT * FROM methods WHERE ID='" . (int) $delete_meth . "'");
$my_meth = SQLSelectOne("SELECT * FROM methods WHERE OBJECT_ID='" . $rec['ID'] . "' AND TITLE LIKE '" . DBSafe($method['TITLE']) . "'");
SQLExec("DELETE FROM methods WHERE OBJECT_ID='" . $rec['ID'] . "' AND TITLE LIKE '" . DBSafe($method['TITLE']) . "'");
}
if ($overwrite) {
global $method_id;
$method = SQLSelectOne("SELECT * FROM methods WHERE ID='" . (int) $method_id . "'");
$out['METHOD_CLASS_ID'] = $method['CLASS_ID'];
$tmp = SQLSelectOne("SELECT * FROM classes WHERE ID='" . $method['CLASS_ID'] . "'");
$out['METHOD_CLASS_TITLE'] = $tmp['TITLE'];
$out['METHOD_TITLE'] = $method['TITLE'];
$out['METHOD_TITLE_URL'] = urlencode($method['TITLE']);
$out['OBJECT_TITLE'] = $rec['TITLE'];
$out['OBJECT_TITLE_URL'] = urlencode($rec['TITLE']);
$out['METHOD_ID'] = $method['ID'];
$my_meth = SQLSelectOne("SELECT * FROM methods WHERE OBJECT_ID='" . $rec['ID'] . "' AND TITLE LIKE '" . DBSafe($method['TITLE']) . "'");
if ($this->mode == 'update') {
$ok = 1;
示例3: recLocalTime
function recLocalTime($table, $id, $gmt, $field = "ADDED")
{
// UPDATES TIMESTAMP FIELD USING GMT
$rec = SQLSelectOne("SELECT ID, DATE_FORMAT({$field}, '%Y-%m-%d %H:%i') as DAT FROM {$table} WHERE ID='{$id}'");
if (isset($rec["ID"])) {
$new_dat = setLocalTime($rec['DAT'], $gmt);
SQLExec("UPDATE {$table} SET {$field}='{$new_dat}' WHERE ID='{$id}'");
}
}
示例4: uninstall
/**
* Uninstall
*
* Module uninstall routine
*
* @access public
*/
function uninstall()
{
SQLExec('DROP TABLE IF EXISTS events');
parent::uninstall();
}
示例5: SQLSelectOne
global $switch_scene_new;
global $state_id;
global $state_delete;
global $state_clone;
global $ext_url_new;
global $homepage_id_new;
global $open_scene_id_new;
global $do_on_click_new;
global $priority_new;
global $code_new;
if ($state_delete && $state_rec['ID']) {
$state_rec = SQLSelectOne("SELECT * FROM elm_states WHERE ID='" . $state_id . "'");
foreach ($state_rec as $k => $v) {
$out['STATE_' . $k] = '';
}
SQLExec("DELETE FROM elm_states WHERE ID='" . $state_rec['ID'] . "'");
} elseif ($state_title_new) {
$state_rec['ELEMENT_ID'] = $element['ID'];
$state_rec['TITLE'] = $state_title_new;
$state_rec['IMAGE'] = $image_new;
$state_rec['HTML'] = $html_new;
$state_rec['IS_DYNAMIC'] = $is_dynamic_new;
$state_rec['LINKED_OBJECT'] = $linked_object_new;
$state_rec['LINKED_PROPERTY'] = $linked_property_new;
$state_rec['CONDITION'] = $condition_new;
$state_rec['CONDITION_VALUE'] = $condition_value_new;
$state_rec['CONDITION_ADVANCED'] = $condition_advanced_new;
$state_rec['PRIORITY'] = (int) $priority_new;
if ($do_on_click_new != 'run_script') {
$script_id_new = 0;
}
示例6: run
//.........这里部分代码省略.........
} else {
$new[$i]['ICON'] = ROOTHTML . 'img/admin/icons/ico_default.gif';
}
}
$out["MODULES"] = $new;
if (file_exists(DIR_MODULES . 'saverestore/saverestore.class.php')) {
$out['CHECK_UPDATES'] = 1;
global $check;
if ($check) {
include_once DIR_MODULES . 'saverestore/saverestore.class.php';
$sv = new saverestore();
$sv->checkUpdates($o);
if ($o['NO_UPDATES'] || $o['ERROR_CHECK']) {
echo "no";
} else {
echo "yes";
}
exit;
}
}
} elseif ($this->action == "logoff") {
unset($session->data['AUTHORIZED']);
unset($session->data['USER_NAME']);
unset($session->data['USERNAME']);
$this->owner->redirect("?");
} elseif ($this->action == "admin") {
global $mode;
global $mode2;
global $id;
if (!$session->data['AUTHORIZED']) {
exit;
}
if ($mode == "delete") {
SQLExec("DELETE FROM admin_users WHERE ID='" . $id . "'");
$this->redirect("?");
}
if ($mode == "edit") {
$user = SQLSelectOne("SELECT * FROM admin_users WHERE ID='" . $id . "'");
if ($mode2 == "update") {
$ok = 1;
global $name;
global $login;
global $password;
global $email;
global $comments;
global $sel;
global $private;
global $EMAIL_ORDERS;
global $EMAIL_INVENTORY;
$user['NAME'] = $name;
if (!checkGeneral($user['NAME'])) {
$out["ERR_NAME"] = 1;
$ok = 0;
}
$user['LOGIN'] = $login;
if (!checkGeneral($user['LOGIN'])) {
$out["ERR_LOGIN"] = 1;
$ok = 0;
}
if ($password != '' || !$user['ID']) {
$user['PASSWORD'] = $password;
if (!checkGeneral($user['PASSWORD'])) {
$out["ERR_PASSWORD"] = 1;
$ok = 0;
} else {
$user['PASSWORD'] = md5($user['PASSWORD']);
示例7: trim
$rec['KEEP_HISTORY'] = (int) $keep_history;
global $onchange;
$rec['ONCHANGE'] = trim($onchange);
//updating 'Description' (text)
global $description;
$rec['DESCRIPTION'] = $description;
//UPDATING RECORD
if ($ok) {
if ($rec['ID']) {
SQLUpdate($table_name, $rec);
// update
if (!$rec['KEEP_HISTORY']) {
$pvalues = SQLSelect("SELECT * FROM pvalues WHERE PROPERTY_ID='" . $rec['ID'] . "'");
$total = count($pvalues);
for ($i = 0; $i < $total; $i++) {
SQLExec("DELETE FROM phistory WHERE VALUE_ID='" . $pvalues[$i]['ID'] . "'");
}
}
} else {
$new_rec = 1;
$rec['ID'] = SQLInsert($table_name, $rec);
// adding new record
}
$out['OK'] = 1;
} else {
$out['ERR'] = 1;
}
}
if (is_array($rec)) {
foreach ($rec as $k => $v) {
if (!is_array($v)) {
示例8: uninstall
/**
* Uninstall
*
* Module uninstall routine
*
* @access public
*/
function uninstall()
{
SQLExec('DROP TABLE IF EXISTS rss_channels');
SQLExec('DROP TABLE IF EXISTS rss_items');
parent::uninstall();
}
示例9: SQLUpdate
//updating 'DEVICEID' (varchar)
global $deviceid;
$rec['DEVICEID'] = $deviceid;
//UPDATING RECORD
if ($ok) {
if ($rec['ID']) {
SQLUpdate($table_name, $rec);
// update
} else {
$new_rec = 1;
$rec['ID'] = SQLInsert($table_name, $rec);
// adding new record
}
$out['OK'] = 1;
if ($rec['DEVICEID']) {
SQLExec("UPDATE gpslog SET DEVICE_ID='" . $rec['ID'] . "' WHERE DEVICE_ID=0 AND DEVICEID='" . DBSafe($rec['DEVICEID']) . "'");
}
} else {
$out['ERR'] = 1;
}
}
//options for 'USER_ID' (select)
$tmp = SQLSelect("SELECT ID, NAME FROM users ORDER BY NAME");
$users_total = count($tmp);
for ($users_i = 0; $users_i < $users_total; $users_i++) {
$user_id_opt[$tmp[$users_i]['ID']] = $tmp[$users_i]['NAME'];
}
for ($i = 0; $i < $users_total; $i++) {
if ($rec['USER_ID'] == $tmp[$i]['ID']) {
$tmp[$i]['SELECTED'] = 1;
}
示例10: uninstall
/**
* Uninstall
*
* Module uninstall routine
*
* @access public
*/
function uninstall()
{
SQLExec('DROP TABLE IF EXISTS gpslog');
SQLExec('DROP TABLE IF EXISTS gpslocations');
SQLExec('DROP TABLE IF EXISTS gpsdevices');
SQLExec('DROP TABLE IF EXISTS gpsactions');
parent::uninstall();
}
示例11: uninstall
/**
* Uninstall
*
* Module uninstall routine
*
* @access public
*/
function uninstall()
{
SQLExec('DROP TABLE IF EXISTS scenes');
SQLExec('DROP TABLE IF EXISTS elements');
SQLExec('DROP TABLE IF EXISTS elm_states');
parent::uninstall();
}
示例12: install
/**
* Install
*
* Module installation routine
*
* @access private
*/
function install($parent_name = "")
{
parent::install($parent_name);
SQLExec("UPDATE project_modules SET HIDDEN=1 WHERE NAME LIKE '" . $this->name . "'");
}
示例13: uninstall
/**
* Uninstall
*
* Module uninstall routine
*
* @access public
*/
function uninstall() {
SQLExec('DROP TABLE IF EXISTS terminals');
parent::uninstall();
}
示例14: getObjectsByClass
}
$out['OK'] = 1;
if ($rec['CLASS_ID']) {
$objects = getObjectsByClass($rec['CLASS_ID']);
$total = count($objects);
$replaces = array();
for ($i = 0; $i < $total; $i++) {
$property = SQLSelectOne("SELECT ID FROM properties WHERE TITLE LIKE '" . DBSafe($rec['TITLE']) . "' AND OBJECT_ID=" . (int) $objects[$i]['ID'] . " AND CLASS_ID!=" . (int) $rec['CLASS_ID']);
if ($property['ID']) {
$replaces[] = $property['ID'];
}
}
$total = count($replaces);
for ($i = 0; $i < $total; $i++) {
SQLExec("UPDATE pvalues SET PROPERTY_ID=" . (int) $rec['ID'] . " WHERE PROPERTY_ID=" . (int) $replaces[$i]);
SQLExec("DELETE FROM properties WHERE ID=" . (int) $replaces[$i]);
}
}
} else {
$out['ERR'] = 1;
}
}
if (is_array($rec)) {
foreach ($rec as $k => $v) {
if (!is_array($v)) {
$rec[$k] = htmlspecialchars($v);
}
}
}
outHash($rec, $out);
global $overwrite;
示例15: dbInstall
/**
* Module data installation
*
* Installing required module data structure into project.
* (Notes: file "initial.sql" will be executed if found in project directory)
*
* @param string $data required database tables and fields
* @access private
*/
function dbInstall($data) {
$sql="";
$strings=explode("\n", $data);
$table_defined=array();
for($i=0;$i<count($strings);$i++) {
$strings[$i]=preg_replace('/\/\/.+$/is', '', $strings[$i]);
$fields=explode(":", $strings[$i]);
$table=trim(array_shift($fields));
$definition=trim(implode(':', $fields));
$definition=str_replace("\r", "", trim($definition));
if ($definition=="") continue;
$tmp=explode(" ", $definition);
$field=$tmp[0];
$definition=str_replace($field.' ', '`'.$field.'` ', $definition);
if (!IsSet($table_defined[$table])) {
// new table
if (strpos($definition, "auto_increment")) {
$definition.=", PRIMARY KEY(".$field.")";
//$definition.=", KEY(".$field.")";
}
$sql="CREATE TABLE IF NOT EXISTS $table ($definition);";
$table_defined[$table]=1;
SQLExec($sql);
$result = SQLExec("SHOW FIELDS FROM $table");
while($row = mysql_fetch_array($result)) {
$tbl_fields[$table][$row[Field]]=1;
}
} elseif ((strtolower($field)=='key') || (strtolower($field)=='index') || (strtolower($field)=='fulltext')) {
if (!$indexes_retrieved[$table]) {
$result = SQLExec("SHOW INDEX FROM $table");
while($row = mysql_fetch_array($result)) {
$tbl_indexes[$table][$row[Key_name]]=1;
}
$indexes_retrieved[$table]=1;
}
preg_match('/\((.+?)\)/', $definition, $matches);
$key_name=trim($matches[1]);
if (!IsSet($tbl_indexes[$table][$key_name])) {
$sql="ALTER IGNORE TABLE $table ADD $definition;";
SQLExec($sql);
}
} elseif (!IsSet($tbl_fields[$table][$field])) {
// new field
$sql="ALTER IGNORE TABLE $table ADD $definition;";
SQLExec($sql);
}
}
// executing initial query and comments each line to prevent execution next time
if (file_exists(DIR_MODULES.$this->name."/initial.sql")) {
$data=LoadFile(DIR_MODULES.$this->name."/initial.sql");
$data.="\n";
$data=str_replace("\r", "", $data);
$query=explode("\n",$data);
for ($i=0;$i < count($query)-1;$i++) {
if ($query[$i]{0}!="#") {
SQLExec($query[$i]);
$mdf[]="#".$query[$i];
} else {
$mdf[]=$query[$i];
}
}
SaveFile(DIR_MODULES.$this->name."/initial.sql", join("\n", $mdf));
}
}