<?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>Avi :) &#187; php</title>
	<atom:link href="http://blog.avi.co/wp/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.avi.co</link>
	<description>Open Source Software Hippy and all-round pedant</description>
	<lastBuildDate>Mon, 07 Jun 2010 14:34:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Massive dumps with MySQL</title>
		<link>http://blog.avi.co/wp/massive-dumps-with-mysql/</link>
		<comments>http://blog.avi.co/wp/massive-dumps-with-mysql/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 23:47:03 +0000</pubDate>
		<dc:creator>Avi</dc:creator>
				<category><![CDATA[Geekery]]></category>
		<category><![CDATA[dump]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plaintextiscool]]></category>

		<guid isPermaLink="false">http://aviswebsite.co.uk/?p=450</guid>
		<description><![CDATA[hurr. *insert FLUSH TABLES joke here*
I have a 2.5GB sql dump to import to my MySQL server. MySQL doesn't like me giving it work to do, and the box it's running on only has 3GB of memory. So, I stumbled across bigdump, which is brilliant. It's a PHP script that splits massive SQL dumps into [...]]]></description>
			<content:encoded><![CDATA[<p>hurr. *insert <tt>FLUSH TABLES</tt> joke here*</p>
<p>I have a 2.5GB sql dump to import to my MySQL server. MySQL doesn't like me giving it work to do, and the box it's running on only has 3GB of memory. So, I stumbled across <a href="http://www.ozerov.de/bigdump.php">bigdump</a>, which is brilliant. It's a PHP script that splits massive SQL dumps into smaller statements, and runs them one at a time against the server. Always the way: 10 lines into duct-taping together something to do the job for you, you find that someone else has done it rather elegantly.<sup>1</sup></p>
<p>In short, we extract the directory to a publicly http-accessible location, stick the sql dump there and tell it to go.</p>
<p>In long, installation is approximately as follows:</p>
<pre class="bash">avi@jup-linux2:~$ <span style="color: #7a0874; font-weight: bold;">cd</span> www
avi@jup-linux2:~/www$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> bigdump
avi@jup-linux2:~/www$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">777</span> bigdump
avi@jup-linux2:~/www$ <span style="color: #7a0874; font-weight: bold;">cd</span> bigdump/
avi@jup-linux2:~/www$ <span style="color: #c20cb9; font-weight: bold;">wget</span> -q http://www.ozerov.de/bigdump.<span style="color: #c20cb9; font-weight: bold;">zip</span>
avi@jup-linux2:~/www$ <span style="color: #c20cb9; font-weight: bold;">unzip</span> bigdump.<span style="color: #c20cb9; font-weight: bold;">zip</span>
avi@jup-linux2:~/www/bigdump$ <span style="color: #c20cb9; font-weight: bold;">ls</span>
bigdump.php  bigdump.<span style="color: #c20cb9; font-weight: bold;">zip</span></pre>
<p>Where <tt>~/www</tt> is my apache UserDir (i.e. when I visit <tt>http://localhost/~avi</tt>, i see the contents of <tt>~/www</tt>). We need permissions to execute PHP scripts in this dir, too (which I have already). We also need to give everyone permissions to do everything - don't do this on the internet!<sup>2</sup></p>
<p>Configuration involves editing <tt>bigdump.php</tt> with the hostname of our MySQL server, the name of the DB we want to manipulate and our credentials. The following is lines 40-45 of mine:</p>
<pre class="php"><span style="color: #808080; font-style: italic;">// Database configuration</span>
&nbsp;
<span style="color: #0000ff;">$db_server</span>   = <span style="color: #ff0000;">'localhost'</span>;
<span style="color: #0000ff;">$db_name</span>     = <span style="color: #ff0000;">'KBDB'</span>;
<span style="color: #0000ff;">$db_username</span> = <span style="color: #ff0000;">'kbox'</span>;
<span style="color: #0000ff;">$db_password</span> = <span style="color: #ff0000;">'imnottellingyou'</span>;</pre>
<p>Finally, we need to give it a dump to process. For dumps of less than 2Mb<sup>3</sup>, we can upload through the web browser, else we need to upload or link our sql dump to the same directory as bigdump:</p>
<pre class="bash">avi@jup-linux2:~/www/bigdump$ <span style="color: #c20cb9; font-weight: bold;">ln</span> -s /home/avi/kbox/kbox_dbdata ./dump.sql</pre>
<p>Now, we visit the php page through a web browser, and get a pretty interface:</p>
<p><a href="http://aviswebsite.co.uk/wordpress/wp-content/uploads/massive-dumps-with-mysql/bigdump.png"><img src="http://aviswebsite.co.uk/wordpress/wp-content/uploads/massive-dumps-with-mysql/bigdump-150x150.png" alt="" title="Bigdump UI" width="150" height="150" class="aligncenter size-thumbnail wp-image-460" /></a></p>
<p>BigDump lists all the files in its working directory, and for any that are SQL dumps provides a 'Start Import' link. To import one of them, click the link and wait.</p>
<ol class="footnotes"><li id="footnote_0_450" class="footnote">Yes, you Perl people, it's in PHP. But it's not written by me. So on balance turns out more elegant.</li><li id="footnote_1_450" class="footnote">Those permissions aside - anyone can execute whatever SQL they like with your credentials through this page. Seriously, not on the internet!</li><li id="footnote_2_450" class="footnote">Or whatever's smaller out of <tt>upload_max_filesize</tt> and <tt>post_max_size</tt> in your <tt>php.ini</tt></li></ol>]]></content:encoded>
			<wfw:commentRss>http://blog.avi.co/wp/massive-dumps-with-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP error on fresh install of PHPWiki: Non-static method _PearDbPassUser::_PearDbPassUser() cannot be called statically</title>
		<link>http://blog.avi.co/wp/phpwiki-error-non-static-method-_peardbpassuser_peardbpassuser-cannot-be-called-statically/</link>
		<comments>http://blog.avi.co/wp/phpwiki-error-non-static-method-_peardbpassuser_peardbpassuser-cannot-be-called-statically/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 21:58:29 +0000</pubDate>
		<dc:creator>Avi</dc:creator>
				<category><![CDATA[Geekery]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wiki]]></category>

		<guid isPermaLink="false">http://aviswebsite.co.uk/?p=278</guid>
		<description><![CDATA[I've just installed PHPWiki 1.3.14-4 from the debian repositories and out of the box I got the following message on trying to log in to it:
Fatal error: Non-static method _PearDbPassUser::_PearDbPassUser() cannot be called statically, assuming $this from incompatible context in /usr/share/phpwiki.bak.d/lib/WikiUserNew.php on line 1118
The problem appears to be that, as of PHP 5.something, you're not [...]]]></description>
			<content:encoded><![CDATA[<p>I've just installed PHPWiki 1.3.14-4 from the debian repositories and out of the box I got the following message on trying to log in to it:</p>
<pre>Fatal error: Non-static method _PearDbPassUser::_PearDbPassUser() cannot be called statically, assuming $this from incompatible context in /usr/share/phpwiki.bak.d/lib/WikiUserNew.php on line 1118</pre>
<p>The problem appears to be that, as of PHP 5.something, you're not allowed to have a function with the same name as a class. Apparently it's been a failure in E_STRICT mode for a while.</p>
<p>Anyway, the solution is to rename <tt>_PearDbPassUser()</tt> to something else, and then replace all calls to it with this new name.</p>
<p>I've done this and, so far, everything appears to work.</p>
<p>The function is defined in <tt>/usr/share/lib/phpwiki/lib/WikiUser/PearDb.php</tt>:</p>
<pre class="diff">&nbsp;
jup-linux2:/usr/share$ diff phpwiki.bak.d/lib/WikiUser/PearDb.php phpwiki/lib/WikiUser/PearDb.php
<span style="color: #440088;">18c18</span>
<span style="color: #991111;">&lt; function _PearDbPassUser<span style="">&#40;</span>$UserName='',$prefs=false<span style="">&#41;</span> <span style="">&#123;</span></span>
<span style="color: #888822;">---
<span style="color: #00b000;">&gt;     function _PearDbPassUserFoo<span style="">&#40;</span>$UserName='',$prefs=false<span style="">&#41;</span> <span style="">&#123;</span></span></span>
&nbsp;</pre>
<p>and is called in <tt>/usr/share/WikiUserNew.php</tt>:</p>
<pre class="diff">&nbsp;
jup-linux2:/usr/share$ diff phpwiki.bak.d/lib/WikiUserNew.php phpwiki/lib/WikiUserNew.php
<span style="color: #440088;">1118c1118</span>
<span style="color: #991111;">&lt; _PearDbPassUser::_PearDbPassUser<span style="">&#40;</span>$this-&gt;_userid, $this-&gt;_prefs<span style="">&#41;</span>;</span>
<span style="color: #888822;">---
<span style="color: #00b000;">&gt;                 _PearDbPassUser::_PearDbPassUserFoo<span style="">&#40;</span>$this-&gt;_userid, $this-&gt;_prefs<span style="">&#41;</span>;</span></span>
<span style="color: #440088;">1157c1157</span>
<span style="color: #991111;">&lt; _PearDbPassUser::_PearDbPassUser<span style="">&#40;</span>$this-&gt;_userid, $prefs<span style="">&#41;</span>;</span>
<span style="color: #888822;">---
<span style="color: #00b000;">&gt;                 _PearDbPassUser::_PearDbPassUserFoo<span style="">&#40;</span>$this-&gt;_userid, $prefs<span style="">&#41;</span>;</span></span>
<span style="color: #440088;">2120c2120</span>
<span style="color: #991111;">&lt; function PearDbUserPreferences <span style="">&#40;</span>$saved_prefs = false<span style="">&#41;</span> <span style="">&#123;</span></span>
<span style="color: #888822;">---
<span style="color: #00b000;">&gt;     function PearDbUserPreferencesFoo <span style="">&#40;</span>$saved_prefs = false<span style="">&#41;</span> <span style="">&#123;</span></span></span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.avi.co/wp/phpwiki-error-non-static-method-_peardbpassuser_peardbpassuser-cannot-be-called-statically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
