本文整理汇总了PHP中database::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP database::execute方法的具体用法?PHP database::execute怎么用?PHP database::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database
的用法示例。
在下文中一共展示了database::execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
function delete()
{
$db = new database();
$query = "DELETE FROM Computer WHERE id={$this->id}";
$db->execute($query);
$db = null;
}
示例2: gc
public function gc($maxlifetime)
{
$db = new database();
$db->query("DELETE FROM tbl_session\n WHERE session_lastaccesstime < DATE_SUB(NOW(),\n INTERVAL " . $maxlifetime . " SECOND)");
$db->execute();
return true;
}
示例3: database
function show_page_result()
{
$row_num = ($this->numPage - 1) * $this->pagesize;
//表示每一页从第几条数据开始显示
$row_num = $row_num . ",";
$SQL = "SELECT * FROM `test` LIMIT {$row_num} {$this->pagesize}";
$db = new database();
$query = $db->execute($SQL);
while ($row = mysql_fetch_array($query)) {
echo "<b>" . $row[name] . " | " . $row[sex] . "<hr>";
}
$db = null;
}
示例4: isMaintenanceNeeded
private function isMaintenanceNeeded()
{
global $config;
global $db;
// TODO: remove this loading after legacy maintenance code has been deleted
if (!isset($db)) {
require_once dirname(dirname(dirname(__FILE__))) . '/classes/config.php';
$config = new config();
require_once dirname(dirname(dirname(__FILE__))) . '/classes/db.php';
$db = new database();
}
$this->lockTable('misc_data');
$today = date('Y-m-d');
$last_maintenance = '0000-00-0000';
// check last time where maintenance was performed
$query = $db->SQL('SELECT `last_maintenance` FROM `misc_data` LIMIT 1');
$lastMaintenanceSaved = false;
while ($row = $db->fetchRow($query)) {
$lastMaintenanceSaved = true;
if (isset($row['last_maintenance'])) {
$last_maintenance = $row['last_maintenance'];
}
}
$db->free($query);
// save new maintenance timestamp
if ($lastMaintenanceSaved) {
$query = $db->prepare('UPDATE `misc_data` SET `last_maintenance`=?');
$db->execute($query, $today);
$db->free($query);
} else {
$query = $db->prepare('INSERT INTO `misc_data` (`last_maintenance`) VALUES (?)');
$db->execute($query, $today);
$db->free($query);
}
$this->unlockTables();
// daily maintenance
return strcasecmp($today, $last_maintenance) !== 0;
}
示例5: array
function get_oneuser($field, $value)
{
$field_array = array("id", "name");
//查询方式
if (in_array($field, $field_array)) {
$sql = "SELECT * FROM `{$this->usertable}` FROM {$field}='{$value}'";
$db = new database();
$res = $db->execute($sql);
$obj_user = mysql_fetch_object($res);
return $obj_user;
} else {
echo "查询方式不对";
}
}
示例6: video
function video()
{
$db = new database();
$db->connect();
$this->id = $db->execute("SELECT max(video_id) as maximum from video");
while ($this->row = mysqli_fetch_array($this->id)) {
if (empty($this->row['maximum'])) {
$this->id_no = "VID00001";
} else {
if (intval(substr($this->row['maximum'], 8)) == 99999) {
$str = substr($this->row['maximum'], 0, 8);
++$str;
$this->id_no = $str . '00001';
} else {
$this->id_no = ++$this->row['maximum'];
}
}
}
return $this->id_no;
}
示例7: logEvent
public function logEvent($what, $data)
{
$defineWhat = array("ST" => "Scanned Ticket", "DS" => "Duplicate scan", "IS" => "Invalid scan (barcode not in database)", "NU" => "No username specified");
$db = new database();
if (isset($_GET['user'])) {
$user = $user = filter_input(INPUT_GET, 'user', FILTER_SANITIZE_SPECIAL_CHARS);
} else {
$user = '';
}
$db = new database();
$db->query("INSERT INTO tbl_log (who, what, data, timestamp, username) VALUES (?, ?, ?, NOW(), ?)");
$db->bind(1, sha1($_SERVER['REMOTE_ADDR']));
$db->bind(2, $what);
$db->bind(3, $data);
$db->bind(4, $user);
try {
$db->execute();
} catch (Exception $e) {
return "Database error: " . $e->getMessage();
}
}
示例8: __autoload
<?php
function __autoload($class_name)
{
include_once $class_name . ".class.php";
}
$numq = "SELECT * FROM `test`";
$db = new database();
$res = $db->execute($numq);
//总数据条数
$nums = $db->num_rows($res);
$pagesize = 3;
if (!empty($_GET['pagesize'])) {
$pagesize = $_GET['pagesize'];
}
$page = new page($pagesize, $nums);
//$page->show_page_way_1();
$page->show_page_way_3();
$page->show_page_result();
示例9: database
$message = $orm->message;
$destination_response = $orm->message;
//remove the temporary permission
$p->delete($permission, 'temp');
//get the destination_uuid
if (strlen($destination_response['uuid']) > 0) {
$destination_uuid = $destination_response['uuid'];
}
//redirect the user
if ($action == "add") {
$_SESSION["message"] = $text['message-add'];
// billing
if (file_exists($_SERVER['DOCUMENT_ROOT'] . PROJECT_PATH . "/app/billing/app_config.php")) {
$db2 = new database();
$db2->sql = "select currency, billing_uuid, balance from v_billings where type_value='{$destination_accountcode}'";
$db2->result = $db2->execute();
$default_currency = strlen($_SESSION['billing']['currency']['text']) ? $_SESSION['billing']['currency']['text'] : 'USD';
$billing_currency = strlen($db2->result[0]['currency']) ? $db2->result[0]['currency'] : $default_currency;
$destination_sell_current_currency = currency_convert($destination_sell, $billing_currency, $currency);
$billing_uuid = $db2->result[0]['billing_uuid'];
$balance = $db2->result[0]['balance'];
unset($db2->sql, $db2->result);
$balance -= $destination_sell_current_currency;
$db2->sql = "update v_billings set balance = {$balance}, old_balance = {$balance} where type_value='{$destination_accountcode}'";
$db2->result = $db2->execute();
unset($db2->sql, $db2->result);
$billing_invoice_uuid = uuid();
$user_uuid = check_str($_SESSION['user_uuid']);
$settled = 1;
$mc_gross = -1 * $destination_sell_current_currency;
$post_payload = serialize($_POST);
示例10: gmdate
if (permission_exists('recording_download')) {
echo "<a href=\"" . PROJECT_PATH . "/app/recordings/recordings.php?a=download&type=rec&t=bin&filename=" . base64_encode($recording_file_path) . "\" title='" . $text['label-download'] . "'>" . $v_link_label_download . "</a>";
}
echo "\t</td>\n";
} else {
echo "\t<td valign='top' align='center' class='" . $row_style[$c] . "'> </td>\n";
}
}
echo "\t<td valign='top' class='" . $row_style[$c] . "' style='text-align: center;' nowrap='nowrap'>" . $tmp_start_epoch . "</td>\n";
echo "\t<td valign='top' class='" . $row_style[$c] . "' style='text-align: right;'>" . ($row['tta'] > 0 ? $row['tta'] . "s" : " ") . "</td>\n";
echo "\t<td valign='top' class='" . $row_style[$c] . "' style='text-align: center;'>" . gmdate("G:i:s", $seconds) . "</td>\n";
if (file_exists($_SERVER["PROJECT_ROOT"] . "/app/billing/app_config.php")) {
$database->table = "v_xml_cdr";
$accountcode = strlen($row["accountcode"]) ? $row["accountcode"] : $_SESSION[domain_name];
$database->sql = "SELECT currency FROM v_billings WHERE type_value='{$accountcode}'";
$database->result = $database->execute();
$billing_currency = strlen($database->result[0]['currency']) ? $database->result[0]['currency'] : 'USD';
$billing_currency = strlen($database->result[0]['currency']) ? $database->result[0]['currency'] : (strlen($_SESSION['billing']['currency']['text']) ? $_SESSION['billing']['currency']['text'] : 'USD');
unset($database->sql);
unset($database->result);
$sell_price = strlen($row['call_sell']) ? $row['call_sell'] : 0;
$lcr_direction = strlen($row['direction']) ? $row['direction'] : "outbound";
$xml_string = trim($row["xml"]);
$json_string = trim($row["json"]);
if (strlen($xml_string) > 0) {
$format = "xml";
}
if (strlen($json_string) > 0) {
$format = "json";
}
try {
示例11: attemptToInstall
public function attemptToInstall()
{
require_once '../install/sql.php';
$db = new database();
$db->query($sql);
try {
$db->execute();
} catch (Exception $e) {
return returnError("Database error: " . $e->getMessage());
}
$lockfile = 'inc/dbinstalled.lck';
clearstatcache();
if (file_exists(ABSPATH . 'inc/dbinstalled.lck')) {
unlink($lockfile);
}
$handle = fopen(ABSPATH . $lockfile, 'w') or die('Cannot open file: ' . $lockfile);
fwrite($handle, date(DATE_FORMAT));
fclose();
}
示例12: save
public function save($obj)
{
$where = $this->get_pk_condition($obj);
$obj = $this->remove_pk($obj);
$setsql = $this->implode($obj);
//$sql = "UPDATE " . $this->table . " SET " . $setsql . " WHERE " . $where;
$table = $this->table;
$sql = "UPDATE {$table} SET {$setsql} WHERE {$where};";
return database::execute($sql);
}
示例13: database
<?php
#insert section
session_start();
require_once "../classes/database.php";
require_once "../classes/retrival.php";
$db = new database();
$db->connect();
if (isset($_REQUEST['Submit'])) {
$s_name = $_REQUEST['name'];
$s_details = $_REQUEST['detail'];
$c_name = $_REQUEST['course'];
$query = "SELECT * from course where c_name='{$c_name}'";
$result = $db->execute($query);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_array($result)) {
$c = $row['course_id'];
// echo $c;
}
$c_id = $GLOBALS['c'];
$_SESSION['course_id'] = $c_id;
$rt = new retrieval();
$s_id = $rt->section();
$query = "INSERT INTO section(section_id, course_id, s_name, s_detail)\n\t\t\t VALUES('{$s_id}', '{$c_id}', '{$s_name}', '{$s_details}')";
if (empty($db->execute($query))) {
echo "0";
} else {
echo "1";
}
} else {
echo "not working";
示例14: getUser
public function getUser($uid)
{
$db = new database();
$db->query("SELECT username, email, uid, status, rank, created\n FROM tbl_user\n WHERE uid = ?");
$db->bind(1, $uid);
try {
$db->execute();
} catch (Exception $e) {
return returnError("Database error: " . $e->getMessage());
}
return $db->single();
}
示例15: insertPost
function insertPost()
{
$title = $_POST['title'];
$content = $_POST['content'];
$date = date("Y-m-d H:i:s");
$user = $_SESSION['username'];
$hidden = 'false';
if (isset($title, $content)) {
include_once 'database.class.php';
$dsn = new database();
$dsn->query("INSERT INTO news (title, member, date, content, hidden) VALUES ('{$title}','{$user}','{$date}','{$content}','{$hidden}')");
$dsn->execute();
}
}