<?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>Marcus Nyberg &#187; mysql</title>
	<atom:link href="http://www.marcusnyberg.com/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.marcusnyberg.com</link>
	<description>Digital and dangerous</description>
	<lastBuildDate>Mon, 26 Jul 2010 11:00:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Convert the character set of a mysql database</title>
		<link>http://www.marcusnyberg.com/2008/02/19/convert-the-character-set-of-a-mysql-database/</link>
		<comments>http://www.marcusnyberg.com/2008/02/19/convert-the-character-set-of-a-mysql-database/#comments</comments>
		<pubDate>Tue, 19 Feb 2008 12:32:07 +0000</pubDate>
		<dc:creator>marcus</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.marcusnyberg.com/2008/02/19/convert-the-character-set-of-a-mysql-database/</guid>
		<description><![CDATA[This php-script is for converting content of all tables of a mysql database to another character set. In this case i convert everything (latin 8859-1) to utf8_swedish_ci. The same action can be made from the shell with mysqldump and iconv, but the programmer in me prefers the-php-way. As always, tweaks and comments are very helpful. [...]]]></description>
			<content:encoded><![CDATA[<p>This php-script is for converting content of all tables of a mysql database to another character set. In this case i convert everything (latin 8859-1) to utf8_swedish_ci. The same action can be made from the shell with mysqldump and iconv, but the programmer in me prefers the-php-way. As always, tweaks and comments are very helpful.</p>
<p class="code">
&lt;?</p>
<p>set_time_limit(0);</p>
<p>$link = mysql_connect(&#8216;localhost&#8217;, &#8216;mysql_user&#8217;, &#8216;mysql_password&#8217;);</p>
<p>mysql_select_db(&#8216;db&#8217;);</p>
<p>$sql = &quot;SHOW TABLES FROM db&quot;;<br />
$result = mysql_query($sql);</p>
<p>while($row = mysql_fetch_array($result))<br />
{<br />
	$sql = &quot;ALTER TABLE &quot;.$row[0].&quot; CONVERT TO CHARACTER SET utf8 COLLATE utf8_swedish_ci&quot;;<br />
	mysql_query($sql);<br />
	echo &#8216;Converting table: &#8216;.$row[0].&#8217;&lt;br&gt;&#8217;;<br />
}</p>
<p>?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marcusnyberg.com/2008/02/19/convert-the-character-set-of-a-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL &#8211; replace &#8211; sök och ersätt</title>
		<link>http://www.marcusnyberg.com/2007/07/31/mysql-replace-sok-och-ersatt/</link>
		<comments>http://www.marcusnyberg.com/2007/07/31/mysql-replace-sok-och-ersatt/#comments</comments>
		<pubDate>Tue, 31 Jul 2007 10:59:12 +0000</pubDate>
		<dc:creator>marcus</dc:creator>
				<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.marcusnyberg.com/2007/07/31/mysql-replace-sok-och-ersatt/</guid>
		<description><![CDATA[En smidig funktionalitet i MySQL för att göra enkla sökningar-ersättningar (find-replace) i texter är att använda sig av strängfunktionen replace. Den har visat sig väldigt användbar då jag av misstag fått in en massa junktext i databasen och måste rätta detta. Syntax: REPLACE(sträng,från_sträng,till_sträng) Exempel: mysql&#62; SELECT REPLACE(&#8216;www.mysql.com&#8217;, &#8216;w&#8217;, &#8216;Ww&#8217;); Resultat&#62; &#8216;WwWwWw.mysql.com&#8217;]]></description>
			<content:encoded><![CDATA[<p>En smidig funktionalitet i MySQL för att göra enkla sökningar-ersättningar (find-replace) i texter är att använda sig av <a target="_blank" href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace">strängfunktionen replace</a>. Den har visat sig väldigt användbar då jag av misstag fått in en massa junktext i databasen och måste rätta detta.</p>
<p><strong>Syntax:<br />
</strong>REPLACE(sträng,från_sträng,till_sträng)</p>
<p><strong>Exempel:</strong><br />
mysql&gt; SELECT REPLACE(&#8216;www.mysql.com&#8217;, &#8216;w&#8217;, &#8216;Ww&#8217;);<br />
Resultat&gt; &#8216;WwWwWw.mysql.com&#8217;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marcusnyberg.com/2007/07/31/mysql-replace-sok-och-ersatt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
