您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
webman-查詢構造器-插入
发布时间:2022-02-06 19:06:42编辑:雪饮阅读()
實例:
public function index(Request $request)
{
ini_set('memory_limit','4096M');
$row=(Array)Db::table('ecms_news')->selectRaw("count(*) num")->first();
$count=$row["num"];
//單條插入
$data=(Array)Db::table('ecms_news')->first();
unset($data["id"]);
$signleRes=Db::table('ecms_news')->insert($data);
//多條插入
$multiData=[];
$multiData[]=$data;
$multiData[]=$data;
$multiRes=Db::table('ecms_news')->insert($multiData);
$row=(Array)Db::table('ecms_news')->selectRaw("count(*) num")->first();
$afterCount=$row["num"];
$all=compact("count","signleRes","multiRes","afterCount");
var_dump($all);
return response("ok");
}
構造的sql:
insert into `phome_ecms_news` (`classid`, `ttid`, `onclick`, `plnum`, `totaldown`, `newspath`, `filename`, `userid`, `username`, `firsttitle`, `isgood`, `ispic`, `istop`, `isqf`, `ismember`, `isurl`, `truetime`, `lastdotime`, `havehtml`, `groupid`, `userfen`, `titlefont`, `titleurl`, `stb`, `fstb`, `restb`, `keyboard`, `title`, `newstime`, `titlepic`, `ftitle`, `smalltext`, `diggtop`, `push_weixin_material`, `push_baidu_last_time`, `push_weixin_material_last_time`) values (83, 0, 62, 0, 0, '', '114', 1, '雪饮', 0, 0, 1, 0, 0, 0, 0, 1423920308, 1425445123, 1, 0, 0, '', '/manshenghuo/xinshang/114.html', 1, 1, 1, '', '一个程序员的爱情故事', 1423920134, '/d/file/manshenghuo/xinshang/2015-02-14/01e4753ff30b6bf0838b6e55cbe88c39.jpg', '程序员,爱情,雪饮个人博客', ' //一个程序员的爱情故事 public class MyLoveStory { public static void Main(string[] args) { //The ForeStory int result', 0, 0, 0, 0)
insert into `phome_ecms_news` (`classid`, `diggtop`, `filename`, `firsttitle`, `fstb`, `ftitle`, `groupid`, `havehtml`, `isgood`, `ismember`, `ispic`, `isqf`, `istop`, `isurl`, `keyboard`, `lastdotime`, `newspath`, `newstime`, `onclick`, `plnum`, `push_baidu_last_time`, `push_weixin_material`, `push_weixin_material_last_time`, `restb`, `smalltext`, `stb`, `title`, `titlefont`, `titlepic`, `titleurl`, `totaldown`, `truetime`, `ttid`, `userfen`, `userid`, `username`) values (83, 0, '114', 0, 1, '程序员,爱情,雪饮个人博客', 0, 1, 0, 0, 1, 0, 0, 0, '', 1425445123, '', 1423920134, 62, 0, 0, 0, 0, 1, ' //一个程序员的爱情故事 public class MyLoveStory { public static void Main(string[] args) { //The ForeStory int result', 1, '一个程序员的爱情故事', '', '/d/file/manshenghuo/xinshang/2015-02-14/01e4753ff30b6bf0838b6e55cbe88c39.jpg', '/manshenghuo/xinshang/114.html', 0, 1423920308, 0, 0, 1, '雪饮'), (83, 0, '114', 0, 1, '程序员,爱情,雪饮个人博客', 0, 1, 0, 0, 1, 0, 0, 0, '', 1425445123, '', 1423920134, 62, 0, 0, 0, 0, 1, ' //一个程序员的爱情故事 public class MyLoveStory { public static void Main(string[] args) { //The ForeStory int result', 1, '一个程序员的爱情故事', '', '/d/file/manshenghuo/xinshang/2015-02-14/01e4753ff30b6bf0838b6e55cbe88c39.jpg', '/manshenghuo/xinshang/114.html', 0, 1423920308, 0, 0, 1, '雪饮')
實例被訪問時:
[root@localhost webman]# /usr/local/php734/bin/php -c /usr/local/php734/lib/php.ini start.php start
Workerman[start.php] start in DEBUG mode
----------------------------------------- WORKERMAN -----------------------------------------
Workerman version:4.0.26 PHP version:7.3.4
------------------------------------------ WORKERS ------------------------------------------
proto user worker listen processes status
tcp root webman http://0.0.0.0:8787 4 [OK]
tcp root monitor none 1 [OK]
---------------------------------------------------------------------------------------------
Press Ctrl+C to stop. Start success.
訪問了全局中間件!
array(4) {
["count"]=>
int(2598)
["signleRes"]=>
bool(true)
["multiRes"]=>
bool(true)
["afterCount"]=>
int(2601)
}
关键字词:webman,查詢構造器,插入
相关文章
- webman-查詢構造器-offset,limit的用法
- webman-查詢構造器-groupBy與having的用法
- webman-查詢構造器-orderBy,随机排序的用法
- webman-查詢構造器-参数分组,whereExists的用法
- webman-查詢構造器-orWhereColumn 的用法
- webman-查詢構造器-whereColumn 的用法
- webman-查詢構造器-whereDate,whereMonth,whereDay,wh
- webman-查詢構造器-whereNull ,whereNotNull,orWhereN
- webman-查詢構造器-whereIn、whereNotIn、orWhereIn
- webman-查詢構造器-whereBetween 與 orWhereBetween