<?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>El Blog de Manu Garcia &#187; PHP</title>
	<atom:link href="http://www.manugarcia.es/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.manugarcia.es</link>
	<description>Programador Web y emprendedor</description>
	<lastBuildDate>Thu, 06 Oct 2011 10:48:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Restaurar un Mysql Backup con php</title>
		<link>http://www.manugarcia.es/2009/09/05/restaurar-un-mysql-backup-con-php/</link>
		<comments>http://www.manugarcia.es/2009/09/05/restaurar-un-mysql-backup-con-php/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 09:38:28 +0000</pubDate>
		<dc:creator>Manu Garcia</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysqldump]]></category>

		<guid isPermaLink="false">http://mgarcia.info/?p=73</guid>
		<description><![CDATA[Escribo un post rápido sobre algo tan sencillo que ni se me había pasado por la cabeza, acostumbrado al acceso shell y el uso de mysqldump. Hace poco un amigo me comentaba el problema que tuvo al subir a un servidor un sql porque no tenía acceso shell para hacer mysqldump y tuvo que dividir [...]]]></description>
			<content:encoded><![CDATA[<p>Escribo un post rápido sobre algo tan sencillo que ni se me había pasado por la cabeza, acostumbrado al acceso shell y el uso de mysqldump. Hace poco un amigo me comentaba el problema que tuvo al subir a un servidor un sql porque no tenía acceso shell para hacer mysqldump y tuvo que dividir el sql en varias partes para su uso en PhpMyAdmin&#8230;</p>
<p>Pero hay una solución más sencilla y mucho más rapida, que podemos encontrar en el <a href="http://d15.biz/blog/2006/12/restore-mysql-dump-using-php/">blog de Daniel15</a></p>
<blockquote>
<div>
<div>
<pre style="font-family: monospace;"><span style="color: #339933;">&lt;</span>?php
<span style="color: #666666; font-style: italic;">/*
 * Restore MySQL dump using PHP
 * (c) 2006 Daniel15
 * Last Update: 9th December 2006
 * Version: 0.2
 * Edited: Cleaned up the code a bit.
 *
 * Please feel free to use any part of this, but please give me some credit <img src='http://www.manugarcia.es/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />
 */</span>

<span style="color: #666666; font-style: italic;">// Name of the file</span>
<span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'test.sql'</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// MySQL host</span>
<span style="color: #000088;">$mysql_host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// MySQL username</span>
<span style="color: #000088;">$mysql_username</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'root'</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// MySQL password</span>
<span style="color: #000088;">$mysql_password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Database name</span>
<span style="color: #000088;">$mysql_database</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'test'</span><span style="color: #339933;">;</span>

<span style="color: #666666; font-style: italic;">//////////////////////////////////////////////////////////////////////////////////////////////</span>

<span style="color: #666666; font-style: italic;">// Connect to MySQL server</span>
<span style="color: #990000;">mysql_connect</span><span style="color: #009900;">(</span><span style="color: #000088;">$mysql_host</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mysql_username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mysql_password</span><span style="color: #009900;">)</span> or <span style="color: #990000;">die</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'Error connecting to MySQL server: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Select database</span>
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">(</span><span style="color: #000088;">$mysql_database</span><span style="color: #009900;">)</span> or <span style="color: #990000;">die</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'Error selecting MySQL database: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>

<span style="color: #666666; font-style: italic;">// Temporary variable, used to store current query</span>
<span style="color: #000088;">$templine</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Read in entire file</span>
<span style="color: #000088;">$lines</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file</span><span style="color: #009900;">(</span><span style="color: #000088;">$filename</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Loop through each line</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">(</span><span style="color: #000088;">$lines</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$line</span><span style="color: #009900;">)</span>
<span style="color: #009900;">{</span>
	<span style="color: #666666; font-style: italic;">// Skip it if it's a comment</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span><span style="color: #990000;">substr</span><span style="color: #009900;">(</span><span style="color: #000088;">$line</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">)</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'--'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$line</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">)</span>
		<span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>

	<span style="color: #666666; font-style: italic;">// Add this line to the current segment</span>
	<span style="color: #000088;">$templine</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$line</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// If it has a semicolon at the end, it's the end of the query</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span><span style="color: #990000;">substr</span><span style="color: #009900;">(</span><span style="color: #990000;">trim</span><span style="color: #009900;">(</span><span style="color: #000088;">$line</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">';'</span><span style="color: #009900;">)</span>
	<span style="color: #009900;">{</span>
		<span style="color: #666666; font-style: italic;">// Perform the query</span>
		<span style="color: #990000;">mysql_query</span><span style="color: #009900;">(</span><span style="color: #000088;">$templine</span><span style="color: #009900;">)</span> or <span style="color: #990000;">print</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'Error performing query \'</span><span style="color: #339933;">&lt;</span>strong<span style="color: #339933;">&gt;</span><span style="color: #0000ff;">' . $templine . '</span>\<span style="color: #0000ff;">': '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;&lt;br /&gt;'</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// Reset temp variable to empty</span>
		<span style="color: #000088;">$templine</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">}</span>
<span style="color: #009900;">}</span>

<span style="color: #000000; font-weight: bold;">?&gt;</span></pre>
</div>
</div>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.manugarcia.es/2009/09/05/restaurar-un-mysql-backup-con-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Soporte Unicode en CentOS 5.2 con PHP y PCRE</title>
		<link>http://www.manugarcia.es/2009/05/19/soporte-unicode-en-centos-52-con-php-y-pcre/</link>
		<comments>http://www.manugarcia.es/2009/05/19/soporte-unicode-en-centos-52-con-php-y-pcre/#comments</comments>
		<pubDate>Tue, 19 May 2009 08:42:54 +0000</pubDate>
		<dc:creator>Manu Garcia</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Servidores]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[pcre]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://mgarcia.info/?p=58</guid>
		<description><![CDATA[No hace mucho me encontré con un problema en un servidor nuevo de la empresa (un CentOS con Plesk), tras instalar el framework Kohana y probar el test de compatibilidad que trae este framework me avisaba de que podría no funcionar bien ya que no tenía en mi servidor soporte unicode en el PCRE, para [...]]]></description>
			<content:encoded><![CDATA[<p>No hace mucho me encontré con un problema en un servidor nuevo de la <a href="http://mgarcia.info/2008/12/18/doublemusic-sl/">empresa </a>(un CentOS con Plesk), tras instalar el<a href="http://kohanaphp.com/"> framework Kohana </a>y probar el test de compatibilidad que trae este framework me avisaba de que podría no funcionar bien ya que no tenía en mi servidor soporte unicode en el <a href="http://www.pcre.org/">PCRE</a>, para probar si nuestro PCRE tiene soporte unicode tan sólo tenemos que poner via linea de comandos:</p>
<pre style="padding-left: 30px;">$ <strong>pcretest -C</strong>
PCRE version 6.6 06-Feb-2006
Compiled with
  UTF-8 support
<strong>  No Unicode properties support</strong>
  Newline character is LF
  Internal link size = 2
  POSIX malloc threshold = 10
  Default match limit = 10000000
  Default recursion depth limit = 10000000
  Match recursion uses stack</pre>
<p>Si a ti también te aparece &#8220;<strong>No Unicode properties support&#8221; </strong>al ejecutar pcre sigue leyendo <img src='http://www.manugarcia.es/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <strong> </strong>sino te recomiendo que visites mi web de <a href="http://www.emoxion.com">música electrónica</a> xD</p>
<p><strong>Solucionar el problema</strong></p>
<p>Antes de nada comentarte que no debes usar el usuario &#8220;root&#8221; para esto, por lo que deberíamos usar un usuario normal.</p>
<p>Bueno una vez estamos conectados con un usuario &#8220;normal&#8221; debemos crear los siguientes directorios en la carpeta por defecto de tu usuario ej. /home/miusuario &#8230;</p>
<p>$ mkdir -p ~/src/rpm<br />
$ cd ~/src/rpm<br />
$ mkdir BUILD RPMS SOURCES SPECS SRPMS<br />
$ mkdir RPMS/i[3456]86 RPMS/noarch RPMS/athlon</p>
<p>Una vez hecho esto creamos el archivo<strong> ~/.rpmmacros</strong> y escribimos lo siguiente:<br />
# Path to top of build area<br />
%_topdir    /home/miusuario/src/rpm</p>
<p>A continuación nos descargamos <a href="http://mirrors.kernel.org/centos/5.2/os/SRPMS/pcre-6.6-2.el5_1.7.src.rpm">este archivo</a>(Recuerda que yo estoy actualizando CentOS 5.2 con PCRE 6.6) en la carpeta de nuestro usuario y ponemos:</p>
<p>$ rpm -ivh pcre-6.6-2.el5_1.7.src.rpm</p>
<p>Esto pondrá los archivos necesarios en las carpetas creadas anteriormente para poder recompilar de nuevo PCRE con soporte Unicode.<br />
Ahora abrimos con nano (o vi eso a gusto de cada uno) el archivo</p>
<p>~/src/rpm/SPECS/pcre.spec</p>
<p>Buscamos &#8230;<br />
%configure &#8211;enable-utf8</p>
<p>Una vez encontrada le añadimos lo siguiente y guardamos el archivo<br />
%configure &#8211;enable-utf8 <strong>&#8211;enable-unicode-properties</strong></p>
<p>Bueno ya tenemos todo listo para recompilar PCRE con soporte Unicode ahora tan sólo tenemos que ejecutar lo siguiente</p>
<p>$ rpmbuild -ba ~/src/rpm/SPECS/pcre.spec</p>
<p>Esto nos mostrará algo parecido a esto:</p>
<p>Escrito: /home/miusuario/src/rpm/SRPMS/pcre-6.6-2.7.src.rpm<br />
Escrito: /home/miusuario/src/rpm/RPMS/i386/pcre-6.6-2.7.i386.rpm<br />
Escrito: /home/miusuario/src/rpm/RPMS/i386/pcre-devel-6.6-2.7.i386.rpm<br />
Escrito: /home/miusuario/src/rpm/RPMS/i386/pcre-debuginfo-6.6-2.7.i386.rpm</p>
<p>Ahora sí debemos cambiar a root para poder instalar el nuevo rpm:</p>
<p>$ rpm -Uvh /home/miusuario/src/rpm/RPMS/i386/pcre-6.6-2.7.i386.rpm</p>
<p>Reiniciamos apache <img src='http://www.manugarcia.es/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   listo! problema resuelto <img src='http://www.manugarcia.es/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Para este pequeño tutorial me he basado en los manuales <a href="http://gaarai.com/2009/01/31/unicode-support-on-centos-52-with-php-and-pcre/">Unicode Support on CentOS 5.2 with PHP and PCRE</a> y <a href="http://bradthemad.org/tech/notes/patching_rpms.php">How to patch and rebuild an RPM package</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.manugarcia.es/2009/05/19/soporte-unicode-en-centos-52-con-php-y-pcre/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

