本文整理匯總了PHP中sql_insert函數的典型用法代碼示例。如果您正苦於以下問題:PHP sql_insert函數的具體用法?PHP sql_insert怎麽用?PHP sql_insert使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了sql_insert函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: CreatCardApplyInfo
/**
* 創建道具卡申請訂單
* @param unknown_type $cd_CAFormName
* @param unknown_type $cd_CAFormRemark
* @param unknown_type $CardStr
* @param unknown_type $EmailBody
*/
public function CreatCardApplyInfo($cd_CAFormName, $cd_CAFormRemark, $CardStr, $EmailBody)
{
if (!isset($_SESSION)) {
session_start();
}
if (!isset($_SESSION['account_ID']) || !isset($_SESSION['user'])) {
return new ExcuteResult(ResultStateLevel::ERROR, "賬號已登出,請重新登錄", "-1");
}
$AccountName = $_SESSION['user'];
$Time = date("Y-m-d H:i:s");
$sql_apply = "insert into CD_CardApplyForm (cd_CAFormName,cd_CAFormRemark,cd_CardApplyer,cd_CardApplyTime,cd_CAFormState)";
$sql_apply .= " values ('{$cd_CAFormName}','{$cd_CAFormRemark}','{$AccountName}','{$Time}',-1)";
$r = sql_insert($sql_apply);
if ($r != 0) {
$applyID = $r;
$arr = array("NULL" => $applyID);
$addCardInfo = strtr($CardStr, $arr);
$sql_apply_card = "insert into CD_CAFormCardInfo(cd_CAFormID,cd_CardTypeID,cd_CardNum) values " . $addCardInfo;
$add_card = sql_query($sql_apply_card);
if ($add_card != 0) {
$sql_apply_update = "UPDATE CD_CardApplyForm set cd_CAFormState = 0 where cd_CAFormID = " . $applyID;
$sql_update = sql_query($sql_apply_update);
if ($r != 0) {
return new ExcuteResult(ResultStateLevel::SUCCESS, "", NULL);
} else {
return new ExcuteResult(ResultStateLevel::SUCCESS, "卡更新狀態失敗!", NULL);
}
} else {
return new ExcuteResult(ResultStateLevel::ERROR, "CD_CAFormCardInfo 新增失敗", NULL);
}
} else {
return new ExcuteResult(ResultStateLevel::ERROR, "CD_CardApplyForm 新增失敗", NULL);
}
}
示例2: get_value
/**
* функци¤ возвращет конкретное значение из полученного массива данных по ip
*
* @param string - ключ массива. ≈сли интересует конкретное значение.
* люч может быть равным 'inetnum', 'country', 'city', 'region', 'district', 'lat', 'lng'
* @param boolean - устанавливаем хранить данные в базе или нет
* ≈сли true, то в таблицу ipgeobase будут записаны данные по ip и повторные запросы на ipgeobase происходить не будут.
* ≈сли false, то данные посто¤нно будут запрашиватьс¤ с ipgeobase
*
* @return array OR string - дополнительно читайте комментарии внутри функции.
*/
function get_value($key = false, $from_db = true)
{
$key_array = array('inetnum', 'country', 'city', 'region', 'district', 'lat', 'lng');
if (!in_array($key, $key_array)) {
$key = false;
}
$data = null;
// если используем базу, то достаем данные
if ($from_db) {
$numeric_ip = $this->numeric_ip($this->ip);
$data = sql_getRow("SELECT * FROM `{$this->dbname}`.`{$this->table}` WHERE (from_ip>={$numeric_ip} AND to_ip<={$numeric_ip}) LIMIT 1");
}
if (!$data) {
$data = $this->get_geobase_data();
$inetnum = explode('-', $data['inetnum']);
if ($data && $data['country']) {
sql_insert("`{$this->dbname}`.`{$this->table}`", array('from_ip' => $this->numeric_ip($inetnum[0]), 'to_ip' => $this->numeric_ip($inetnum[1]), 'country' => $data['country'], 'city' => $data['city'], 'region' => $data['region'], 'district' => $data['district'], 'lat' => $data['lat'], 'lng' => $data['lng']));
}
}
if ($key) {
return $data[$key];
// если указан ключ, возвращаем строку с нужными данными
} else {
return $data;
// иначе возвращаем массив со всеми данными
}
}
示例3: insert
function insert($table, $vyber)
{
if ($_POST[submit]) {
//var_dump($_POST);
$meno = sec_sql(sec_input($_POST["meno"]));
$email_meno = sec_sql(sec_input($_POST["email_meno"]));
if (strlen($meno) > 50 or strlen($meno) < 2) {
$error_msg[] = "Meno môže mať od 4 do 50 znakov";
}
if (empty($error_msg)) {
if ($table == "dodavatel") {
$query = "INSERT INTO {$table} (meno)\r\n VALUES (\"{$meno}\")\r\n ";
}
if ($table == "do_produkt") {
$query = "INSERT INTO {$table} (meno, email_meno)\r\n VALUES (\"{$meno}\", \"{$email_meno}\")\r\n ";
}
sql_insert($query);
header("location: index.php?vyber={$vyber}&sub={$table}");
} else {
echo "<div id=error_message>" . implode("<br>", $error_msg) . "</div>";
}
$data = $_SESSION["posted_form_add_new_item_{$table}"];
}
echo "<form method=\"POST\">";
echo textfield("meno", $meno, "Meno *", 50, 20);
if ($table == "do_produkt") {
echo textfield("email_meno", $email_meno, "Email meno", 50, 40);
}
echo submit("submit", "Odoslať");
echo "</form>";
}
示例4: _home
public function _home() {
global $config, $user, $cache;
if (!_button()) {
return;
}
$this->id = request_var('msg_id', 0);
$sql = 'SELECT *
FROM _forum_topics
WHERE topic_id = ?';
if (!$this->object = sql_fieldrow(sql_filter($sql, $this->id))) {
fatal_error();
}
$this->object = (object) $this->object;
$this->object->new_value = ($this->object->topic_featured) ? 0 : 1;
topic_feature($this->id, $this->object->new_value);
$sql_insert = array(
'bio' => $user->d('user_id'),
'time' => time(),
'ip' => $user->ip,
'action' => 'feature',
'old' => $this->object->topic_featured,
'new' => $this->object->new_value
);
sql_insert('log_mod', $sql_insert);
return redirect(s_link('topic', $this->id));
}
示例5: AddBMAccountEventLog
/**
* 增加後台基本模塊操作日誌
* @param $Remark
* @param $EventType=1 後台基礎信息 2=卡庫 10=
*/
function AddBMAccountEventLog($Remark, $EventType)
{
if (!isset($_SESSION)) {
session_start();
}
if (!isset($_SESSION['account_ID'])) {
return;
} else {
$accountID = $_SESSION['account_ID'];
$accountName = "";
if (isset($_SESSION['user'])) {
$accountName = $_SESSION['user'] . "操作:";
}
if (defined('TIMEZONE')) {
$timezone = TIMEZONE;
if (function_exists('date_default_timezone_set')) {
date_default_timezone_set($timezone);
}
}
$Time = date("Y-m-d H:i:s");
$OperateIP = Utils::get_client_ip();
$Remark = $accountName . $Remark;
$sql = "INSERT INTO bm_event_log(event_type, account_id, operate_ip, event_desc, add_time) \r\n\t\t\tVALUES ({$EventType}, {$accountID}, '{$OperateIP}', '{$Remark}', '{$Time}')";
sql_insert($sql);
}
}
示例6: _home
public function _home() {
global $config, $user, $cache;
sql_truncate('_smilies');
$emoticon_path = $config['assets_path'] . 'emoticon/';
$process = 0;
$fp = @opendir($emoticon_path);
while ($file = @readdir($fp)) {
if (preg_match('#([a-z0-9]+)\.(gif|png)#is', $file, $part)) {
$insert = array(
'code' => ':' . $part[1] . ':',
'smile_url' => $part[0]
);
sql_insert('smilies', $insert);
$process++;
}
}
@closedir($fp);
$cache->delete('smilies');
return _pre($process . ' emoticons.');
}
示例7: MyCommit
function MyCommit($row)
{
// Переносим изображение
if ($row['image'] && getimagesize('..' . $row['image']) && strpos($row['image'], 'plans') === false) {
$object_id = sql_getValue('SELECT pid FROM obj_elem_plans WHERE id=' . $row['pid']);
$dir = '../files/objects/' . $object_id;
if (!is_dir($dir)) {
mkdir($dir);
mkdir($dir, 0770);
}
$dir .= '/plans';
if (!is_dir($dir)) {
mkdir($dir);
mkdir($dir, 0770);
}
$new_name = $dir . '/' . basename($row['image']);
rename('..' . $row['image'], $new_name);
$row['image'] = substr($new_name, 2);
}
if ($_POST['id']) {
sql_update($this->elem_table, $row, 'id = ' . $_POST['id']);
} else {
sql_insert($this->elem_table, $row);
}
$err = sql_getError();
if (empty($err)) {
return 1;
}
return $err;
}
示例8: formulaires_ecatalogue_prices_group_traiter_dist
function formulaires_ecatalogue_prices_group_traiter_dist()
{
$result = array();
$is_active = _request('is_active');
$prices_group = _request('price');
$elements_insert = _request('elements_insert');
$isset_price_group = sql_select('*', 'spip_ecatalogue_prices_group');
if ($isset_price_group) {
while ($row = sql_fetch($isset_price_group)) {
$id_price_group = $row['id_group'];
if (isset($prices_group[$id_price_group])) {
$name = $prices_group[$id_price_group];
$status = isset($is_active[$id_price_group]) ? 1 : 0;
sql_update('spip_ecatalogue_prices_group', array('titre' => '"' . $name . '"', 'is_active' => $status), 'id_group = ' . (int) $id_price_group);
} else {
sql_delete('spip_ecatalogue_prices_group', 'id_group = ' . $id_price_group);
// Delete price group
}
}
}
if (is_array($elements_insert) && !empty($elements_insert)) {
foreach ($elements_insert as $key => $value) {
$name = $value['titre'];
$is_active = isset($value['is_active']) ? 1 : 0;
sql_insert('spip_ecatalogue_prices_group', '(titre,is_active)', '("' . $name . '",' . $is_active . ')');
}
}
return $result;
}
示例9: create
private function create() {
$v = _request(array('username' => ''));
if (_empty($v)) return;
$v->username = get_username_base($v->username);
$sql = 'SELECT *
FROM _members
WHERE username_base = ?';
if (!$result = sql_fieldrow(sql_filter($sql, $v->username))) {
return;
}
$sql = 'SELECT *
FROM _banlist
WHERE ban_userid = ?';
if (!$ban = sql_fieldrow(sql_filter($sql, $result['user_id']))) {
$insert = array(
'ban_userid' => $result['user_id']
);
sql_insert('banlist', $insert);
$sql = 'DELETE FROM _sessions
WHERE session_user_id = ?';
sql_query(sql_filter($sql, $result['user_id']));
echo 'El usuario ' . $result['username'] . ' fue bloqueado.';
}
return true;
}
示例10: _home
public function _home() {
global $config, $user, $cache;
if ($submit) {
return false;
}
$bot_name = request_var('bot_name', '');
$bot_agent = request_var('bot_agent', '');
$bot_ip = request_var('bot_ip', '');
$bot_base = get_username_base($bot_name);
$sql = 'SELECT *
FROM _bots
WHERE bot_name = ?';
$insert = true;
if ($row = sql_fieldrow(sql_filter($sql, $bot_name))) {
$insert = false;
if ($row['bot_ip'] != $bot_ip) {
$sql = 'UPDATE _bots SET bot_ip = ?
WHERE bot_id = ?';
sql_query(sql_filter($sql, $row['bot_ip'] . ',' . $bot_ip, $row['bot_id']));
}
}
if ($insert)
{
$insert_member = array(
'user_type' => 2,
'user_active' => 1,
'username' => $bot_name,
'username_base' => $bot_base,
'user_timezone' => -6.00,
'user_lang' => 'spanish'
);
$bot_id = sql_insert('members', $insert_member);
$insert_bot = array(
'bot_active' => 1,
'bot_name' => $bot_name,
'user_id' => $bot_id,
'bot_agent' => $bot_agent,
'bot_ip' => $bot_ip,
);
sql_insert('bots', $insert_bot);
}
$sql = "DELETE FROM _sessions
WHERE session_browser LIKE '%??%'";
sql_query(sql_filter($sql, $bot_name));
$cache->delete('bots');
return;
}
示例11: addMessageToArchive
public function addMessageToArchive($message)
{
// there are no some fields in cb_mail_archive table
unset($message['smtp_server_id']);
$message['sended_from'] = $message['from_mail'];
$message['sended_time'] = date("Y-m-d H:i:s");
$message['error_type'] = 0;
$message['error_text'] = '';
$result = sql_insert('cb_mail_archive', $message);
//using internal clientbase.ru function to avoid problems with quotes
return $result;
}
示例12: sdk_log
/**
*
* System Log Entry
*
* Dev Future: add auto creation of bugs for certain categories
*
* severity options based on bootstrap color swatches
* default (grey), primary (dk blue), success (green), info (light blue), warning (yellow), danger (red)
*
* action options:
* AUTH CREATE - New user created
* AUTH SUCCESS - Login attempt successful
* AUTH FAILURE - Login attempt failed
* AUTH PASSSWD - Password reset or changed
* AUTH TERMINATE - Session expired or logged out
* SQL INSERT - Database record inserted
* SQL UPDATE - Database record updated
* SQL DELETE - Database record deleted
* FORM VALIDATION - Validation error in a form post
* PAGE VIEW - User viewed page
*
*/
function sdk_log($severity, $action, $message, $ref_key = '', $ref_value = '0')
{
// Define Global Variables
global $ses_sdk_act_usr;
global $ses_sdk_act_ses;
// Create array of columns/values for database
$sql_insert_values = array('sdk_act_usr' => $ses_sdk_act_usr, 'sdk_act_ses' => $ses_sdk_act_ses, 'sdk_sys_log_ref_key' => $ref_key, 'sdk_sys_log_ref_value' => $ref_value, 'sdk_sys_log_severity' => $severity, 'sdk_sys_log_action' => $action, 'sdk_sys_log_message' => $message);
// Execute SQL Query to Insert New Row
$sql_insert_exec = sql_insert('sdk_sys_log', $sql_insert_values);
// Return the Log UID
return $sql_insert_exec;
}
示例13: AddStore
public function AddStore($name, $province, $city, $district, $addr, $contacts, $phone)
{
if (!isset($_SESSION['account_ID'])) {
return new ExcuteResult(ResultStateLevel::ERROR, "賬號已登出,請重新登錄", "-1");
}
$account_id = $_SESSION['account_ID'];
$sql = "INSERT INTO bm_store_info(account_id,shop_name,shop_province,shop_city,shop_district,shop_addr,shop_contacts,shop_phone,shop_state)" . "VALUE('{$account_id}','{$name}','{$province}','{$city}','{$district}','{$addr}','{$contacts}','{$phone}',0);";
$r = sql_insert($sql);
if ($r != 0) {
return new ExcuteResult(ResultStateLevel::SUCCESS, "", $r[0]);
} else {
return new ExcuteResult(ResultStateLevel::EXCEPTION, "執行出錯", $sql);
}
}
示例14: AddShoppingCart
/**
* 添加到購物車
*/
public function AddShoppingCart($_GoodsId, $_GoodsNum)
{
if (!isset($_SESSION['account_ID'])) {
return new ExcuteResult(ResultStateLevel::ERROR, "賬號已登出,請重新登錄", "-1");
}
$account_id = $_SESSION['account_ID'];
$sql = "insert into bm_shopping_cart(account_id,goods_id,goods_num,add_time) values('{$account_id}','{$_GoodsId}','{$_GoodsNum}',now())";
$r = sql_insert($sql);
if ($r != 0) {
return new ExcuteResult(ResultStateLevel::SUCCESS, "", $r[0]);
} else {
return new ExcuteResult(ResultStateLevel::EXCEPTION, "執行出錯", $sql);
}
}
示例15: AddMailApplay
/**
* 新增郵件申請
* @param unknown_type $serverID
* @param unknown_type $users
* @param unknown_type $title
* @param unknown_type $desc
* @param unknown_type $remark
* @param unknown_type $delTime
* @param unknown_type $ApplyDesc
*/
public function AddMailApplay($gameID, $serverID, $users, $title, $desc, $delTime, $ApplyDesc, $sendType, $attchID, $attNum)
{
if (!isset($_SESSION['account_ID'])) {
return new ExcuteResult(ResultStateLevel::ERROR, "賬號已登出,請重新登錄", "-1");
}
$sql_check = "SELECT bm_AreaID, bm_ServerConnString, bm_ServerName FROM bm_gameserver WHERE bm_ServerID = " . $serverID;
$r_check = sql_fetch_one($sql_check);
if ($r_check == "") {
return new ExcuteResult(ResultStateLevel::ERROR, "此遊戲服務器不存在或已被刪除!", NULL);
}
$AreaID = $r_check[0];
$ServerName = $r_check[2];
$AccessoriesFlag = 1;
$GameMailTarget = '全服發送';
$GameMailNickName = '全服發送';
$now = date("Y-m-d H:i:s");
if ($attchID == 0 && $attNum == 0) {
$AccessoriesFlag = 0;
}
$markAry['mailExpired'] = $delTime;
$markAry['attachID'] = $attchID;
$markAry['attachNum'] = $attNum;
$markAry['type'] = $sendType;
$markAry['note'] = $ApplyDesc;
$mailApplyRemark = json_encode($markAry);
$currentUser = $_SESSION['user'];
if (!empty($users)) {
$usernames = str_replace(array("\r", "\n"), array("", ","), trim($users));
if ($sendType == 0) {
//passport
$GameMailTarget = $usernames;
$GameMailNickName = '';
} else {
$GameMailTarget = '';
$GameMailNickName = $usernames;
}
}
$sql = "INSERT INTO bm_gamemail( bm_GameID, bm_AreaID, bm_ServerID, bm_ServerName, bm_GameMailTitle, bm_GameMailDesc,\r\n \t\t\t\tbm_GameMailTarget, bm_GameMailNickName, bm_MailApplyRemark, bm_MailApplyFlag, bm_AccessoriesFlag, \r\n \t\t\t\tbm_GameMailSendState, bm_ApplyState, bm_Account, bm_CreatTime) VALUES( {$gameID}, {$AreaID}, {$serverID}, \r\n \t\t\t\t'{$ServerName}', '{$title}', '{$desc}', '{$GameMailTarget}', '{$GameMailNickName}', \r\n \t\t\t\t'{$mailApplyRemark}', 1, {$AccessoriesFlag}, 0, 0, '{$currentUser}', '{$now}')";
$insertID = sql_insert($sql);
if ($insertID && $attchID != 0 && $attNum != 0) {
$sqladd = "INSERT INTO bm_gamemailaffixitem(bm_GameMailID, bm_ItemID, bm_ItemNum) VALUES({$insertID}, {$attchID},{$attNum})";
$r_add = sql_query($sqladd);
if ($r_add == 0) {
return new ExcuteResult(ResultStateLevel::ERROR, "訂單生成,道具信息插入失敗!", NULL);
} else {
return new ExcuteResult(ResultStateLevel::SUCCESS, "", NULL);
}
}
return new ExcuteResult(ResultStateLevel::ERROR, "生成訂單失敗", $sql);
}