本文整理汇总了PHP中db_execute函数的典型用法代码示例。如果您正苦于以下问题:PHP db_execute函数的具体用法?PHP db_execute怎么用?PHP db_execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_execute函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resources_handle_on_project_user_removed
/**
* Handle on_project_user_removed event
*
* @param Project $project
* @param User $user
* @return null
*/
function resources_handle_on_project_user_removed($project, $user)
{
$rows = db_execute('SELECT id FROM ' . TABLE_PREFIX . 'project_objects WHERE project_id = ?', $project->getId());
if (is_foreachable($rows)) {
$object_ids = array();
foreach ($rows as $row) {
$object_ids[] = (int) $row['id'];
}
// foreach
$user_id = $user->getId();
// Assignments cleanup
db_execute('DELETE FROM ' . TABLE_PREFIX . 'assignments WHERE user_id = ? AND object_id IN (?)', $user_id, $object_ids);
cache_remove('object_starred_by_' . $user_id);
cache_remove('object_assignments_*');
cache_remove('object_assignments_*_rendered');
// Starred objects cleanup
db_execute('DELETE FROM ' . TABLE_PREFIX . 'starred_objects WHERE user_id = ? AND object_id IN (?)', $user_id, $object_ids);
cache_remove('object_starred_by_' . $user_id);
// Subscriptions cleanup
db_execute('DELETE FROM ' . TABLE_PREFIX . 'subscriptions WHERE user_id = ? AND parent_id IN (?)', $user_id, $object_ids);
cache_remove('user_subscriptions_' . $user_id);
// remove pinned project
PinnedProjects::unpinProject($project, $user);
}
// if
}
示例2: upgrade_log
function upgrade_log($v = false)
{
if (!$v) {
$v = upgrade_version_num();
}
return db_execute('insert into sitellite_upgrade values (?, ?, now())', $v, session_username());
}
示例3: source_handle_on_object_deleted
/**
* on_object_deleted handler implemenation
*
* @param AngieObject $object
* @return null
*/
function source_handle_on_object_deleted($object)
{
if (instance_of($object, 'Ticket') || instance_of($object, 'Discussion') || instance_of($object, 'Milestone') || instance_of($object, 'Task')) {
db_execute('DELETE FROM ' . TABLE_PREFIX . 'commit_project_objects WHERE object_id = ? AND project_id = ?', $object->getId(), $object->getProjectId());
}
// if
}
示例4: syslog_db_execute
function syslog_db_execute($sql, $log = TRUE)
{
global $syslog_cnn, $cnn_id;
/* use cacti function if using Cacti db */
if ($syslog_cnn == $cnn_id) {
return db_execute($sql, $log);
}
$sql = str_replace(" ", " ", str_replace("\n", "", str_replace("\r", "", str_replace("\t", " ", $sql))));
if (read_config_option("log_verbosity") == POLLER_VERBOSITY_DEBUG) {
cacti_log("DEBUG: SQL Exec: \"" . $sql . "\"", FALSE);
}
$errors = 0;
while (1) {
$query = $syslog_cnn->Execute($sql);
if ($query || $syslog_cnn->ErrorNo() == 1032) {
return 1;
} else {
if ($log || read_config_option("log_verbosity") == POLLER_VERBOSITY_DEBUG) {
if (substr_count($syslog_cnn->ErrorMsg(), "Deadlock") || $syslog_cnn->ErrorNo() == 1213 || $syslog_cnn->ErrorNo() == 1205) {
$errors++;
if ($errors > 30) {
cacti_log("ERROR: Too many Lock/Deadlock errors occurred! SQL:'" . str_replace("\n", "", str_replace("\r", "", str_replace("\t", " ", $sql))) . "'", TRUE);
return 0;
} else {
usleep(500000);
continue;
}
} else {
cacti_log("ERROR: A DB Exec Failed!, Error:'" . $syslog_cnn->ErrorNo() . "', SQL:\"" . str_replace("\n", "", str_replace("\r", "", str_replace("\t", " ", $sql))) . "'", FALSE);
return 0;
}
}
}
}
}
示例5: rrdclean_check_upgrade
function rrdclean_check_upgrade()
{
global $config;
$files = array('index.php', 'plugins.php', 'rrdcleaner.php');
if (isset($_SERVER['PHP_SELF']) && !in_array(basename($_SERVER['PHP_SELF']), $files)) {
return;
}
$current = plugin_rrdclean_version();
$current = $current['version'];
$old = db_fetch_row("SELECT * FROM plugin_config WHERE directory='rrdclean'");
if (sizeof($old) && $current != $old["version"]) {
/* if the plugin is installed and/or active */
if ($old["status"] == 1 || $old["status"] == 4) {
/* re-register the hooks */
plugin_rrdclean_install();
/* perform a database upgrade */
rrdclean_database_upgrade();
}
# stub for updating tables
#$_columns = array_rekey(db_fetch_assoc("SHOW COLUMNS FROM <table>"), "Field", "Field");
#if (!in_array("<new column>", $_columns)) {
# db_execute("ALTER TABLE <table> ADD COLUMN <new column> VARCHAR(40) NOT NULL DEFAULT '' AFTER <old column>");
#}
# new hooks
#api_plugin_register_hook('rrdclean', 'config_settings', 'rrdclean_config_settings', 'setup.php');
#if (api_plugin_is_enabled('rrdclean')) {
# may sound ridiculous, but enables new hooks
# api_plugin_enable_hooks('rrdclean');
#}
# register new version
$info = plugin_rrdclean_version();
$id = db_fetch_cell("SELECT id FROM plugin_config WHERE directory='rrdclean'");
db_execute("UPDATE plugin_config\r\n\t\t\tSET name='" . $info["longname"] . "',\r\n\t\t\tauthor='" . $info["author"] . "',\r\n\t\t\twebpage='" . $info["homepage"] . "',\r\n\t\t\tversion='" . $info["version"] . "'\r\n\t\t\tWHERE id='{$id}'");
}
}
示例6: auth_control_data_save
/**
* Saves auth control data for a certain control id
*
* Saves auth control data for a certain control id
*
* @return 1 on success, 0 on error
*/
function auth_control_data_save($data, $category = "SYSTEM", $enable_user_edit = 0, $plugin_id = 0, $control_id = 0) {
/* Validate input */
if (!is_array($data)) {
return 0;
}
if (!is_numeric($enable_user_edit)) {
return 0;
}
if (($enable_user_edit < 0) || ($enable_user_edit > 1)) {
$enable_user_edit = 0;
}
if (!is_numeric($plugin_id)) {
return 0;
}
if (!is_numeric($control_id)) {
return 0;
}
if (empty($control_id)) {
$control_id = $_SESSION["sess_user_id"];
}
/* Create SQL Query */
$username = db_fetch_cell("SELECT username FROM user_auth WHERE id = " . $control_id, "username");
$sql = "REPLACE INTO `auth_data` (`control_id`,`plugin_id`,`category`,`name`,`value`,`enable_user_edit`,`updated_when`,`updated_by`) VALUES ";
foreach ($data as $name => $value) {
$sql .= "(" . $control_id . "," . $plugin_id . ",'" . $category . "','" . $name . "','" . $value . "'," . $enable_user_edit . ",NOW(),'" . $username . "'),";
}
$sql = substr($sql,0,strlen($sql) - 1);
/* Execute query and return */
return db_execute($sql);
}
示例7: logSearch
/**
* Log a search query.
*/
function logSearch($query, $results, $ts = false, $ip = false, $ctype = false, $domain = false)
{
if (!$ts) {
$ts = date('YmdHis');
}
if (!$ip) {
$ip = $_SERVER['REMOTE_ADDR'];
}
if (!$ctype) {
$ctype = 'all';
} elseif (is_array($ctype)) {
$ctype = join(', ', $ctype);
}
if (!$domain) {
$domain = 'all';
} elseif (is_array($domain)) {
$domain = join(', ', $domain);
}
$res = db_execute('insert into sitesearch_log
(id, query, results, ts, ip, ctype, domain)
values
(null, ?, ?, ?, ?, ?, ?)', $query, $results, $ts, $ip, $ctype, $domain);
if (!$res) {
$this->error = db_error();
}
return $res;
}
示例8: incoming_mail_handle_on_object_deleted
/**
* on_object_deleted handler implemenation
*
* @param AngieObject $object
* @return null
*/
function incoming_mail_handle_on_object_deleted($object)
{
if (instance_of($object, 'Project')) {
db_execute('UPDATE ' . TABLE_PREFIX . 'incoming_mailboxes SET enabled=0 WHERE project_id = ?', $object->getId());
}
// if
}
示例9: api_device_remove_multi
function api_device_remove_multi($device_ids)
{
$devices_to_delete = '';
$i = 0;
if (sizeof($device_ids)) {
/* build the list */
foreach ($device_ids as $device_id) {
if ($i == 0) {
$devices_to_delete .= $device_id;
} else {
$devices_to_delete .= ', ' . $device_id;
}
/* poller commands go one at a time due to trashy logic */
db_execute_prepared('DELETE FROM poller_item WHERE host_id = ?', array($device_id));
db_execute_prepared('DELETE FROM poller_reindex WHERE host_id = ?', array($device_id));
db_execute_prepared('DELETE FROM poller_command WHERE command LIKE ?', array($device_id . ':%'));
$i++;
}
db_execute("DELETE FROM host WHERE id IN ({$devices_to_delete})");
db_execute("DELETE FROM host_graph WHERE host_id IN ({$devices_to_delete})");
db_execute("DELETE FROM host_snmp_query WHERE host_id IN ({$devices_to_delete})");
db_execute("DELETE FROM host_snmp_cache WHERE host_id IN ({$devices_to_delete})");
db_execute("DELETE FROM graph_tree_items WHERE host_id IN ({$devices_to_delete})");
db_execute("DELETE FROM reports_items WHERE host_id IN ({$devices_to_delete})");
/* for people who choose to leave data sources around */
db_execute("UPDATE data_local SET host_id=0 WHERE host_id IN ({$devices_to_delete})");
db_execute("UPDATE graph_local SET host_id=0 WHERE host_id IN ({$devices_to_delete})");
}
}
示例10: api_poller_cache_item_add
function api_poller_cache_item_add($host_id, $host_field_override, $local_data_id, $poller_action_id, $data_source_item_name, $num_rrd_items, $arg1 = "", $arg2 = "", $arg3 = "")
{
$host = db_fetch_row("select\n\t\thost.id,\n\t\thost.hostname,\n\t\thost.snmp_community,\n\t\thost.snmp_version,\n\t\thost.snmp_username,\n\t\thost.snmp_password,\n\t\thost.snmp_port,\n\t\thost.snmp_timeout,\n\t\thost.disabled\n\t\tfrom host\n\t\twhere host.id={$host_id}");
/* the $host_field_override array can be used to override certain host fields in the poller cache */
if (isset($host)) {
$host = array_merge($host, $host_field_override);
}
if (isset($host["id"]) || isset($host_id)) {
if (isset($host)) {
if ($host["disabled"] == "on") {
return true;
}
} else {
if ($poller_action_id == 0) {
return true;
}
$host["id"] = 0;
$host["snmp_community"] = "";
$host["snmp_timeout"] = "";
$host["snmp_username"] = "";
$host["snmp_password"] = "";
$host["snmp_version"] = "";
$host["snmp_port"] = "";
$host["hostname"] = "None";
}
if ($poller_action_id == 0) {
if ($host["snmp_version"] < 1 || $host["snmp_version"] > 3 || $host["snmp_community"] == "" && $host["snmp_version"] != 3) {
return true;
}
}
return db_execute("insert into poller_item (local_data_id,host_id,action,hostname,\n\t\t\tsnmp_community,snmp_version,snmp_timeout,snmp_username,snmp_password,snmp_port,rrd_name,rrd_path,\n\t\t\trrd_num,arg1,arg2,arg3) values ({$local_data_id}," . $host["id"] . ",{$poller_action_id},'" . $host["hostname"] . "',\n\t\t\t'" . $host["snmp_community"] . "','" . $host["snmp_version"] . "','" . $host["snmp_timeout"] . "',\n\t\t\t'" . $host["snmp_username"] . "','" . $host["snmp_password"] . "','" . $host["snmp_port"] . "',\n\t\t\t'{$data_source_item_name}','" . addslashes(clean_up_path(get_data_source_path($local_data_id, true))) . "',\n\t\t\t'{$num_rrd_items}','{$arg1}','{$arg2}','{$arg3}')");
}
}
示例11: color_remove
function color_remove()
{
/* ================= input validation ================= */
input_validate_input_number(get_request_var("id"));
/* ==================================================== */
db_execute("delete from colors where id=" . $_GET["id"]);
}
示例12: invoicing_handle_on_object_deleted
/**
* on_object_deleted handler implemenation
*
* @param AngieObject $object
* @return null
*/
function invoicing_handle_on_object_deleted($object)
{
if (instance_of($object, 'TimeRecord')) {
db_execute('DELETE FROM ' . TABLE_PREFIX . 'invoice_time_records WHERE time_record_id = ?', $object->getId());
}
// if
}
示例13: create_user
function create_user($email, $username, $password, $password_confirm, $firstname, $lastname)
{
if (!ereg(".+@.+\\..+", $email)) {
return "Invalid email address";
}
if (empty($username)) {
return "Empty username";
}
if (empty($password) || empty($password_confirm)) {
return "Empty password";
}
if (strcmp($password, $password_confirm)) {
return "Passwords don't match";
}
if (empty($firstname)) {
return "Empty first name";
}
if (empty($lastname)) {
return "Empty last name";
}
if (db_fetch("select email from sitellite_user where email = ?", $email)) {
return "Email address is already in system";
}
if (db_fetch("select username from sitellite_user where username = ?", $username)) {
return "Username is already in system";
}
// All the data checks out, let's insert this mofo
if (!db_execute("insert into sitellite_user (email, password, firstname, lastname, username, role, team, expires, lang) values (?, ?, ?, ?, ?, ?, ?, ?, ?)", $email, crypt($password), $firstname, $lastname, $username, '', '', 0, 'en')) {
return "User creation failed";
}
return '';
// Everything is peachy! *gulp*
}
示例14: onSubmit
function onSubmit($vals)
{
//echo '<pre>';
//print_r ($vals);
//exit;
$duration = (strtotime($vals['ended']) - strtotime($vals['started'])) / 60 / 60;
$res = db_execute('insert into timetracker_entry
(id, project_id, task_description, started, duration)
values
(null, ?, ?, ?, ?)', $vals['project'], $vals['description'], $vals['started'], $duration);
if (!$res) {
return '<p>Unknown error: ' . db_error() . '</p>';
}
$eid = db_lastid();
if (!is_array($vals['users'])) {
$vals['users'] = preg_split('/, ?/', $vals['users']);
}
foreach ($vals['users'] as $user) {
db_execute('insert into timetracker_user_entry
(id, user_id, entry_id)
values
(null, ?, ?)', $user, $eid);
}
header('Location: ' . site_prefix() . '/index/timetracker-app/added.entry');
exit;
}
示例15: api_graph_remove_multi
function api_graph_remove_multi($local_graph_ids)
{
/* initialize variables */
$ids_to_delete = '';
$i = 0;
/* build the array */
if (sizeof($local_graph_ids)) {
foreach ($local_graph_ids as $local_graph_id) {
if ($i == 0) {
$ids_to_delete .= $local_graph_id;
} else {
$ids_to_delete .= ', ' . $local_graph_id;
}
$i++;
if ($i % 1000 == 0) {
db_execute("DELETE FROM graph_templates_graph WHERE local_graph_id IN ({$ids_to_delete})");
db_execute("DELETE FROM graph_templates_item WHERE local_graph_id IN ({$ids_to_delete})");
db_execute("DELETE FROM graph_tree_items WHERE local_graph_id IN ({$ids_to_delete})");
db_execute("DELETE FROM reports_items WHERE local_graph_id IN ({$ids_to_delete})");
db_execute("DELETE FROM graph_local WHERE id IN ({$ids_to_delete})");
$i = 0;
$ids_to_delete = '';
}
}
if ($i > 0) {
db_execute("DELETE FROM graph_templates_graph WHERE local_graph_id IN ({$ids_to_delete})");
db_execute("DELETE FROM graph_templates_item WHERE local_graph_id IN ({$ids_to_delete})");
db_execute("DELETE FROM graph_tree_items WHERE local_graph_id IN ({$ids_to_delete})");
db_execute("DELETE FROM reports_items WHERE local_graph_id IN ({$ids_to_delete})");
db_execute("DELETE FROM graph_local WHERE id IN ({$ids_to_delete})");
}
}
}