<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>https://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>https://jackxiang.com/post//</link>
<title><![CDATA[php pdo  $pdo-lastInsertId()取得插入ID]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Wed, 22 Oct 2008 09:33:30 +0000</pubDate> 
<guid>https://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	<div class="code"><br/>&lt;?php<br/>/**<br/> * 倒库程序雏形，将space的数据分析后导入到现有数据库中<br/> *<br/> */<br/>class import_export<br/>&#123;<br/>&nbsp;&nbsp;private&nbsp;&nbsp;$dsn=&quot;&quot;;<br/>&nbsp;&nbsp;private&nbsp;&nbsp;$user=&quot;&quot;;<br/>&nbsp;&nbsp;private&nbsp;&nbsp;$password=&quot;&quot;;<br/>&nbsp;&nbsp;private&nbsp;&nbsp;$pdo=&quot;&quot;;<br/>&nbsp;&nbsp;<br/>&nbsp;&nbsp;public function import_export($dsn,$user,$password)<br/>&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;dsn = $dsn;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;user = $user;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;password = $password;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;pdo = new PDO($this-&gt;dsn, $this-&gt;user, $this-&gt;password);<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;<br/>&nbsp;&nbsp;public function fetch_result($query)<br/>&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$rs = $this-&gt;pdo-&gt;query($query);<br/>&nbsp;&nbsp;&nbsp;&nbsp;$result_arr = $rs-&gt;fetchAll();<br/>&nbsp;&nbsp;&nbsp;&nbsp;return $result_arr;<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;<br/>&nbsp;&nbsp;public function insert($insert_sql)<br/>&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$count = $this-&gt;pdo-&gt;exec($insert_sql);<br/>&nbsp;&nbsp;&nbsp;&nbsp;if($count)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return true;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;else&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return false;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;<br/>&nbsp;&nbsp;public function get_pdo_obj()<br/>&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;return $this-&gt;db;<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;<br/>&nbsp;&nbsp;public function lastInsertId()<br/>&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;return $this-&gt;pdo-&gt;lastInsertId();<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&#125;<br/>&#125;<br/>?&gt;<br/>&lt;?php<br/>$time_begin = time();<br/>$conf_array = array(&quot;db_host&quot;=&gt;&quot;localhost&quot;,&quot;port&quot;=&gt;&quot;3306&quot;,&quot;dbname&quot;=&gt;&quot;public&quot;,&quot;user&quot;=&gt;&quot;root&quot;,&quot;password&quot;=&gt;&quot;&quot;);<br/>$dsn = &quot;mysql:host=&#123;$conf_array&#91;&#039;db_host&#039;&#93;&#125;;port=&#123;$conf_array&#91;&#039;port&#039;&#93;&#125;;dbname=&#123;$conf_array&#91;&#039;dbname&#039;&#93;&#125;&quot;;<br/>$user = $conf_array&#91;&#039;user&#039;&#93;;<br/>$password = $conf_array&#91;&#039;password&#039;&#93;;<br/>$pdo = new import_export($dsn,$user,$password);<br/>for($i=1;$i&lt;100000000000;$i++)<br/>&#123;<br/>&nbsp;&nbsp;$time_end = time();<br/>&nbsp;&nbsp;if($time_end - $time_begin &gt;= 60)<br/>&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;exit;<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;$insert_sql = &quot;INSERT INTO `information` ( `infoid` , `group` , `productid` , `connection` , `invitetype` , `content` , `addition` ) VALUES (NULL , &#039;1&#039;, &#039;2&#039;, &#039;2&#039;, &#039;1&#039;, &#039;的的的的的的的的的的的的的的的的的的&#039;, &#039;的的的的的的的的的的的的的的的的的的的的的的的的&#039;);&quot;; //插入数据库的sql语句<br/>&nbsp;&nbsp;$import_export2 = $pdo-&gt;insert($insert_sql);<br/>&nbsp;&nbsp;$insert_id = $pdo-&gt;lastInsertId();<br/>&nbsp;&nbsp;$insert_sql2 = &quot;INSERT INTO `relation` ( `id` , `owneruid` , `otheruid` , `type` , `status` , `infoid` , `ctime` , `uniq_key` ) VALUES (NULL , &#039;1&#039;, &#039;2&#039;, &#039;1&#039;, &#039;11&#039;, $insert_id, &#039;2008-10-02 20:30:21&#039;, &#039;45646546456456456456456456456456465&#039;);&quot;; //插入数据库的sql语句<br/>&nbsp;&nbsp;$import_export2 = $pdo-&gt;insert($insert_sql2);<br/>&nbsp;&nbsp;<br/>&#125;<br/>?&gt;<br/><br/></div><br/><br/><br/><div class="code">&lt;?php<br/>$G_MDB_AUTH&#91;&#039;dns&#039;&#93; = &quot;mysql:host=10.210.71.81;dbname=public;port=3501;&quot;;<br/>$G_MDB_AUTH&#91;&#039;user&#039;&#93; = &#039;public&#039;;<br/>$G_MDB_AUTH&#91;&#039;pass&#039;&#93; = &#039;public123&#039;;<br/><br/>$date_time=time();<br/>$pdo = new PDO($G_MDB_AUTH&#91;&#039;dns&#039;&#93;,$G_MDB_AUTH&#91;&#039;user&#039;&#93;,$G_MDB_AUTH&#91;&#039;pass&#039;&#93;);<br/>$info = &quot;当 PHP 解析一个文件时，会寻找开始和结束标记，标记告诉 PHP 开始和停止解释其中的代码。此种方式的解析可以使 PHP 嵌入到各种不同的文档中，凡是在一对开始和结束标记之外的内容都会被 PHP 解析器忽略。大多数情况下 PHP 都是嵌入在 HTML 文档中的，如下例所示当 PHP 解析一个文件时，会寻找开始和结束标记，标记告诉 PHP 开始和停止解释其中的代码。此种方式的解析可以使 PHP 嵌入到各种当 PHP 解析一个文件时，&quot;;<br/>$sql = &quot;INSERT INTO `information` (`group` ,`productid` ,`connection` ,`invitetype` ,`content` ,`addition`) VALUES (?,&#039;12341234123412341234123412341234&#039;, ?, ?, ?, &#039;&#039;)&quot;;<br/>$sql2 = &quot;INSERT INTO `relation` (owneruid ,otheruid ,type ,status ,infoid ,ctime,uniq_key) VALUES (1, 2, 1, 1, ?,&nbsp;&nbsp;&#039;2008-12-21&#039;, &#039;12341234123412341234123412341234&#039;)&quot;;<br/><br/><br/><br/>$sj = date(&#039;Y-m-d H:i:s&#039;);<br/>$para = intval($argv&#91;1&#93;)*1000000;<br/>$para = $argv&#91;1&#93;;<br/>for($i=0;$i&lt;1000000;$i++)&#123;<br/>&nbsp;&nbsp;$date_time2 = time();<br/>&nbsp;&nbsp;if($date_time2-$date_time &gt;= 60)<br/>&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;exit;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&#125;<br/><br/>&nbsp;&nbsp;$stmt = $pdo-&gt;prepare($sql);<br/>&nbsp;&nbsp;$stmt-&gt;bindParam(1, $group);<br/>&nbsp;&nbsp;$stmt-&gt;bindParam(2, $connection);<br/>&nbsp;&nbsp;$stmt-&gt;bindParam(3, $invitetype);<br/>&nbsp;&nbsp;$stmt-&gt;bindParam(4, $content);<br/><br/>&nbsp;&nbsp;$group = 1; <br/>&nbsp;&nbsp;$connection = 2;<br/>&nbsp;&nbsp;$invitetype = 3;<br/>&nbsp;&nbsp;$content = 2;<br/>&nbsp;&nbsp;$stmt-&gt;execute();<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;$stmt2 = $pdo-&gt;prepare($sql2);<br/>&nbsp;&nbsp;//echo $pdo-&gt;lastInsertId().&quot;&#92;n&quot;;<br/>&nbsp;&nbsp;$stmt2-&gt;bindParam(1, $pdo-&gt;lastInsertId());<br/>&nbsp;&nbsp;$stmt2-&gt;execute();<br/><br/>&#125;</div><br/>
]]>
</description>
</item><item>
<link>https://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] php pdo  $pdo-lastInsertId()取得插入ID]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>