本文整理汇总了PHP中medoo::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP medoo::insert方法的具体用法?PHP medoo::insert怎么用?PHP medoo::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类medoo
的用法示例。
在下文中一共展示了medoo::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: header
<?php
session_start();
// error_reporting(null);
if (!isset($_SESSION['uid'])) {
header("Location: login.php");
exit;
}
date_default_timezone_set('Asia/Shanghai');
include "./medoo.min.php";
$database = new medoo();
if (isset($_GET['qid']) && isset($_POST['reply'])) {
$name = $database->select("user", "name", array("id" => $_SESSION['uid']));
$database->insert("answer", array("qid" => $_GET['qid'], "name" => $name[0], "content" => $_POST['reply']));
$database->update("question", array("isanswer" => 1), array("id" => $_GET['qid']));
header("Location: my.php");
}
示例2: importData
/**
* 导入数据到 wd_120answer_temp 中
* @author gaoqing
* 2015年11月9日
* @param array $initAskArr 初始要导入的问答信息集
* @param int $preInsertCount 每次插入的条数
* @param medoo $connection 连接数据库对象
* @param int $sleepSeconds 休眠的秒数
* @return int $importCount 成功导入的信息数
*/
function importData($initAskArr, $preInsertCount, $connection, $sleepSeconds)
{
$importCount = 0;
$data = array("isimport" => 1);
$insertArr = array();
$updateIDArr = array();
$initAskArrCount = count($initAskArr);
foreach ($initAskArr as $key => $initAsk) {
if ($key % 100 == 0) {
sleep($sleepSeconds);
}
$insertArr[] = getInserArr($initAsk);
$updateIDArr[] = $initAsk['id'];
if ($key % $preInsertCount == $preInsertCount - 1 || $key == $initAskArrCount - 1) {
//将 $insertArr 数组集,插入到 wd_fhanswer_temp 中
if (!empty($insertArr)) {
//插入到 wd_120answer_temp 中
$idArr = $connection->insert(IMPORT_TABLE, $insertArr);
$importCount += count($insertArr);
$insertArr = array();
//更新 wd_120answer_keshi 中的信息
$where = array('id' => $updateIDArr);
$connection->update(SELECT_TABLE, $data, $where);
$updateIDArr = array();
}
}
}
return $importCount;
}
示例3: saveNew
/**
* Add new record to to DB
* @param array $args
* @param bool $extCall
* @return int|string id of new record
* @throws FatalError
* @throws \Exception
*/
public function saveNew($args, $extCall = false)
{
$this->gp->checkAccess(__FUNCTION__, $extCall);
$parsed_arg = $this->checkArguments($args);
$parsed_arg = $this->parseJson($parsed_arg, true);
if (EMA_DEBUG && EMA_LOG_SQL_QUERIES) {
$this->logInsertQuery($this->dbTable, $parsed_arg);
}
$dbData = $this->dbConnection->insert($this->dbTable, $parsed_arg);
if (is_numeric($dbData) === true and $dbData > 0) {
if ($this->isImplement("FileManage") && !empty($_FILES)) {
$uploadedData = $this->saveUploadedFile($dbData);
$parsed_arg = $this->parseJson($parsed_arg);
/** @var array $parsed_arg */
$parsed_arg['id'] = $dbData;
$parsed_arg = array_replace_recursive($parsed_arg, $uploadedData);
$this->save($parsed_arg);
}
if ($this->isImplement("Sitemap")) {
$this->generateSitemap();
}
if ($this->isImplement("RssFeed")) {
$this->rssFeedUpdate();
}
return $dbData;
} else {
$this->throwMysqlError();
}
}
示例4: insert
/**
* @param string $table
* @param array $datas
* @return bool|int
*/
public function insert($table, $datas)
{
$n = 0;
if (isset($datas[0])) {
foreach ($datas as $data) {
parent::insert($table, $data);
$this->lastSql = $this->last_query();
$this->lastError = $this->error();
if ($this->lastError[0] == '00000') {
$n += 1;
}
}
} else {
parent::insert($table, $datas);
$this->lastSql = $this->last_query();
$this->lastError = $this->error();
if ($this->lastError[0] == '00000') {
$n = 1;
}
}
return $n;
}
示例5: getHtml
ini_set('display_errors', 'ON');
error_reporting(E_ALL);
header("Content-type:text/html;charset=utf-8");
defined('ROOT_PATH') or define('ROOT_PATH', dirname(__FILE__));
include ROOT_PATH . '/../lib/medoo.php';
include ROOT_PATH . '/../lib/Curl.php';
$db = new medoo(array('database_type' => 'mysql', 'database_name' => 'fayuan', 'server' => 'localhost', 'username' => 'root', 'password' => '123456', 'port' => 3306, 'charset' => 'utf8', 'option' => array(PDO::ATTR_CASE => PDO::CASE_NATURAL)));
$curl = new Curl();
$id = 2250;
while ($id <= 1239000) {
$url = "http://shixin.court.gov.cn/detail?id={$id}";
$resArr = getHtml($url);
echo "{$id}\r\n";
if (is_array($resArr) && !empty($resArr)) {
//判断数据是否存在
print_r($resArr);
$i = $db->insert('shixin', $resArr);
if ($i <= 0) {
print_r($db->error());
die;
}
}
$id++;
}
function getHtml($url)
{
global $curl;
$curl->setUrl($url);
$html = $curl->run();
return json_decode($html, true);
}
示例6: medoo
<?php
session_start();
error_reporting(null);
date_default_timezone_set('Asia/Shanghai');
include "./medoo.min.php";
$database = new medoo();
if (isset($_POST['uid']) && isset($_POST['qid'])) {
$database->insert("who", array("qid" => $_POST['qid'], "uid" => $_POST['uid']));
$database->update("question", array("isreply" => 1), array("id" => $_POST['qid']));
header("Location: manager.php");
}
示例7: getGameData
if ($method == "login") {
$pw = sha1($_POST['password']);
$uname = $_POST['user_name'];
$data = $database->select("users", ["password", "user_name", "user_id"], ["user_name" => $uname]);
if ($data[0]['password'] == $pw) {
$data[0]['password'] = "";
print json_encode($data);
$_SESSION['user_id'] = $data[0]['user_id'];
} else {
print json_encode([]);
}
} else {
if ($method == "create") {
$pw = sha1($_POST['password']);
$uname = $_POST['user_name'];
$data = $database->insert("users", ["user_name" => $uname, "password" => $pw]);
$resp = ["user_name" => $uname, "user_id" => $data];
print json_encode($resp);
} else {
if ($method == "game_list") {
$data = $database->select("game", "*", []);
print json_encode($data);
} else {
if ($method == "game_view") {
$game_id = $_GET['game_id'];
$result = getGameData($database, $game_id, $user_id);
print json_encode($result);
} else {
if ($method == "create_game") {
$game_name = $_POST['game_name'];
$data = ["game_name" => $game_name, "game_type" => "sh", "game_status" => "pending", "owner_id" => $user_id];
示例8: array
if (count($is_phone_exists) == 0) {
if (isset($_FILES['image'])) {
$errors = array();
$file_name = $_FILES['image']['name'];
$file_size = $_FILES['image']['size'];
$file_tmp = $_FILES['image']['tmp_name'];
$file_type = $_FILES['image']['type'];
$file_ext = strtolower(end(explode('.', $_FILES['image']['name'])));
$expensions = array("jpeg", "jpg", "png");
if (in_array($file_ext, $expensions) === false) {
$errors[] = "extension not allowed, please choose a JPEG or PNG file.";
}
if ($file_size > 2097152) {
$errors[] = 'File size must be excately 2 MB';
}
if (empty($errors) == true) {
move_uploaded_file($file_tmp, "profile_pic/" . $phone . $file_ext);
$image_path = "profile_pic/" . $phone . $file_ext;
echo "Success";
} else {
print_r($errors);
}
}
$database->insert("krishok", ["full_name" => $fullname, "district" => $district, "address" => $address, "phone" => $phone, "password" => $pass, "profile_pic_path" => $image_path]);
} else {
echo 'Already Registered';
}
} else {
echo 'Something wrong';
}
}
示例9: function
$app->notfound();
}
});
$app->get("/secindex", function () use($app) {
try {
$app->render("secindex.html");
} catch (Exception $e) {
$app->notfound();
}
});
$app->get("/thirdindex/:uid/:type", function ($uid, $type) use($app, $databases) {
try {
$ftype = $app->getCookie("ctype");
$stype = $app->getCookie("csectype");
$ttype = $app->getCookie("csort");
$f = $databases->insert("history", array("uuid" => $uid, "ftype" => $ftype, "stype" => $stype, "ttype" => $ttype));
if ($type > 2) {
$datas = $databases->select("user", "expire", array("uuid" => $uid, "ORDER" => array("id DESC", "time DESC")));
if (count($datas) > 0) {
$now = time();
if ($now > $datas[0]) {
$app->redirect("../../buy");
} else {
$app->render("thirdindex.html");
}
} else {
$app->redirect("../../buy");
}
} else {
$app->render("thirdindex.html");
}
示例10: medoo
<?php
require_once 'meedoo.php';
require_once 'config.php';
$database = new medoo();
$mealID = $_POST["mealID"];
$name = $_POST["name"];
$type = $_POST["type"];
$ingredients = $_POST["ingredients"];
$instructions = $_POST["instructions"];
$user = $_POST["user"];
// LATER --> double check if meal exists first
echo 'MEALID:::: ' . $mealID;
//if not...
$add = $database->insert('meals', ['mealID' => $mealID, 'name' => $name, 'status' => 'active', 'type' => $type, 'ingredients' => $ingredients, 'instructions' => $instructions, 'user' => $user]);
if ($add) {
echo 'good';
} else {
echo 'bad';
}
示例11: medoo
* 连接数据库
*/
echo "_______________\n";
$database = new medoo('meetingmanage');
print_r($database->info());
/*
* 查看错误信息
*/
echo "_______________\n";
$database->select("bccount", array("user_name", "email"), array("user_id[<]" => 20));
var_dump($database->error());
/*
* 查看上一条query
*/
echo "_______________\n";
$last_user_id = $database->insert("test", array("user" => "fooa", "email" => "foo@bar.com", "id" => 25, "pwd" => "smart", "name" => array("en", "fr", "jp", "cn")));
echo $database->last_query();
/*
* quote函数,单引号
*/
echo "_______________\n";
$data = "Medoo";
echo "we love" . $data . "\n";
echo "we love" . $database->quote($data);
/*
* query()函数
*/
echo "_______________\n";
$data1 = $database->query("select * from test")->fetchAll();
print_r($data1);
/*
示例12: medoo
<?php
session_start();
error_reporting(null);
date_default_timezone_set('Asia/Shanghai');
include "./medoo.min.php";
$database = new medoo();
if (isset($_POST['title'])) {
$database->insert("question", array("name" => $_POST['user'], "title" => $_POST['title'], "content" => $_POST['des'], "call" => $_POST['call'], "isreply" => 0, "isanswer" => 0));
$result = array();
$result['status'] = "success";
echo json_encode($result);
} else {
$result = array();
$result['status'] = "wrong";
echo json_encode($result);
}
示例13: foreach
$datas = $database->select("xp_posts", ["[>]wp_posts" => ["post_name" => "post_name"]], ["xp_posts.id(id)", "xp_posts.post_title(post_title)", "xp_posts.post_name(post_name)", "wp_posts.id(idn)", "wp_posts.post_title(post_titlen)", "wp_posts.post_name(post_namen)"], ["AND" => ["xp_posts.post_status" => 'publish', "xp_posts.post_parent" => '0', "xp_posts.post_type" => 'post']]);
foreach ($datas as $data) {
//echo "ID:" . $data["id"] . "IDnew:".$data["idn"]." - <br/>";
$i++;
if (!empty($data["idn"])) {
// Search in xp_postmeta record with ID of Featured image
$metas = $database->select("xp_postmeta", ["post_id", "meta_key", "meta_value"], ["AND" => ["post_id" => $data["id"], "meta_key" => "_thumbnail_id"]]);
//echo $metas['0']["post_id"]."---".$data["idn"]."---".$metas['0']["meta_value"]."<br>";
// Posts can be without featured image, so we make check
if (!empty($metas['0']["meta_value"])) {
// Select from old table all Featured Images information
$images = $database->select("xp_posts", ["id", "post_title", "post_name", "post_mime_type", "guid"], ["AND" => ["post_status" => 'inherit', "post_parent" => $data["id"], "post_type" => 'attachment', "id" => $metas['0']['meta_value']]], ["ORDER" => "xp_posts.id DESC", "LIMIT" => 1]);
foreach ($images as $img) {
//echo "ID:" . $img["id"] . "IDnew:".$img["guid"]." - <br/>";
// Insert record with Images information to wp_post
$last_user_id = $database->insert("wp_posts", ["post_author" => "1", "post_date" => "2015-12-15 11:13:52", "post_date_gmt" => "2015-12-15 08:13:52", "post_title" => $img["post_title"], "post_status" => "inherit", "comment_status" => "open", "ping_status" => "open", "post_name" => $img["post_name"], "post_modified" => "2016-01-25 01:03:55", "post_modified_gmt" => "2016-01-25 01:03:55", "post_parent" => $data["idn"], "guid" => $img["guid"], "menu_order" => "0", "post_type" => "attachment", "post_mime_type" => $img["post_mime_type"], "comment_count" => "0"]);
////// select meta information from xp_postmeta
$meta_all = $database->select("xp_postmeta", ["post_id", "meta_key", "meta_value"], ["post_id" => $metas['0']['meta_value']]);
////// ###select from wp_postmeta /////
foreach ($meta_all as $meta) {
//echo "ID:" . $meta["post_id"] . "IDnew:".$meta["meta_value"]." - <br/>";
// Insert meta information to wp_postmeta
$last_id = $database->insert("wp_postmeta", ["post_id" => $last_user_id, "meta_key" => $meta["meta_key"], "meta_value" => $meta["meta_value"]]);
}
// Insert meta information to wp_postmeta
$last_id = $database->insert("wp_postmeta", ["post_id" => $data["idn"], "meta_key" => "_thumbnail_id", "meta_value" => $last_user_id]);
}
// Delete incorect records from wp_postmeta
$meta_del = $database->select("wp_postmeta", ["meta_id"], ["AND" => ["post_id" => $data["idn"], "meta_key" => "_thumbnail_id", "meta_value" => $metas['0']['meta_value']]]);
if (!empty($meta_del['0']['meta_id'])) {
$database->delete("wp_postmeta", ["meta_id" => $meta_del['0']['meta_id']]);
示例14: medoo
<?php
require_once 'medoo.php';
//configuro database
$database = new medoo(['database_type' => 'mysql', 'database_name' => 'test', 'server' => 'localhost', 'username' => 'root', 'charset' => 'utf8']);
//qui processerò i parametri provenienti da ajax
$comunePartenzaSelezionato = $_POST['comunePartenza'];
$comuneArrivoSelezionato = $_POST['comuneArrivo'];
$giornoPartenza = $_POST['giorno'];
$spazioDisponibileSelezionato = $_POST['spazio'];
$nomeAnnuncioViaggio = $_POST['nomeViaggio'];
$mailAnnuncioViaggio = $_POST['mailViaggio'];
$phoneAnnuncioViaggio = $_POST['phoneViaggio'];
//qui inserirò i dati nel db
$database->insert('viaggi', ['ksCodIstatComunePartenza' => $comunePartenzaSelezionato, 'ksCodIstatComuneArrivo' => $comuneArrivoSelezionato, 'giornoPartenza' => $giornoPartenza, 'spazioDisponibile' => $spazioDisponibileSelezionato, 'nome' => $nomeAnnuncioViaggio, 'mail' => $mailAnnuncioViaggio, 'phone' => $phoneAnnuncioViaggio]);
示例15: medoo
if (file_exists("assert/docs/" . $_FILES["file"]["name"])) {
echo $_FILES["file"]["name"] . " already exists. ";
} else {
$name = $_FILES['file']['name'];
$path = "./assert/docs/" . $_FILES["file"]["name"];
move_uploaded_file($_FILES["file"]["tmp_name"], "assert/docs/" . $_FILES["file"]["name"]);
}
}
//}
//else{
// echo "文件不合法!";
//}
$type = $_POST['type'];
$db = new medoo('meetingmanage');
$did = $db->max('docspace', 'DOC_ID');
$did += 1;
$db->insert('docspace', array('DOC_ID' => $did, 'MEETING_ID' => $mid, 'TYPE' => $type, 'DATE' => date("Y/m/d"), 'PATH' => $path, 'NAME' => $name));
?>
<html>
<head>
</head>
<body style="background:#ffffff">
<script type="text/javascript">
alert('文件上传成功!')
</script>
<meta http-equiv="refresh" content="100;url='./mymeeting.php'"/>
</body>
</html>