<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>爱周末 &#187; php</title>
	<atom:link href="http://zhoumo123.cn/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://zhoumo123.cn</link>
	<description>知识分享，共同进步。zhoumo123.cn</description>
	<lastBuildDate>Thu, 07 Nov 2019 05:53:49 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.1</generator>
	<item>
		<title>php 判断数组键值是否存在 array_key_exists() 与 isset()</title>
		<link>http://zhoumo123.cn/php/3446.html</link>
		<comments>http://zhoumo123.cn/php/3446.html#comments</comments>
		<pubDate>Tue, 22 Dec 2015 01:47:35 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3446</guid>
		<description><![CDATA[php使用array_key_exists() 与 isset() 来判断数组中的某个键值是否存在。一起看下使用方法： array_key_exists (PHP 4 &#62;= 4.0.7, PHP 5) array_key_exists — 检查给定的键名或索引是否存在于数组中 说明 bool array_key_exists ( mixed $key , array $search ) array_key_exists() 在给定的 key 存在于数组中时返回 TRUE。key 可以是任何能作为数组索引的值。array_key_exists() 也可用于对象。 Example #1 ar ...  <a href="http://zhoumo123.cn/php/3446.html">  阅读全文 </a>]]></description>
				<content:encoded><![CDATA[<p>php使用array_key_exists() 与 isset() 来判断数组中的某个键值是否存在。一起看下使用方法：</p>
<p><strong>array_key_exists</strong></p>
<p>(PHP 4 &gt;= 4.0.7, PHP 5)</p>
<p><strong>array_key_exists — 检查给定的键名或索引是否存在于数组中</strong><br />
说明</p>
<p>bool array_key_exists ( mixed $key , array $search )</p>
<p>array_key_exists() 在给定的 key 存在于数组中时返回 TRUE。key 可以是任何能作为数组索引的值。array_key_exists() 也可用于对象。<br />
<strong><em>Example #1 array_key_exists() 例子</em></strong><br />
<span style="color: #0000ff;">&lt;?php</span><br />
<span style="color: #0000ff;">$search_array = array(&#8216;first&#8217; =&gt; 1, &#8216;second&#8217; =&gt; 4);</span><br />
<span style="color: #0000ff;">if (array_key_exists(&#8216;first&#8217;, $search_array)) {</span><br />
<span style="color: #0000ff;"> echo &#8220;The &#8216;first&#8217; element is in the array&#8221;;</span><br />
<span style="color: #0000ff;">}</span><br />
<span style="color: #0000ff;">?&gt;</span></p>
<p>Note: 在 PHP 4.0.6 中本函数名为 key_exists()。<br />
<strong>Example #2 array_key_exists() 与 isset() 对比</strong><br />
<strong>isset() 对于数组中为 NULL 的值不会返回 TRUE，而 array_key_exists() 会。</strong><br />
<span style="color: #0000ff;">&lt;?php</span><br />
<span style="color: #0000ff;">$search_array = array(&#8216;first&#8217; =&gt; null, &#8216;second&#8217; =&gt; 4);</span></p>
<p><span style="color: #0000ff;">// returns false</span><br />
<span style="color: #0000ff;">isset($search_array[&#8216;first&#8217;]);</span></p>
<p><span style="color: #0000ff;">// returns true</span><br />
<span style="color: #0000ff;">array_key_exists(&#8216;first&#8217;, $search_array);</span><br />
<span style="color: #0000ff;">?&gt;</span></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/php/3446.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php mysql分页大数据查询方案大数据优化</title>
		<link>http://zhoumo123.cn/php/3356.html</link>
		<comments>http://zhoumo123.cn/php/3356.html#comments</comments>
		<pubDate>Tue, 13 Oct 2015 09:15:46 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php大数据]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3356</guid>
		<description><![CDATA[如何将分页SQL做到更优化，让MySQL执行的更快的方法。 一般的情况下，我们的分页SQL语句是这样的： SELECT * FROM table ORDER BY id LIMIT 1000,10; 以上SQL语句在原理上和在实际操作中是不会存在什么问题，但是当table表的数据量达到几十万以上的时候，上面的语句执行一遍，可能会要执行个十几秒的时间，并且当页数越靠后的话，执行的时间会越长，这个时候我们就需要找到一种更快的查询办法来替代这种操作了。 网上已经有很多优化的方法，基本都是这样的： SELECT * FROM table WHERE id &#62;= (SELECT id FROM t ...  <a href="http://zhoumo123.cn/php/3356.html">  阅读全文 </a>]]></description>
				<content:encoded><![CDATA[<p>如何将分页SQL做到更优化，让MySQL执行的更快的方法。</p>
<p>一般的情况下，我们的分页SQL语句是这样的：</p>
<p><strong>SELECT * FROM table ORDER BY id LIMIT 1000,10;</strong><br />
以上SQL语句在原理上和在实际操作中是不会存在什么问题，但是当table表的数据量达到几十万以上的时候，上面的语句执行一遍，可能会要执行个十几秒的时间，并且当页数越靠后的话，执行的时间会越长，这个时候我们就需要找到一种更快的查询办法来替代这种操作了。</p>
<p>网上已经有很多优化的方法，基本都是这样的：</p>
<p><strong> SELECT * FROM table WHERE id &gt;= (SELECT id FROM table LIMIT 1000000, 1) LIMIT 10;</strong><br />
以上SQL语句是一个不错的解决方法，分页查询的速度基本会保持在1秒之内，但据经验总结得出还有一种更好的办法，如下：</p>
<p><strong> SELECT * FROM table WHERE id BETWEEN 1000000 AND 1000010;</strong><br />
相比以上的解决办法，在速度上还会快了不少。</p>
<p>另外分享两个关于查询的技巧：</p>
<p>（1）如果需要查询 id 不是连续的一段，最佳的做法就是先找出 id ，然后用 in 查询：</p>
<p><strong> SELECT * FROM table WHERE id IN(10000, 100000, 1000000&#8230;);</strong><br />
（2）当查询字段一较长字符串的时候，表设计时要为该字段多加一个字段，如存储网址的字段，在需要查询该字段的时候，不要直接查询字符串，效率低下，应该查诡该字串的crc32或md5值。</p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/php/3356.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>b&gt;Warning:  Unknown: write failed: No space left on device (28) in Unknown on line </title>
		<link>http://zhoumo123.cn/php/3349.html</link>
		<comments>http://zhoumo123.cn/php/3349.html#comments</comments>
		<pubDate>Fri, 09 Oct 2015 02:09:01 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3349</guid>
		<description><![CDATA[php mysql  b&#62;Warning&#60;/b&#62;:  Unknown: write failed: No space left on device (28) in &#60;b&#62;Unknown&#60;/b&#62; on line  未知：写失败：设备没有剩余空间 。导致此错误的原因为设备剩余空间不足。 使用命令查看系统空间使用情况 root@Master:~# df -h 发现文件系统已使用100%，删除该文件系统下的无用文件即可。 &#160; &#160; &#160;]]></description>
				<content:encoded><![CDATA[<p>php mysql  b&gt;Warning&lt;/b&gt;:  Unknown: write failed: No space left on device (28) in &lt;b&gt;Unknown&lt;/b&gt; on line  未知：写失败：设备没有剩余空间 。导致此错误的原因为设备剩余空间不足。</p>
<p>使用命令查看系统空间使用情况</p>
<p>root@Master:~# df -h</p>
<p>发现文件系统已使用100%，删除该文件系统下的无用文件即可。</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/php/3349.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php时间格式化实现刚刚几分钟前小时前几天前</title>
		<link>http://zhoumo123.cn/php/3347.html</link>
		<comments>http://zhoumo123.cn/php/3347.html#comments</comments>
		<pubDate>Fri, 09 Oct 2015 01:36:28 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3347</guid>
		<description><![CDATA[微博 论坛 空间动态 微信各种社交动态都比较人性化，如发布的新鲜事时间都显示刚刚，几秒前，几分钟前，几小时前，几天前等等，下面看下PHP实现此功能的方法：]]></description>
				<content:encoded><![CDATA[<p>微博 论坛 空间动态 微信各种社交动态都比较人性化，如发布的新鲜事时间都显示刚刚，几秒前，几分钟前，几小时前，几天前等等，下面看下PHP实现此功能的方法：</p>
<pre class="brush: php; title: ; notranslate">
function wordTime($time) {
$time = (int) substr($time, 0, 10);
$int = time() - $time;
$str = '';
if ($int &amp;lt;= 2){
$str = sprintf('刚刚', $int);
}elseif ($int &amp;lt; 60){
$str = sprintf('%d秒前', $int);
}elseif ($int &amp;lt; 3600){
$str = sprintf('%d分钟前', floor($int / 60));
}elseif ($int &amp;lt; 86400){
$str = sprintf('%d小时前', floor($int / 3600));
}elseif ($int &amp;lt; 2592000){
$str = sprintf('%d天前', floor($int / 86400));
}else{
$str = date('Y-m-d H:i:s', $time);
}
return $str;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/php/3347.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP解析XML怎么通过属性查找到指定节点</title>
		<link>http://zhoumo123.cn/php/3321.html</link>
		<comments>http://zhoumo123.cn/php/3321.html#comments</comments>
		<pubDate>Mon, 21 Sep 2015 12:09:45 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3321</guid>
		<description><![CDATA[http://bbs.csdn.net/topics/330029501]]></description>
				<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
&lt;?php 
$doc = new DOMDocument();
//$doc-&gt;loadXML($xml);
$doc-&gt;load('book.xml'); 
$xpath = new DOMXPath($doc);
$query = &quot;//book[@id = '2']&quot;;
$entries = $xpath-&gt;query($query);
 
foreach ($entries as $entry) {
  echo &quot;节点 &quot;. $entry-&gt;nodeName;
  for($i=1; $i&lt;$entry-&gt;childNodes-&gt;length; $i+=2) {
    $testNode = $entry-&gt;childNodes-&gt;item($i);
    echo &quot;&lt;br /&gt;节点 &quot;.$testNode-&gt;nodeName;
    echo &quot;&lt;br /&gt;内容 &quot;.$testNode-&gt;nodeValue;
  }
}
?&gt;

</pre>
<p>http://bbs.csdn.net/topics/330029501</p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/php/3321.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php下载中文名称乱码问题多浏览器</title>
		<link>http://zhoumo123.cn/php/3319.html</link>
		<comments>http://zhoumo123.cn/php/3319.html#comments</comments>
		<pubDate>Mon, 21 Sep 2015 11:59:40 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3319</guid>
		<description><![CDATA[]]></description>
				<content:encoded><![CDATA[<p>       <?php </p>
<p>        $ua = $_SERVER["HTTP_USER_AGENT"]; </p>
<p>        $filename = "中文 文件名.txt";<br />
        $encoded_filename = urlencode($filename);<br />
        $encoded_filename = str_replace("+", "%20", $encoded_filename); </p>
<p>        header('Content-Type: application/octet-stream'); </p>
<p>        if (preg_match("/MSIE/", $ua)) {<br />
            header('Content-Disposition: attachment; filename="' . $encoded_filename . '"');<br />
        } else if (preg_match("/Firefox/", $ua)) {<br />
            header('Content-Disposition: attachment; filename*="utf8\'\'' . $filename . '"');<br />
        } else {<br />
            header('Content-Disposition: attachment; filename="' . $filename . '"');<br />
        } </p>
<p>        print 'ABC';<br />
        ?> </p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/php/3319.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP在IE浏览器下载文件乱码问题urlencode</title>
		<link>http://zhoumo123.cn/php/3317.html</link>
		<comments>http://zhoumo123.cn/php/3317.html#comments</comments>
		<pubDate>Mon, 21 Sep 2015 11:54:15 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[ie乱码]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3317</guid>
		<description><![CDATA[在IE下下载文件名出现乱码，是因为IE的原因，加上URL编码转换则可 如$name = urlencode($name); 那还需要针对IE 写下面的代码。 if(strpos($_SERVER[&#8220;HTTP_USER_AGENT&#8221;],&#8221;MSIE&#8221;)) { $name = urlencode($name); }]]></description>
				<content:encoded><![CDATA[<p>在IE下下载文件名出现乱码，是因为IE的原因，加上URL编码转换则可 如$name = urlencode($name); </p>
<p>那还需要针对IE 写下面的代码。<br />
if(strpos($_SERVER[&#8220;HTTP_USER_AGENT&#8221;],&#8221;MSIE&#8221;))<br />
{<br />
     $name = urlencode($name);<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/php/3317.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fatal error Maximum execution time of 30 seconds exceeded in 解决办法</title>
		<link>http://zhoumo123.cn/php/3307.html</link>
		<comments>http://zhoumo123.cn/php/3307.html#comments</comments>
		<pubDate>Mon, 14 Sep 2015 03:08:15 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[max_execution_time]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3307</guid>
		<description><![CDATA[php mysql 查询错误提示 ：Fatal error Maximum execution time of 30 seconds exceeded in &#8230; 的解决办法如下： 报错一：内存超限，具体报错语句忘了，简单说一下解决办法。 利用循环分批导入； 每个循环内部开始处使用sleep(5);语句，做延迟执行，防止服务器内存同一时间占用过多，里面数字据情况修改； 每个循环内部结束地方使用 ob_flush();刷新输出缓冲 flush();将当前为止程序的所有输出发送到用户的浏览器 两者必须同时使用来刷新输出缓冲 报错二：30秒运行超时的错误（Maximum execution ...  <a href="http://zhoumo123.cn/php/3307.html">  阅读全文 </a>]]></description>
				<content:encoded><![CDATA[<p>php mysql 查询错误提示 ：Fatal error Maximum execution time of 30 seconds exceeded in &#8230; 的解决办法如下：</p>
<p><strong>报错一：内存超限，具体报错语句忘了，简单说一下解决办法。</strong></p>
<p>利用循环分批导入；<br />
每个循环内部开始处使用sleep(5);语句，做延迟执行，防止服务器内存同一时间占用过多，里面数字据情况修改；<br />
每个循环内部结束地方使用 ob_flush();刷新输出缓冲<br />
flush();将当前为止程序的所有输出发送到用户的浏览器<br />
两者必须同时使用来刷新输出缓冲</p>
<p><strong>报错二：30秒运行超时的错误（Maximum execution time of 30 seconds exceeded）</strong><br />
解决办法：<br />
<strong>方法一，修改php.ini文件</strong><br />
max_execution_time = 30; Maximum execution time of each script, in seconds<br />
把它设置成需要的值就可以了。如果设置成0的话，就是永不过期。</p>
<p><strong>方法二，修改php执行文件</strong><br />
加上<br />
&lt;?<br />
set_time_limit(0);<br />
?&gt;</p>
<p>max_execution_time = 30; Maximum execution time of each script, in seconds<br />
把它设置成需要的值就可以了。如果设置成0的话，就是永不过期。</p>
<p>http://www.oschina.net/code/snippet_262017_19330</p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/php/3307.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux下安装配置php的mysql扩展</title>
		<link>http://zhoumo123.cn/php/3130.html</link>
		<comments>http://zhoumo123.cn/php/3130.html#comments</comments>
		<pubDate>Tue, 07 Jul 2015 15:04:39 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Mysql安装]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3130</guid>
		<description><![CDATA[安装PHP扩展，已经有太多人写过了，随便百度、谷歌一下，都可以查到各种PHP扩展的安装方法，今天我要写的是，在本地没有安装msyql应用的情况下，如何安装配置php的mysql扩展。首先说说为什么会有这种需求吧，今年可以说是VPS，即云主机开始最火的一年，很多小公司及个人，都大量购买云主机，云数据库等等。当我们的网站或者应用系统，使用RDS即阿里云的云数据库的时候，我们的云主机是不需要安装mysql的，因为我们要做分布式的系统架构，即每台服务器，只跑一个专门的应用。好了，说了这么多，下面我们来开始安装及配置PHP的mysql扩展吧。 一、下载或者上传php程序 wget http://cn2. ...  <a href="http://zhoumo123.cn/php/3130.html">  阅读全文 </a>]]></description>
				<content:encoded><![CDATA[<p>安装PHP扩展，已经有太多人写过了，随便百度、谷歌一下，都可以查到各种PHP扩展的安装方法，今天我要写的是，在本地没有安装msyql应用的情况下，如何安装配置php的mysql扩展。首先说说为什么会有这种需求吧，今年可以说是VPS，即云主机开始最火的一年，很多小公司及个人，都大量购买云主机，云数据库等等。当我们的网站或者应用系统，使用RDS即阿里云的云数据库的时候，我们的云主机是不需要安装mysql的，因为我们要做分布式的系统架构，即每台服务器，只跑一个专门的应用。好了，说了这么多，下面我们来开始安装及配置PHP的mysql扩展吧。</p>
<p><strong>一、下载或者上传php程序</strong><br />
wget http://cn2.php.net/distributions/php-5.5.26.tar.gz<br />
tar xzvf php-5.5.26.tar.gz<br />
cd php-5.5.26/ext/mysql/<br />
其实之前我们已经安装过PHP了，直接进入您源码存放的相应路径即可；</p>
<p><strong>二、环境准备</strong><br />
在正式安装前，我们需要先安装mysql的头文件，否则在配置(configure)的时候会报错；<br />
yum -y install mysql-devel</p>
<p>注：如果是64位的操作系统的话，还需要做个软链接，否则在配置(configure)的时候会报错找不到lib文件，即：<br />
ln -s /usr/lib64/mysql /usr/lib/mysql</p>
<p><strong>三、安装</strong><br />
由于我之前安装的php源码是放在root目录下，php安装到/usr/local/php 所以：<br />
cd /root/php-5.5.26/ext/mysql<br />
/usr/local/php/bin/phpize<br />
./configure &#8211;with-php-config=/usr/local/php/bin/php-config &#8211;with-mysql=/usr<br />
make<br />
make install</p>
<p><strong>四、配置</strong><br />
安装结束时，系统会提示您新安装的扩展文件存放的相关路径，我们只要编辑php.ini文件，加下如下内容即可：<br />
extension=mysql.so</p>
<p>最后重启 php-fpm及nginx或者apache服务生效即可；</p>
<p>http://63638790.blog.51cto.com/513514/1671677</p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/php/3130.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php插入数据后获取当前数据ID方法mysql_insert_id</title>
		<link>http://zhoumo123.cn/php/2595.html</link>
		<comments>http://zhoumo123.cn/php/2595.html#comments</comments>
		<pubDate>Wed, 01 Apr 2015 03:17:26 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=2595</guid>
		<description><![CDATA[在php项目中经常需要知道最新插入数据在数据库中的ID，方便一些操作，php如何获取当前的ID呢？推荐使用mysql_insert_id ，其他方法如下; 一、用以下语句： mysql_query(&#8220;select max(id) from t1&#8243;,$link); 使用这种方法时 我们得到得是 id最大的值 的确时最后一个 但当多链接线程时 这个最大的id并不一定是 我们插入的所以这个不利用域线程 二、用以下函数： msyql_insert_id(); 当系统执行完INSERT后，再执行SELECT时，可能已经被分发到了不同的后端服务器，如果你使用的编程语言是PHP的话， ...  <a href="http://zhoumo123.cn/php/2595.html">  阅读全文 </a>]]></description>
				<content:encoded><![CDATA[<p>在php项目中经常需要知道最新插入数据在数据库中的ID，方便一些操作，php如何获取当前的ID呢？推荐使用<strong>mysql_insert_id</strong> ，其他方法如下;</p>
<p><strong>一、用以下语句：</strong></p>
<p>mysql_query(&#8220;select max(id) from t1&#8243;,$link);</p>
<p>使用这种方法时 我们得到得是 id最大的值 的确时最后一个 但当多链接线程时<br />
这个最大的id并不一定是 我们插入的所以这个不利用域线程</p>
<p><strong>二、用以下函数：</strong></p>
<p><strong>msyql_insert_id();</strong></p>
<p>当系统执行完INSERT后，再执行SELECT时，可能已经被分发到了不同的后端服务器，如果你使用的编程语言是PHP的话，此时应该通过 mysql_insert_id()来得到最新插入的id，每次INSERT结束后，其实对应的autoincrement值就已经计算好返回给PHP 了，你无需再发出一次独立的查询，直接用mysql_insert_id()就可以了。</p>
<p>这个函数很好用 当我们插入一条语句时 它自动返回了 最后的id值。并且此函数 仅对当前链接有用 也就是说 它是多用户安全型的<br />
所以我们经常用此函数；</p>
<p>但此函数有一个问题 就是当id 为bigint 型时 就不在起作用了所以现在正在用此函数的请小心了不过 我们平时很少遇到这样的问题，所以可以不用管它。</p>
<p><strong>三、用以下查询</strong></p>
<p>msyql_query(&#8220;select last_insert_id()&#8221;);</p>
<p>last_insert_id() 是mysql 一个函数 也是 对当前链接起效<br />
此用法 解决了 mysql_insert_id () 中遇到的 bigint 型问题</p>
<p>总结： 根据以上分析 第一种方法 尽量少用 多用第二种方法 当遇到特殊情况时 可以考虑用第三种方法</p>
<p>原文：</p>
<p>http://blog.sina.com.cn/s/blog_3f8e41370100ijd3.html</p>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/php/2595.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
