本文整理汇总了PHP中Database::query_insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::query_insert方法的具体用法?PHP Database::query_insert怎么用?PHP Database::query_insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::query_insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: salvar
function salvar($id,$nome, $email,$senha)
{
$db = new Database();
// inserir
if($id == 0)
{
$senha = md5($senha);
$sql = 'insert into usuario ( nome, email, senha) values ("'.$nome.'","'.$email.'","'.$senha .'")';
return $db->query_insert($sql);
}
else
{ // atualizar
if($email != '')
$and = ' ,senha = md5(\''.$senha.'\') ';
else
$and = '';
$sql = ' update usuario set nome = "'.$nome.'", email = "'.$email.'" '. $and . ' where id = ' .$id;
return $db->query_update($sql);
}
}
示例2: add
public function add($obj)
{
$db = new Database();
$db->connect();
$obj = $db->query_insert($this->table_name, $obj);
$db->close();
return new response(array('body' => $obj));
}
示例3: save
public function save($token = false, $data = false, $server = false)
{
$database = new Database();
$date = date('Y-m-d h:m:s');
$expired_date = date('Y-m-d h:m:s ', strtotime($date . ' + 1 days'));
$session_saved = $database->query_insert('sessions', array('token' => $token, 'data' => json_encode($data), 'server_data' => json_encode($server), 'expired_date' => $expired_date, 'created' => $date));
return $session_saved;
}
示例4: UpdateSettings
function UpdateSettings($setting, $val, $type = '')
{
global $server, $user, $pass, $database, $pre;
if (empty($type)) {
$type = 'admin';
}
//Connect to database
require_once "sources/class.database.php";
$db = new Database($server, $user, $pass, $database, $pre);
$db->connect();
//Check if setting is already in DB. If NO then insert, if YES then update.
$data = $db->fetch_row("SELECT COUNT(*) FROM " . $pre . "misc WHERE type='" . $type . "' AND intitule = '" . $setting . "'");
if ($data[0] == 0) {
$db->query_insert("misc", array('valeur' => $val, 'type' => $type, 'intitule' => $setting));
//in case of stats enabled, add the actual time
if ($setting == 'send_stats') {
$db->query_insert("misc", array('valeur' => time(), 'type' => $type, 'intitule' => $setting . '_time'));
}
} else {
$db->query_update("misc", array('valeur' => $val), "type='" . $type . "' AND intitule = '" . $setting . "'");
//in case of stats enabled, update the actual time
if ($setting == 'send_stats') {
//Check if previous time exists, if not them insert this value in DB
$data_time = $db->fetch_row("SELECT COUNT(*) FROM " . $pre . "misc WHERE type='" . $type . "' AND intitule = '" . $setting . "_time'");
if ($data_time[0] == 0) {
$db->query_insert("misc", array('valeur' => 0, 'type' => $type, 'intitule' => $setting . '_time'));
} else {
$db->query_update("misc", array('valeur' => 0), "type='" . $type . "' AND intitule = '" . $setting . "_time'");
}
}
}
//save in variable
if ($type == "admin") {
$_SESSION['settings'][$setting] = $val;
} else {
if ($type == "settings") {
$settings[$setting] = $val;
}
}
}
示例5: salvar
function salvar($id,$nome, $email)
{
$db = new Database();
// inserir
if($id == 0)
{
$sql = 'insert into periodo ( nome ) values ("'.$nome.'")';
return $db->query_insert($sql);
}
else
{
// atualizar
$sql = ' update periodo set nome = "'.$nome.'" where id = ' .$id;
return $db->query_update($sql);
}
}
示例6: sendSMSAlert
function sendSMSAlert($geoAssId, $devDateTime)
{
$db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
$db->connect();
$getData = "SELECT * FROM tb_assigngeofence,tb_deviceinfo,tb_geofence_info,tb_clientinfo WHERE ci_id = tag_clientId AND tgi_id = tag_geofenceId AND di_id = tag_diId AND tag_id = " . $geoAssId;
$resData = mysql_query($getData);
if (@mysql_affected_rows() > 0) {
$fetData = mysql_fetch_assoc($resData);
$from = "";
$to = $fetData[tag_alertSrc];
if ($fetData[di_deviceName]) {
$devName = $fetData[di_deviceName];
} else {
$devName = $fetData[di_deviceId];
}
if ($fetData[tag_inout] == "in") {
$status = "entered zone";
} else {
$status = "left zone";
}
$msg = "Dear " . ucfirst($fetData[ci_clientName]) . "! " . $devName . " has " . $status . " " . $fetData[tgi_name] . " at " . date("H:i:s", strtotime($devDateTime)) . " - " . $fetData[ci_weburl];
//echo $msg;
$smsres = sendSMS($from, $to, $msg);
$smsdata['tsi_mobileno'] = $fetData[tag_alertSrc];
$smsdata['tsi_tgai_id'] = $geoAssId;
$smsdata['tsi_smsResult'] = $smsres;
$smsdata['tsi_message'] = urlencode($msg);
$smsdata['tsi_smsType'] = "GEOALERT";
//print_r($smsdata);
//exit;
if ($db->query_insert("tb_smsinfo", $smsdata)) {
$res = 1;
} else {
$res = 0;
}
return $res;
//print_r($fetData);
}
}
示例7: insertNewTransfer
public function insertNewTransfer($eventId, $offer)
{
$insert['mode'] = $_GET['mode'];
$insert['event_id'] = $eventId;
$insert['start'] = $_POST['start'];
$insert['via'] = $_POST['via'];
$insert['destination'] = $_POST['destination'];
$insert['email'] = $_POST['email'];
$insert['name'] = $_POST['name'];
$insert['message'] = $_POST['message'];
$insert['centre_fk'] = $_SESSION['centreIdent'];
#echo "*".$_SESSION['centreIdent'];
#check for Spamrobots
if ($_SESSION['centreIdent'] != '') {
echo "Spam";
$db = new Database();
$db->connect();
$db->query_insert("transfer", $insert);
$this->debug("NEW TRANSFER ENTRY", "Inserting transfer with the following content:\n" . $this->convert($insert));
$db->close();
}
}
示例8: Database
include_once 'includes/database.class.php';
require_once 'config.php';
$db = new Database($mysql_db_host, $mysql_db_user, $mysql_db_passwd, $mysql_db_name, $table_prefix);
$db->connect();
switch ($_GET['action']) {
case "deactivate":
$data['action'] = 0;
$db->query_update("plugins", $data, "filename='" . $_GET['filename'] . "'");
break;
case "activate":
$sql = "SELECT * FROM " . $table_prefix . "plugins WHERE filename = '" . $db->escape($_GET['filename']) . "'";
$count = count($db->fetch_all_array($sql));
if ($count < 1) {
$data['filename'] = $_GET['filename'];
$data['action'] = 1;
$db->query_insert("plugins", $data);
} else {
$data['action'] = 1;
$db->query_update("plugins", $data, "filename='" . $_GET['filename'] . "'");
}
break;
}
$sql = "SELECT filename, action FROM " . $table_prefix . "plugins WHERE action = '" . $db->escape(1) . "'";
$result_rows = $db->fetch_all_array($sql);
$plugin_list = new phphooks();
$plugin_headers = $plugin_list->get_plugins_header();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
示例9: logEvents
function logEvents($type, $label, $who)
{
global $server, $user, $pass, $database, $pre;
//include librairies & connect to DB
require_once "class.database.php";
$db = new Database($server, $user, $pass, $database, $pre);
$db->connect();
$db->query_insert("log_system", array('type' => $type, 'date' => mktime(date('h'), date('i'), date('s'), date('m'), date('d'), date('y')), 'label' => $label, 'qui' => $who));
}
示例10: rand
// Photo name : timestamp-random(year,timestamp)-locationid_photoid.jpg
$photo_name = $date[0] . '-' . rand($date[year], $date[0]) . '-' . $subDirImage . "_" . $subPhotoID . ".jpg";
$path = "./../upload/{$dir}/{$subDirImage}/" . $photo_name;
// Write photo
$base = $_POST['photo_upload'];
if ($base != "") {
$binary = base64_decode($base);
$file = fopen($path, 'a');
fwrite($file, $binary);
fclose($file);
chmod($path, 0766);
$UploadImage['LOCATION_CATE_ID'] = $_POST["location_cate_id"];
$UploadImage['LOCATION_ID'] = $_POST["location_id"];
$UploadImage['PHOTO_NAME'] = $photo_name;
$UploadImage['OWNER_NAME'] = $_POST["user_name"];
$insertPhoto = $db->query_insert("photo", $UploadImage);
} else {
echo "ไม่มีภาพอัพโหลด";
}
//Find PHOTO_ID
$sql = "SELECT MAX( PHOTO_ID ) as maxPho_ID FROM photo";
$q_maxPhotoID = $db->query($sql);
if ($_maxPhotoID = $db->fetch_array($q_maxPhotoID)) {
$maxPhoto_ID = $_maxPhotoID['maxPho_ID'];
}
// INSER OWNER
$_user_id = $_REQUEST['user_id'];
$_user_name = $_REQUEST['user_name'];
$_user_username = $_REQUEST['user_username'];
$userInsert['USER_ID'] = $_user_id;
$userInsert['USER_NAME'] = $_user_name;
示例11: fwrite
echo "{$errstr} ({$errno})<br />\n";
} else {
$out = "GET /api/v1/xml/" . $user_proj . "/commits/master HTTP/1.1\r\n";
$out .= "Host: google.com \r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
$results .= fgets($fp, 128);
}
fclose($fp);
}
$post_results = parseHttpResponse($results);
$objXML = new xml2Array();
$arrOutput = $objXML->parse($post_results);
$github_result = $arrOutput[0]['children'];
for ($i = 0; $i < count($github_result); $i++) {
$commit_id = $github_result[$i]['children'][4]['tagData'];
$message = $github_result[$i]['children'][0]['tagData'];
$date = str_replace('T', ' T ', $github_result[$i]['children'][5]['tagData']);
$commiter = $github_result[$i]['children'][3]['children'][0]['tagData'] . "/" . $github_result[$i]['children'][3]['children'][1]['tagData'];
$unix_stamp = strtotime($date);
echo "{$message} [{$commit_id}] was commited by {$commiter} on " . $unix_stamp . " \n";
if (strlen($mydb->first("SELECT `sum` FROM commits WHERE `sum`='{$commit_id}'")) == 0) {
$ar = array('id' => null, 'user' => $commiter, 'message' => $message, 'sum' => $commit_id, 'project' => $r['id']);
$mydb->query_insert('commits', $ar);
$LASTID = $mydb->lastID();
$s->n($LASTID, '', 'git', $r['id'], $unix_stamp);
}
//echo "<a href='#' onclick=\"insertAtCursor(document.reply.report, '[GIT]".$commit_id."[/GIT]');\" title=\".". $date . "\">" .$message . "</a><small>[" . $commit_id . "]</small>";
}
}
示例12: date
}
@fclose($file1);
}
if (isset($_GET[add_stop_name]) && $_GET[add_stop_name] != '') {
//echo $_GET[add_stop_name];
$getCont = "select * from tb_geofence_info where tgi_name = '" . $_GET[add_stop_name] . "' OR tgi_latLong = '" . $_GET[mapPt] . "' AND tgi_clientId =" . $_SESSION[clientID];
$resCont = $db->query($getCont);
if ($db->affected_rows == 0) {
$cdata["tgi_clientId"] = $_SESSION[clientID];
$cdata["tgi_name"] = $_GET[add_stop_name];
$cdata["tgi_isActive"] = 1;
$cdata["tgi_radius"] = "0.5";
$cdata["tgi_latLong"] = $_GET[mapPt];
//print_r($cdata);
//exit;
if ($db->query_insert("tb_geofence_info", $cdata)) {
echo 1;
} else {
echo 0;
}
} else {
echo 0;
}
}
if ($_GET[date_offline] != '' && $_GET[sessionid] != '') {
if (isset($_GET[date_offline]) && $_GET[date_offline]) {
$date_offline = $_GET[date_offline];
} else {
$date_offline = date('d-m-Y');
}
$getUserInfo = "SELECT * FROM tb_userinfo,tb_clientinfo WHERE ui_id = " . $_SESSION[userID] . " AND ci_id = " . $_SESSION[clientID];
示例13: array
$db->query_update('nested_tree', array('parent_id' => $_POST['newparent_id']), "id=" . $id[1]);
//Get the title to display it
$data = $db->fetch_row("SELECT title FROM " . $pre . "nested_tree WHERE id = " . $_POST['newparent_id']);
//show value
echo $data[0];
//rebuild the tree grid
$tree = new NestedTree($pre . 'nested_tree', 'id', 'parent_id', 'title');
$tree->rebuild();
} else {
if (isset($_POST['changer_complexite'])) {
$id = explode('_', $_POST['id']);
//Check if group exists
$tmp = $db->fetch_row("SELECT COUNT(*) FROM " . $pre . "misc WHERE type = 'complex' AND intitule = '" . $id[1] . "'");
if ($tmp[0] == 0) {
//Insert into DB
$db->query_insert('misc', array('type' => 'complex', 'intitule' => $id[1], 'valeur' => $_POST['changer_complexite']));
} else {
//update DB
$db->query_update('misc', array('valeur' => $_POST['changer_complexite']), "type='complex' AND intitule = " . $id[1]);
}
//Get title to display it
echo $mdp_complexite[$_POST['changer_complexite']][1];
//rebuild the tree grid
$tree = new NestedTree($pre . 'nested_tree', 'id', 'parent_id', 'title');
$tree->rebuild();
} else {
if (isset($_POST['type'])) {
switch ($_POST['type']) {
// CASE where DELETING a group
case "supprimer_groupe":
// this will delete all sub folders and items associated
示例14: array
if (isset($_POST["titlechange"]) && $isadmin == 1) {
$tickid = $mydb->clean($_POST["tickid"], '', '');
$mydb->query_update("list", array('title' => $_POST["titlechange"]), "id='{$tickid}'");
echo "Title changed.";
}
if (isset($_POST["closeticket"]) && $isadmin == 1) {
$closeticket = $mydb->clean($_POST["tickid"], '', '');
$mydb->query_update('list', array('status' => 0, 'finished' => time()), "id='{$closeticket}'");
echo "Ok";
}
if (isset($_POST["openticket"]) && $isadmin == 1) {
$closeticket = $mydb->clean($_POST["tickid"], '', '');
$mydb->query_update('list', array('status' => 1, 'finished' => '0'), "id='{$closeticket}'");
echo "Ok";
}
if (isset($_POST["changepri"]) && $isadmin == 1) {
$changepri = $mydb->clean($_POST["changepri"], '', '');
$id = $mydb->clean($_POST["id"], '', '');
$mydb->query_update('list', array('priority' => $changepri), "id='{$id}'");
//print_r($_POST);
}
// adds to do items
if (isset($_POST["addtodo"])) {
$id = $mydb->clean($_POST["id"], '', '');
$mydb->query_insert('todo_list', array('id' => 'null', 'tid' => $_POST['id'], 'content' => $_POST['item'], 'status' => 0));
echo $mydb->lastID();
}
if (isset($_POST["markfinish"])) {
$mydb->query_update('todo_list', array('status' => 1), "id='" . $mydb->clean($_POST["id"], '', '') . "'");
}
//print_r($_POST);
示例15:
$parent_check = $db->query($parent_rec);
//check if parend data exist
if ($record = $db->fetch_array($parent_check)!=null) {
// $prnt_code['email_code'] = md5($record['email'] + microtime());//for email ver.
// $db->query_update("tblparents", $prnt_code, "id='$parent_id'");
//check slot available
$checkSlot = "SELECT student_id, student_id2, student_id3 FROM tblparents where id='$parent_id'";
$queryCheck = $db->query($checkSlot);
while ($record = $db->fetch_array($queryCheck)) {
if ($record['student_id']=="" && $student0['fname'] != NULL && $student0['lname'] != NULL && $student0['year_level'] != NULL ) {
$primary_id = $db->query_insert("tblstudents", $student0);//insert new student record in the tblstudents
$newStdID["student_id"] = $primary_id;
$db->query_update("tblparents", $newStdID, "id='$parent_id'");
if ($record['student_id2']=="" && $student1['fname'] != NULL && $student1['lname'] != NULL && $student1['year_level'] != NULL ){
$primary_id = $db->query_insert("tblstudents", $student1);//insert new student record in the tblstudents
$newStdID["student_id2"] = $primary_id;
$db->query_update("tblparents", $newStdID, "id='$parent_id'");
}
if($record['student_id3']=="" && $student2['fname'] != NULL && $student2['lname'] != NULL && $student2['year_level'] != NULL ){
$primary_id = $db->query_insert("tblstudents", $student2);//insert new student record in the tblstudents
$newStdID["student_id3"] = $primary_id;
$db->query_update("tblparents", $newStdID, "id='$parent_id'");