<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	
	>
<channel>
	<title>Comments on: PDO For WordPress v1.0.0: Already a bug!!</title>
	<atom:link href="https://rathercurious.no3.co.uk/archives/30/feed" rel="self" type="application/rss+xml" />
	<link>https://rathercurious.no3.co.uk/archives/30</link>
	<description>A home for my coding projects</description>
	<lastBuildDate>Fri, 26 Feb 2010 22:24:46 +0000</lastBuildDate>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.16</generator>
	<item>
		<title>By: baron</title>
		<link>https://rathercurious.no3.co.uk/archives/30/comment-page-1#comment-2080</link>
		<dc:creator><![CDATA[baron]]></dc:creator>
		<pubDate>Fri, 03 Apr 2009 11:32:37 +0000</pubDate>
		<guid isPermaLink="false">http://rathercurious.net/archives/30#comment-2080</guid>
		<description><![CDATA[Works great, thank you]]></description>
		<content:encoded><![CDATA[<p>Works great, thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ingo Fabbri</title>
		<link>https://rathercurious.no3.co.uk/archives/30/comment-page-1#comment-1266</link>
		<dc:creator><![CDATA[Ingo Fabbri]]></dc:creator>
		<pubDate>Wed, 17 Dec 2008 17:39:54 +0000</pubDate>
		<guid isPermaLink="false">http://rathercurious.net/archives/30#comment-1266</guid>
		<description><![CDATA[i can confirm that. BertrandB&#039;s solution is working indeed. the dateupdate-script posted by justin above does not help. with the integer-casts i solved the broken page-archive due to wrong string vs. integer comparison - like bertrandb already said it: &#039;08&#039; != 8

thanks bertrand, now i have my page-archive finally working]]></description>
		<content:encoded><![CDATA[<p>i can confirm that. BertrandB&#8217;s solution is working indeed. the dateupdate-script posted by justin above does not help. with the integer-casts i solved the broken page-archive due to wrong string vs. integer comparison &#8211; like bertrandb already said it: &#8217;08&#8242; != 8</p>
<p>thanks bertrand, now i have my page-archive finally working</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BertrandB</title>
		<link>https://rathercurious.no3.co.uk/archives/30/comment-page-1#comment-824</link>
		<dc:creator><![CDATA[BertrandB]]></dc:creator>
		<pubDate>Mon, 08 Sep 2008 17:56:27 +0000</pubDate>
		<guid isPermaLink="false">http://rathercurious.net/archives/30#comment-824</guid>
		<description><![CDATA[Ok i&#039;ll wait, for the moment my fix (with the cast) solve my problem as you can see my worrd works fine

and i don&#039;t see errors in my database with SqliteManager i have
post_date = &#039;2008-08-30 18:30:12&#039;
the problem that yoiy patch fix is for the first day of a month and in my database the post_date is right like this
&#039;2008-09-04 21:36:03&#039; i think that we don&#039;t speak of same problem mine was because &#039;08&#039; is not equal to 08 (the string is not equal to the integer.]]></description>
		<content:encoded><![CDATA[<p>Ok i&#8217;ll wait, for the moment my fix (with the cast) solve my problem as you can see my worrd works fine</p>
<p>and i don&#8217;t see errors in my database with SqliteManager i have<br />
post_date = &#8217;2008-08-30 18:30:12&#8242;<br />
the problem that yoiy patch fix is for the first day of a month and in my database the post_date is right like this<br />
&#8217;2008-09-04 21:36:03&#8242; i think that we don&#8217;t speak of same problem mine was because &#8217;08&#8242; is not equal to 08 (the string is not equal to the integer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin</title>
		<link>https://rathercurious.no3.co.uk/archives/30/comment-page-1#comment-819</link>
		<dc:creator><![CDATA[Justin]]></dc:creator>
		<pubDate>Sun, 07 Sep 2008 22:25:26 +0000</pubDate>
		<guid isPermaLink="false">http://rathercurious.net/archives/30#comment-819</guid>
		<description><![CDATA[the code above was flawed.  i&#039;ve fixed it now.
i&#039;m also going to have a look at the stringify option for pdo which would then more closely mimic the mysql behaviour and thus might avoid some other problems i&#039;ve been seeing.]]></description>
		<content:encoded><![CDATA[<p>the code above was flawed.  i&#8217;ve fixed it now.<br />
i&#8217;m also going to have a look at the stringify option for pdo which would then more closely mimic the mysql behaviour and thus might avoid some other problems i&#8217;ve been seeing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin</title>
		<link>https://rathercurious.no3.co.uk/archives/30/comment-page-1#comment-817</link>
		<dc:creator><![CDATA[Justin]]></dc:creator>
		<pubDate>Sun, 07 Sep 2008 20:37:31 +0000</pubDate>
		<guid isPermaLink="false">http://rathercurious.net/archives/30#comment-817</guid>
		<description><![CDATA[oh, and you might want to fix the existing inconsistencies in the database from previous posts.  don&#039;t forget to &lt;b&gt; backup your database first!&lt;/b&gt;

i wrote this code, which should work but I HAVE NOT TESTED IT other than on a tiny wp installation.

I store this file in the wp root directory (don&#039;t forget to remove it after use...)
&lt;pre lang=&quot;php&quot;&gt;
&lt;?php
ini_set(&#039;display_errors&#039;, true);
error_reporting(E_ALL);

$array[] = 
array (	&#039;table&#039;=&gt;	&#039;wp_comments&#039;,
		&#039;fields&#039;=&gt;	array(	&#039;comment_date&#039;, 
							&#039;comment_date_gmt&#039;)	
		);
$array[] = 
array (	&#039;table&#039;=&gt;	&#039;wp_links&#039;,
		&#039;fields&#039;=&gt;	array(	&#039;link_updated&#039;)	
		);
$array[] = 
array (	&#039;table&#039;=&gt;	&#039;wp_posts&#039;,
		&#039;fields&#039;=&gt;	array(	&#039;post_date&#039;,
							&#039;post_date_gmt&#039;,
							&#039;post_modified&#039;,
							&#039;post_modified_gmt&#039;,
							)
		);
$array[] = 
array (	&#039;table&#039;=&gt;	&#039;wp_users&#039;,
		&#039;fields&#039;=&gt;	array(	&#039;user_registered&#039;)
		);
try {
	$wpdb = new PDO(&#039;sqlite:./wp-content/database/MyBlog.sqlite&#039;); 
} catch (Exception $e) {
	echo $e-&gt;getMessage();
	exit;
}

$wpdb-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$wpdb-&gt;sqlitecreatefunction(&#039;rewriteDates&#039;, &#039;rewriteDates&#039;, 1);

function rewriteDates($string){
	$pattern = &#039;/([12]d{3})-(d{1,2})-(d{1,2})/ims&#039;;
	return preg_replace_callback($pattern, &#039;_rewriteDates&#039;, $string);

}
function _rewriteDates($date){
	list ($all, $year, $month, $day) = $date;
	$return = sprintf(&quot;%s-%02s-%02s&quot;, $year, $month, $day);
	echo $return . &quot;&lt;br/&gt;&quot;;
	return $return;
}
foreach ($array as $query){
	$q = &quot;Update $query[table] set &quot;;
	foreach ($query[&#039;fields&#039;] as $field){
		$q .= &quot;$field = rewriteDates($field),&quot;;
	}
	$q = rtrim($q, &#039;,&#039;);
        $wpdb-&gt;exec($q);
}

echo &#039;Finished&#039;;
?&gt;
&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>oh, and you might want to fix the existing inconsistencies in the database from previous posts.  don&#8217;t forget to <b> backup your database first!</b></p>
<p>i wrote this code, which should work but I HAVE NOT TESTED IT other than on a tiny wp installation.</p>
<p>I store this file in the wp root directory (don&#8217;t forget to remove it after use&#8230;)</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'display_errors'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">error_reporting</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">E_ALL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> 
<span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span>	<span style="color: #0000ff;">'table'</span><span style="color: #339933;">=&gt;</span>	<span style="color: #0000ff;">'wp_comments'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'fields'</span><span style="color: #339933;">=&gt;</span>	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>	<span style="color: #0000ff;">'comment_date'</span><span style="color: #339933;">,</span> 
							<span style="color: #0000ff;">'comment_date_gmt'</span><span style="color: #009900;">&#41;</span>	
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> 
<span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span>	<span style="color: #0000ff;">'table'</span><span style="color: #339933;">=&gt;</span>	<span style="color: #0000ff;">'wp_links'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'fields'</span><span style="color: #339933;">=&gt;</span>	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>	<span style="color: #0000ff;">'link_updated'</span><span style="color: #009900;">&#41;</span>	
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> 
<span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span>	<span style="color: #0000ff;">'table'</span><span style="color: #339933;">=&gt;</span>	<span style="color: #0000ff;">'wp_posts'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'fields'</span><span style="color: #339933;">=&gt;</span>	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>	<span style="color: #0000ff;">'post_date'</span><span style="color: #339933;">,</span>
							<span style="color: #0000ff;">'post_date_gmt'</span><span style="color: #339933;">,</span>
							<span style="color: #0000ff;">'post_modified'</span><span style="color: #339933;">,</span>
							<span style="color: #0000ff;">'post_modified_gmt'</span><span style="color: #339933;">,</span>
							<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> 
<span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span>	<span style="color: #0000ff;">'table'</span><span style="color: #339933;">=&gt;</span>	<span style="color: #0000ff;">'wp_users'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'fields'</span><span style="color: #339933;">=&gt;</span>	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>	<span style="color: #0000ff;">'user_registered'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
try <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$wpdb</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PDO<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sqlite:./wp-content/database/MyBlog.sqlite'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span>PDO<span style="color: #339933;">::</span><span style="color: #004000;">ATTR_ERRMODE</span><span style="color: #339933;">,</span> PDO<span style="color: #339933;">::</span><span style="color: #004000;">ERRMODE_WARNING</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sqlitecreatefunction</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'rewriteDates'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rewriteDates'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> rewriteDates<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/([12]d{3})-(d{1,2})-(d{1,2})/ims'</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">preg_replace_callback</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_rewriteDates'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> _rewriteDates<span style="color: #009900;">&#40;</span><span style="color: #000088;">$date</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">list</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$all</span><span style="color: #339933;">,</span> <span style="color: #000088;">$year</span><span style="color: #339933;">,</span> <span style="color: #000088;">$month</span><span style="color: #339933;">,</span> <span style="color: #000088;">$day</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$date</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">%s</span>-<span style="color: #009933; font-weight: bold;">%02s</span>-<span style="color: #009933; font-weight: bold;">%02s</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$year</span><span style="color: #339933;">,</span> <span style="color: #000088;">$month</span><span style="color: #339933;">,</span> <span style="color: #000088;">$day</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$return</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$q</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Update <span style="color: #006699; font-weight: bold;">$query[table]</span> set &quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'fields'</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$q</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$field</span> = rewriteDates(<span style="color: #006699; font-weight: bold;">$field</span>),&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$q</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rtrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$q</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">','</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #990000;">exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$q</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Finished'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
	</item>
</channel>
</rss>
