本文整理汇总了PHP中SQLSelectOne函数的典型用法代码示例。如果您正苦于以下问题:PHP SQLSelectOne函数的具体用法?PHP SQLSelectOne怎么用?PHP SQLSelectOne使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SQLSelectOne函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getObject
/**
* Title
*
* Description
*
* @access public
*/
function getObject($name) {
$rec=SQLSelectOne("SELECT * FROM objects WHERE TITLE LIKE '".DBSafe($name)."'");
if ($rec['ID']) {
include_once(DIR_MODULES.'objects/objects.class.php');
$obj=new objects();
$obj->id=$rec['ID'];
$obj->loadObject($rec['ID']);
return $obj;
}
return 0;
}
示例2: unsubscribeFromEvent
function unsubscribeFromEvent($module_name, $event_name = '')
{
$rec = SQLSelectOne("SELECT * FROM settings WHERE NAME LIKE 'HOOK_EVENT_'" . strtoupper($event_name) . " AND TYPE='json'");
if (isset($rec['ID'])) {
$data = json_decode($rec['VALUE'], true);
if (isset($data[$module_name])) {
unset($data[$module_name]);
$rec['VALUE'] = json_encode($data);
SQLUpdate('settings', $rec);
}
}
}
示例3: 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;
}
}
示例4: dump_events
function dump_events($ecode, $data, $server, $port)
{
// Search exist event
$parent_class_rec = SQLSelectOne("SELECT ID FROM classes WHERE TITLE LIKE 'Telephony'");
if ($parent_class_rec['ID']) {
$class_rec = SQLSelectOne("SELECT * FROM classes WHERE TITLE LIKE 'AsteriskAMI' AND PARENT_ID = '" . $parent_class_rec['ID'] . "'");
if ($class_rec['ID']) {
$object_rec = SQLSelectOne("SELECT * FROM objects WHERE CLASS_ID='" . $class_rec['ID'] . "' AND TITLE = 'Asterisk'");
if ($object_rec['ID']) {
$method_rec = SQLSelectOne("SELECT * FROM methods WHERE OBJECT_ID='" . $object_rec['ID'] . "' AND TITLE = 'Event" . $data['Event'] . "'");
if (!$method_rec['ID']) {
// New event. Add method to class AsteriskAMI and object
// Add class method
echo date('Y-m-d H:i:s') . " : Receive new event. Add method Event" . $data['Event'] . "\n";
$class_method_rec['CLASS_ID'] = $class_rec['ID'];
$class_method_rec['TITLE'] = 'Event' . $data['Event'];
$class_method_rec['CODE'] = "echo date('Y-m-d H:i:s')" . ".\" : Event \"." . '$params[\'Event\']' . ".\" received. Process... \\n\"" . ";\n";
SQLInsert('methods', $class_method_rec);
// Add object method
$method_rec['OBJECT_ID'] = $object_rec['ID'];
$method_rec['TITLE'] = 'Event' . $data['Event'];
$method_rec['CALL_PARENT'] .= "1";
$method_rec['CODE'] .= "/**\n";
$method_rec['CODE'] .= "Array received form Asterisk:\n";
foreach ($data as $key => $value) {
$method_rec['CODE'] .= "\t[" . $key . "] => " . $value . " \n";
}
$method_rec['CODE'] .= "*/\n";
SQLInsert('methods', $method_rec);
} else {
// Event already exist. Process event
$method = $object_rec['TITLE'] . ".Event" . $data['Event'];
callMethod($method, $data);
}
}
}
}
}
示例5: getGlobal
/**
* Title
*
* Description
*
* @access public
*/
function getGlobal($varname)
{
$value = SQLSelectOne("SELECT VALUE FROM pvalues WHERE PROPERTY_NAME = '" . DBSafe($varname) . "'");
if (isset($value['VALUE'])) {
return $value['VALUE'];
}
$tmp = explode('.', $varname);
if ($tmp[2]) {
$object_name = $tmp[0] . '.' . $tmp[1];
$varname = $tmp[2];
} elseif ($tmp[1]) {
$object_name = $tmp[0];
$varname = $tmp[1];
} else {
$object_name = 'ThisComputer';
}
$obj = getObject($object_name);
if ($obj) {
return $obj->getProperty($varname);
} else {
return 0;
}
}
示例6: control_modules
if ($cached_result == '') {
if (!file_exists(DIR_MODULES . 'control_modules/installed')) {
include_once DIR_MODULES . "control_modules/control_modules.class.php";
$ctl = new control_modules();
}
$app = new application();
if ($md != $app->name) {
$app->restoreParams();
} else {
$app->getParams();
}
if ($app->action != '' && $app->action != 'docs') {
$fake_doc = '';
}
if ($app->action == '' && $fake_doc != "" && file_exists(DIR_MODULES . 'cms_docs/cms_docs.class.php')) {
$tmp = SQLSelectOne("SELECT ID FROM cms_docs WHERE NAME='" . DBSafe($fake_doc) . "'");
if (isset($tmp['ID'])) {
$app->action = "docs";
$app->doc = $tmp['ID'];
} elseif (file_exists(DIR_TEMPLATES . $fake_doc . ".html")) {
$app->action = $fake_doc;
} else {
//$tmp1=SQLSelectOne("SELECT ID FROM cms_docs WHERE NAME='404'");
$tmp1 = array();
if ($tmp1['ID']) {
$app->action = "docs";
$app->doc = $tmp1['ID'];
} else {
header("HTTP/1.0 404 Not Found");
echo "The page cannot be found. Please use <a href='/'>this link</a> to continue browsing.";
exit;
示例7: SQLSelectOne
global $linked_property_new;
global $condition_new;
global $condition_value_new;
global $condition_advanced_new;
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;
示例8: delete_zwave_devices
/**
* zwave_devices delete record
*
* @access public
*/
function delete_zwave_devices($id)
{
$rec = SQLSelectOne("SELECT * FROM zwave_devices WHERE ID='{$id}'");
// some action for related tables
SQLExec("DELETE FROM zwave_properties WHERE DEVICE_ID='" . $rec['ID'] . "'");
SQLExec("DELETE FROM zwave_devices WHERE ID='" . $rec['ID'] . "'");
}
示例9: mysql
// connecting to database
$db = new mysql(DB_HOST, '', DB_USER, DB_PASSWORD, DB_NAME);
include_once "./load_settings.php";
include_once DIR_MODULES . "control_modules/control_modules.class.php";
// ...
set_time_limit(0);
include_once DIR_MODULES . 'snmpdevices/snmpdevices.class.php';
$snmpdevices = new snmpdevices();
$socket = stream_socket_server("udp://0.0.0.0:162", $errno, $errstr, STREAM_SERVER_BIND);
// If we could not bind successfully, let's throw an error
if (!$socket) {
die($errstr);
} else {
do {
$pkt = stream_socket_recvfrom($socket, 512, 0, $peer);
if (preg_match('/:\\d+$/', $peer, $m)) {
$peer = str_replace($m[0], '', $peer);
}
echo date('Y-m-d H:i:s') . ' new snmp trap from ' . $peer . "\n";
$device = SQLSelectOne("SELECT ID FROM snmpdevices WHERE HOST LIKE '" . DBSafe($peer) . "'");
if ($device['ID']) {
$snmpdevices->readDevice($device['ID']);
} else {
$device['TITLE'] = $peer;
$device['HOST'] = $peer;
$device['ID'] = SQLInsert('snmpdevices', $device);
}
} while ($pkt !== false);
}
$db->Disconnect();
// closing database connection
示例10: foreach
}
if ($this->owner->name!='panel') {
$res[$i]['TITLE']=processTitle($res[$i]['TITLE'], $this);
if ($res[$i]['TYPE']=='custom') {
$res[$i]['DATA']=processTitle($res[$i]['DATA'], $this);
}
}
foreach($res[$i] as $k=>$v) {
if (!is_array($res[$i][$k]) && $k!='DATA') {
$res[$i][$k]=addslashes($v);
}
}
$tmp=SQLSelectOne("SELECT COUNT(*) as TOTAL FROM commands WHERE PARENT_ID='".$res[$i]['ID']."'");
if ($tmp['TOTAL']) {
$res[$i]['RESULT']=$tmp['TOTAL'];
}
}
if ($this->action=='admin') {
$res=$this->buildTree_commands($res);
}
$out['RESULT']=$res;
}
?>
示例11: delete_events
/**
* events delete record
*
* @access public
*/
function delete_events($id)
{
$rec = SQLSelectOne("SELECT * FROM events WHERE ID='{$id}'");
// some action for related tables
SQLExec("DELETE FROM events WHERE ID='" . $rec['ID'] . "'");
}
示例12: SQLUpdate
<?
/*
* @version 0.1 (wizard)
*/
if ($this->owner->name=='panel') {
$out['CONTROLPANEL']=1;
}
$table_name='calendar_categories';
$rec=SQLSelectOne("SELECT * FROM $table_name WHERE ID='$id'");
if ($this->mode=='update') {
$ok=1;
//updating 'TITLE' (varchar, required)
global $title;
$rec['TITLE']=$title;
if ($rec['TITLE']=='') {
$out['ERR_TITLE']=1;
$ok=0;
}
//updating 'ACTIVE' (int)
global $active;
$rec['ACTIVE']=(int)$active;
//updating 'PRIORITY' (int)
global $priority;
$rec['PRIORITY']=(int)$priority;
//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
示例13: delete_methods
/**
* methods delete record
*
* @access public
*/
function delete_methods($id) {
$rec=SQLSelectOne("SELECT * FROM methods WHERE ID='$id'");
// some action for related tables
SQLExec("DELETE FROM methods WHERE ID='".$rec['ID']."'");
}
示例14: count
$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)) {
$rec[$k] = htmlspecialchars($v);
}
}
}
outHash($rec, $out);
global $overwrite;
if ($overwrite) {
$tmp = SQLSelectOne("SELECT * FROM properties WHERE ID='" . (int) $overwrite . "'");
unset($tmp['ID']);
foreach ($tmp as $k => $v) {
$out[$k] = htmlspecialchars($v);
}
}
示例15: array
$options = array('BACKUP_PATH' => 'Path to store backup');
foreach ($options as $k => $v) {
$tmp = SQLSelectOne("SELECT ID FROM settings WHERE NAME LIKE '" . $k . "'");
if (!$tmp['ID']) {
$tmp = array();
$tmp['NAME'] = $k;
$tmp['TITLE'] = $v;
$tmp['TYPE'] = 'text';
SQLInsert('settings', $tmp);
}
}
}
if ($this->filter_name == 'pushbullet' && !defined('SETTINGS_PUSHBULLET_PREFIX')) {
$options = array('PUSHBULLET_KEY' => 'Pushbullet API Key', 'PUSHBULLET_LEVEL' => 'Pushbullet message minimum level', 'PUSHBULLET_DEVICE_ID' => 'Pushbullet Device ID (optional)', 'PUSHBULLET_PREFIX' => 'Pushbullet notifiaction prefix (optional)');
foreach ($options as $k => $v) {
$tmp = SQLSelectOne("SELECT ID FROM settings WHERE NAME LIKE '" . $k . "'");
if (!$tmp['ID']) {
$tmp = array();
$tmp['NAME'] = $k;
$tmp['TITLE'] = $v;
$tmp['TYPE'] = 'text';
if ($k == 'PUSHBULLET_LEVEL') {
$tmp['VALUE'] = 1;
$tmp['DEFAULTVALUE'] = 1;
}
SQLInsert('settings', $tmp);
}
}
}
// if (!empty($options)) {
// }