本文整理汇总了PHP中insert函数的典型用法代码示例。如果您正苦于以下问题:PHP insert函数的具体用法?PHP insert怎么用?PHP insert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了insert函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: tagpatch_u
function tagpatch_u($p, $o, $res = '')
{
//$p='type';
$p = utf8_decode($p);
$r = sql('ib,msg', 'qdd', 'kv', 'val="' . $p . '"');
//id>'.$p.' limit 10000
foreach ($r as $k => $v) {
$r[$k] = tri_tag($v);
foreach ($r[$k] as $ka => $va) {
if ($va) {
$ra[$va] += 1;
$rb[$k][] = $va;
}
}
}
//p($rb);
foreach ($ra as $k => $v) {
$idtag = sql('id', 'qdt', 'v', 'cat="' . $p . '" and tag="' . $k . '"');
if (!$idtag) {
$idtag = insert('qdt', '("","' . $p . '","' . $k . '")');
}
$rtag[$k] = $idtag;
}
foreach ($rb as $k => $v) {
foreach ($v as $ka => $va) {
$idtag = $rtag[$va];
$ex = sql('id', 'qdta', 'v', 'idart="' . $k . '" and idtag="' . $idtag . '"');
if (!$ex) {
insert('qdta', '("","' . $k . '","' . $idtag . '")');
}
}
}
$ret = $p . ':' . sql('count(id)', 'qdt', 'v', '') . '-' . sql('count(id)', 'qdta', 'v', '');
return $ret;
}
开发者ID:philum,项目名称:cms,代码行数:35,代码来源:tagpatch.php
示例2: addUser
function addUser()
{
$arr = $_POST;
$arr['pubTime'] = time();
$path = "../uploads";
$uploadFiles = uploadFile($path);
$totalCap = $arr['capacity'] + getCityCapById($arr['cId']);
$sql = "update biogas_city set totalCap=" . $totalCap . " where id=" . $arr['cId'];
mysql_query($sql);
//更新城市的总池容
$res = insert("biogas_user", $arr);
$uid = getInsertId();
if ($res && $uid) {
if ($uploadFiles && is_array($uploadFiles)) {
foreach ($uploadFiles as $uploadFile) {
$arr1['uid'] = $uid;
$arr1['albumPath'] = $uploadFile['name'];
addAlbum($arr1);
}
}
$mes = "<p>添加成功!</p><a href='addUser.php' target='mainFrame'>继续添加</a>|<a href='listUser.php' target='mainFrame'>查看用户列表</a>";
} else {
$mes = "<p>添加失败!</p><a href='addUser.php' target='mainFrame'>重新添加</a>";
}
return $mes;
}
开发者ID:BigeyeDestroyer,项目名称:biogas,代码行数:26,代码来源:user.inc.php
示例3: emailcheck
function emailcheck()
{
$dbc = connectToDB("leeawg");
$join_name = $_POST['name'];
$join_email = $_POST['email'];
$join_username = $_POST['username'];
$join_password = $_POST['password'];
$join_securepw = sha1($join_password);
$join_age = $_POST['age'];
$q_emailCheck = "SELECT email FROM account WHERE email = '{$join_email}';";
$q_usernameCheck = "SELECT user_id FROM account WHERE user_id = '{$join_username}';";
$emailCheck_result = performQuery($dbc, $q_emailCheck);
$emailCheck_duplicate = mysqli_fetch_array($emailCheck_result, MYSQLI_ASSOC);
$usernameCheck_result = performQuery($dbc, $q_usernameCheck);
$usernameCheck_duplicate = mysqli_fetch_array($usernameCheck_result, MYSQLI_ASSOC);
if (mysqli_num_rows($usernameCheck_result) == 0 && mysqli_num_rows($emailCheck_result) == 0) {
//echo "no duplicate :)";
$query = "INSERT INTO account (user_id,password,name,age,email)\n\t\tVALUES ( '{$join_username}', '{$join_securepw}', '{$join_name}', '{$join_age}', '{$join_email}' )";
insert($dbc, $query);
}
if (mysqli_num_rows($emailCheck_result) > 0) {
errorform('email');
}
if (mysqli_num_rows($usernameCheck_result) > 0) {
errorform('username');
}
}
开发者ID:smblee,项目名称:smblee.github.io,代码行数:27,代码来源:dboperation.php
示例4: addCity
function addCity()
{
$arr = $_POST;
$city_get = getTemp($arr['city']);
$city_info['city'] = $arr['city'];
$city_info['pinyin'] = $city_get['pinyin'];
$city_info['pubDate'] = $city_get['date'];
$city_info['longitude'] = $city_get['longitude'];
$city_info['latitude'] = $city_get['latitude'];
$city_info['altitude'] = $city_get['altitude'];
$city_info['pId'] = $arr['pId'];
$city_info['totalCap'] = 0;
$cName = $city_info['city'];
$pinyin = $city_info['pinyin'];
$str = "<?php" . "\r\n" . "require_once '../lib/mysql.func.php';\r\n" . "require_once '../lib/temp.func.php';\r\n" . "\r\n" . "mysql_connect(\"localhost:/tmp/mysql.sock\",\"root\",\"\");\r\n" . "mysql_set_charset(\"utf8\");\r\n" . "mysql_select_db(\"biogas\");\r\n" . "\r\n" . "\$res = getItem('" . $cName . "');\r\n" . "\$res_insert = array();\r\n" . "\$res_insert['date'] = \$res['date'];\r\n" . "\$res_insert['l_tmp'] = \$res['l_tmp'];\r\n" . "\$res_insert['h_tmp'] = \$res['h_tmp'];\r\n" . "insert(\$res['pinyin'].\"_tmp\", \$res_insert);";
$filename = '../tmp_update/' . $pinyin . '_update.php';
if (insert("biogas_city", $city_info)) {
createTable($city_info['pinyin']);
//(1) 创建城市温度表
file_put_contents($filename, $str);
//(2) 创建温度更新脚本
chmod($filename, 0777);
$mes = "添加成功!<br/><a href='addCity.php'>继续添加!</a>|<a href='listCity.php'>查看列表!</a>";
} else {
$mes = "添加失败!<br/><a href='addCity.php'>重新添加!</a>|<a href='listCity.php'>查看列表!</a>";
}
return $mes;
}
开发者ID:BigeyeDestroyer,项目名称:biogas,代码行数:28,代码来源:city.inc.php
示例5: addComm
/**
*添加评论
*/
function addComm()
{
$mes = array();
$parent_id = addslashes($_POST['parent_id']);
$pro_id = addslashes($_POST['pro_id']);
$sender_id = $_SESSION['id'];
$receiver_id = addslashes($_POST['receiver_id']);
if ($receiver_id == '') {
$receiver_id = 0;
}
$content = addslashes($_POST['text']);
$comm = array('parent_id' => $parent_id, 'pro_id' => $pro_id, 'sender_id' => $sender_id, 'receiver_id' => $receiver_id, 'content' => $content, 'status' => 0, 'reg_time' => time());
if (insert("tuhao_comm", $comm)) {
$id = getInsertId();
$sql = "select * from tuhao_comm where id={$id}";
$row = fetchOne($sql);
$sql1 = "select pro_name from tuhao_pro where id={$row['pro_id']}";
$sql2 = "select head_photo from tuhao_info where user_id={$row['sender_id']}";
$sql3 = "select username from tuhao_user where id={$row['sender_id']}";
$sql4 = "select username from tuhao_user where id={$row['receiver_id']}";
$sender = fetchOne($sql3);
$receiver = fetchOne($sql4);
$proName = fetchOne($sql1);
$src = fetchOne($sql2);
$row['sender_author'] = $sender['username'];
$row['receiver_author'] = $receiver['username'];
$row['goods_name'] = $proName['pro_name'];
$row['src'] = "uploads/" . $src['head_photo'];
$row['comments'] = array();
$mes = array('mes' => '评论成功', 'code' => 1, 'data' => $row);
} else {
$mes = array('mes' => '评论失败', 'code' => 0);
}
echo json_encode($mes);
}
开发者ID:JimmyVV,项目名称:TuhaoWeb,代码行数:38,代码来源:comment.inc.php
示例6: register
function register($name, $username, $password)
{
$message = [];
if (empty($name) || empty($username) || empty($password)) {
$message[] = "Please all fields are required";
} else {
$passlength = strlen($password);
if ($passlength >= 5 && $passlength <= 20) {
$query_run = mysql_query("SELECT * FROM `users` WHERE \n\t \t`username`='{$username}'");
if (mysql_num_rows($query_run) >= 1) {
$message[] = "Username already exists!";
}
if (count($message) == 0) {
// no errors
$password = md5($password);
if (insert('users', ['name' => $name, 'username' => $username, 'password' => $password])) {
$message[] = "Thank you for joining! <a href='login.php'>Click here to log in</a>";
}
}
} else {
$message[] = "Password characters out of required range( 5 - 20 )";
}
}
return $message;
}
开发者ID:brightantwiboasiako,项目名称:tratech2016,代码行数:25,代码来源:user.php
示例7: insert_reply_flagged
function insert_reply_flagged($plcrno, $mno, $flag_note, $cboxes, $date_time)
{
$res = insert('fs_plcm_rflag', array('plcrno', 'mno', 'rflag_option', 'rflag_note', 'rflag_date'), array($plcrno, $mno, $flag_note, $cboxes, $date_time), 'rflagno');
if ($res) {
echo "reply comment flag successfully added!";
}
}
开发者ID:jesus143,项目名称:fs-dev,代码行数:7,代码来源:replyFunc.php
示例8: create
/**
* Zeigt ein Formular zum erstellen einer Seite an
*/
function create()
{
global $msg, $mysql;
if (isset($_POST['content'])) {
if (!insert($_POST['title'], $_POST['content'], $_POST['firstpage'], $_POST['files'])) {
return;
}
$msg->error("Bitte füllen Sie alle Felder aus.");
}
$q = $mysql->query("SELECT * FROM " . _PREFIX_ . "files");
while ($o = mysql_fetch_object($q)) {
$files .= "<option value=" . $o->id . ">" . $o->name . "</option>";
}
$qFirstPage = $mysql->query("SELECT * FROM " . _PREFIX_ . "pages WHERE firstpage=1");
if ($o = @mysql_fetch_object($qFirstPage)) {
$curFirstPage = 'Die momentane Startseite ist: ' . $o->title;
}
/**
* Die Bilderliste auslesen und erstellen
*/
$qImages = $mysql->query("SELECT * FROM " . _PREFIX_ . "images");
$imageTpl = @file_get_contents(dirname(__FILE__) . "/../template/editor.images.tpl");
while ($o = mysql_fetch_object($qImages)) {
$images .= str_replace(array("%name%", "%fullurl%", "%thumburl%"), array($o->name, IMAGE_DIR . $o->file, IMAGE_DIR . $o->file_t), $imageTpl);
}
// Template ausfüllen -->
$template = @file_get_contents(dirname(__FILE__) . "/../template/editor.tpl");
$template = str_replace(array("%cur_firstpage%", "%title%", "%content%", "%file%", "%images%"), array($curFirstPage, $_POST['title'], $_POST['content'], $files, $images), $template);
// <-- Template ausfüllen
return $template;
}
开发者ID:nubix,项目名称:cms,代码行数:34,代码来源:function.create.php
示例9: month_total_fee
function month_total_fee($month)
{
$year = explode('-', $month)[0];
$mon = explode('-', $month)[1];
//获取需要的月份相应交费记录并计算总费用
$sql = "select fee,date,dueDate from hh_fee";
$rows = fetchAll($sql);
$total = 0;
foreach ($rows as $row) {
$day1 = $row['date'];
$day2 = $row['dueDate'];
$fee = $row['fee'];
$T = ceil($fee / days_dis($day1, $day2));
//$T为 该笔学费每天的收入
$days = month_days($day1, $day2, $month);
if ($days) {
$total = $days * $T + $total;
}
}
$arr = array('year' => $year, 'month' => $mon, 'total' => $total);
//如果已存在相应日期记录,则进行更新操作,否则进行插入
$sql = "select count(total) from hh_totalFee where year={$year} and month={$mon}";
$result = fetchOne($sql)['count(total)'];
if ($result >= 1) {
update('hh_totalFee', $arr, "year={$year} and month={$mon}");
} else {
insert('hh_totalFee', $arr);
}
}
开发者ID:hardihuang,项目名称:happyhome_admin,代码行数:29,代码来源:analyze.inc.php
示例10: view_post
function view_post()
{
$data = $_POST['data'];
$data['post_id'] = $this->params[0];
$data['comment_author'] = 'Gunnar';
insert('comment', $data);
}
开发者ID:ramonp233,项目名称:blog,代码行数:7,代码来源:posts.php
示例11: add_new_score
function add_new_score($name, $score)
{
$name = addslashes($name);
$score = addslashes($score);
$sql = "insert into scores(name, score) values ('{$name}', '{$score}')";
insert($sql);
}
开发者ID:juggernautt,项目名称:lines,代码行数:7,代码来源:BL.php
示例12: add
public function add()
{
$this->form_validation->set_rules('name', 'Company Name', 'trim|required');
if ($this->form_validation->run() == FALSE) {
$this->template->load('admin', 'admin/company/add');
} else {
$config['upload_path'] = './uploads/company/';
$config['allowed_types'] = 'gif|jpg|png';
$config['remove_spaces'] = TRUE;
$this->upload->initialize($config);
if (!$this->upload->do_upload('image')) {
$error = array('error' => $this->upload->display_errors());
if (strip_tags($error['error'], '') != 'You did not select a file to upload.') {
$this->session->set_flashdata('error', $error['error']);
redirect('admin/company/add');
}
} else {
$data = array('upload_data' => $this->upload->data());
$image = $data['upload_data']['file_name'];
}
$name = $this->input->post('name');
$about_company = htmlentities($this->input->post('about_company'));
if (!empty($image)) {
$file_path = 'uploads/company/' . $image;
} else {
$file_path = 'uploads/defaults/test.jpg';
}
$data_add = array('company_name' => $name, 'about_company' => $about_company, 'logo' => $file_path, 'is_delete' => 0);
insert('company_mst', $data_add);
$this->session->set_flashdata('success', 'Company has been Successfully Created.');
redirect('admin/company');
}
}
开发者ID:virendrapatel99,项目名称:surat,代码行数:33,代码来源:Company.php
示例13: importSlice
function importSlice($wikiIdstart, $wikiIdEnd, $start, $slice)
{
global $dbs, $startFrom;
$res = $dbs->select(array('pages'), array('page_id', 'page_wikia_id', 'page_last_edited', 'UNIX_TIMESTAMP(page_last_edited) as page_last_edited_unix'), array("page_namespace = " . NS_FILE, "page_wikia_id BETWEEN {$wikiIdstart} and {$wikiIdEnd}", "page_last_edited BETWEEN FROM_UNIXTIME({$startFrom}) and NOW()"), __METHOD__, array('ORDER BY' => 'page_latest ASC', 'OFFSET' => $start, 'LIMIT' => $slice));
while ($row = $dbs->fetchRow($res)) {
insert($row);
}
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:8,代码来源:imageReview.php
示例14: addarticle
function addarticle($table,$arr){
if(insert("dw_article",$arr)){
echo "添加文章成功,你可以<a href='add_article.php'>继续添加</a>|<a href='list_article.php'>查看文章列表</a";
}
else{
echo "添加失败<a href='list_article.php'>查看文章列表</a";
}
}
开发者ID:knight-zhou,项目名称:PHP-HTML,代码行数:8,代码来源:article.fun.php
示例15: edit_post
function edit_post()
{
$data = $_POST['data'];
$data['user_id'] = $this->params[0];
$data['active'] = isset($data['active']) ? 1 : 0;
insert('user', $data);
header('Location: ' . BASE_URL . 'users/view/' . $this->params[0]);
}
开发者ID:PindsterY,项目名称:Meliss,代码行数:8,代码来源:users.php
示例16: POST_index
function POST_index()
{
// Check if the controller's table already exists in the database
// $table_names_are_singular = true; # currently plural names are not supported
$name_plural = $_POST['name_plural'];
$name_singular = $_POST['name_singular'];
$table_name = $name_plural;
$table_prefix = $name_singular;
if (q("SHOW TABLES LIKE '{$table_name}'")) {
// Show error
echo '<div class="alert alert-danger">' . "The table {$name_plural} already existed. Aborting." . '</div>';
} else {
// SQL injection protection
global $db;
$table_name_escaped = mysqli_real_escape_string($db, $table_name);
$table_prefix_escaped = mysqli_real_escape_string($db, $table_prefix);
// Add table to database
q("CREATE TABLE `{$table_name_escaped}` (\n `{$table_prefix_escaped}_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Autocreated',\n `{$table_prefix_escaped}_name` varchar(50) NOT NULL COMMENT 'Autocreated',\n PRIMARY KEY (`{$table_prefix_escaped}_id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
// Print banner
// Add 2 rows to database
insert($table_name, array($table_prefix . '_name' => $name_singular . " #1"));
insert($table_name, array($table_prefix . '_name' => $name_singular . " #2"));
// Add controller from template (substituting module for controller's name)
$content = file_get_contents('system/scaffolding/controller_template.php');
$content = $this->replace_preserving_case("modules", $name_plural, $content);
$content = $this->replace_preserving_case("module", $name_singular, $content);
$controller_file = "controllers/{$name_plural}.php";
$fp = fopen($controller_file, "wb");
fwrite($fp, $content);
fclose($fp);
chmod($controller_file, 0666);
/** Add views **/
$views = ['index', 'view', 'edit'];
// Create views directory
$dirname = "views/{$name_plural}";
if (!is_dir($dirname)) {
mkdir($dirname, 0755);
}
// Create each view
foreach ($views as $view) {
$content = file_get_contents("system/scaffolding/view_{$view}_template.php");
$content = $this->replace_preserving_case("modules", $name_plural, $content);
$content = $this->replace_preserving_case("module", $name_singular, $content);
$view_file = "views/{$name_plural}/{$name_plural}_{$view}.php";
$fp = fopen($view_file, "wb");
fwrite($fp, $content);
fclose($fp);
chmod($view_file, 0666);
}
// Add files to git
exec("git add controllers/*");
exec("git add views/*");
// Prevent git running under developer's user account having permission issues when commiting this file
exec("chmod -R a+rwX *");
echo '<div class="alert alert-success">' . 'The module <a href="' . BASE_URL . $table_name . '">' . $table_name . '</a> was created.</div>';
}
}
开发者ID:DataKeyt,项目名称:meliss,代码行数:57,代码来源:halo.php
示例17: insert_ads_info
function insert_ads_info($client_name, $company_name, $link, $file_ext)
{
$q = insert('ads', array('admin_no', 'client_name', 'company_name', 'link', 'ext', 'date_uploaded'), array(1, $client_name, $company_name, $link, $file_ext, "2012-01-01"), 'ano');
if ($q) {
return true;
} else {
return false;
}
}
开发者ID:jesus143,项目名称:fs-dev,代码行数:9,代码来源:img_save.php
示例18: insert_vote
function insert_vote($openId, $workId)
{
$dataArr = array();
$dataArr['openId'] = $openId;
$dataArr['workId'] = $workId;
$dataArr["creatTime"] = date("Y-m-d H:i:s");
$bRusult = insert(LOG_TABLE, $dataArr);
return $bRusult ? true : false;
}
开发者ID:Flyu,项目名称:voting4wechat,代码行数:9,代码来源:api.function.php
示例19: addnav
function addnav(){
$arr=$_POST;
if(insert("dw_nav",$arr)){
echo "添加成功,你可以<a href='nav_config.php'>马上查看</a>";
}
else{
echo "添加失败<a href='='nav_config.php'>查看分类</a";
}
}
开发者ID:knight-zhou,项目名称:PHP-HTML,代码行数:9,代码来源:nav.fun.php
示例20: delete
protected static function delete()
{
global $current_user;
if ($current_user['is_admin']) {
insert('DELETE FROM user WHERE id=' . $_POST['id']);
} else {
self::$failure = 'you are not admin';
}
}
开发者ID:hillam,项目名称:bookmarks,代码行数:9,代码来源:users.php
注:本文中的insert函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论