<?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>Punksolid &#187; php</title>
	<atom:link href="http://www.punksolid.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.punksolid.com</link>
	<description>Tecnologia, Curiosidades, Sistemas de Informacion y un poco de Religion</description>
	<lastBuildDate>Thu, 18 Aug 2011 13:06:55 +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>Busquedas de filtros complejos en CakePHP</title>
		<link>http://www.punksolid.com/busquedas-de-filtros-complejos-en-cakephp/2011/</link>
		<comments>http://www.punksolid.com/busquedas-de-filtros-complejos-en-cakephp/2011/#comments</comments>
		<pubDate>Fri, 12 Aug 2011 11:57:44 +0000</pubDate>
		<dc:creator>Punksolid</dc:creator>
				<category><![CDATA[Aplicaciones]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[programación]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programas]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.punksolid.com/?p=644</guid>
		<description><![CDATA[Para comprender la situación mejor, necesitamos ver el screenshot de la vista. Hay varias formas de hacer esto, la mas común es usar la función query de CakePHP para armar la consulta SQL en base a condiciones by (@el_keogh) , está la función find, pero no se pueden poner condiciones dentro, así que lo que [...]]]></description>
			<content:encoded><![CDATA[<p>Para comprender la situación mejor, necesitamos ver el screenshot de la vista.</p>
<p><a href="http://www.punksolid.com/blog/wordpress/wp-content/uploads/2011/07/Selecci%C3%B3n_011.png"><img class="aligncenter size-full wp-image-660" title="Busqueda" src="http://www.punksolid.com/blog/wordpress/wp-content/uploads/2011/08/Selecci%C3%B3n_024.png" alt="" width="687" height="225" /></a></p>
<p>Hay varias formas de hacer esto, la mas común es usar la función query de CakePHP para armar la <a href="http://pastebin.com/XS1rMtr1" target="_blank">consulta SQL en base a condiciones</a> by (<a href="http://twitter.com/el_keogh" target="_blank">@el_keogh)</a> , está la función find, pero no se pueden poner condiciones dentro, así que lo que se puede hacer es armar el array conditions desde afuera de la siguiente forma:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #666666; font-style: italic;">//Bloque #1 asignacion de variables para comodidad</span>
<span style="color: #000088;">$alumnoid</span><span style="color: #339933;">=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cuenta'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$user</span><span style="color: #339933;">=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fechaInicio</span><span style="color: #339933;">=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Fecha de Inicio'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fechaFin</span><span style="color: #339933;">=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Fecha de Fin'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$formadepago</span><span style="color: #339933;">=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'forma_de_pago'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$resultado</span><span style="color: #339933;">=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'resultado'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$conditions</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Bloque #2 Condiciones tabla Alumnos</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nombre'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$conditions</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Alumno.nombre LIKE'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'%'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nombre'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'%'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'apellido_paterno'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$conditions</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Alumno.apellido_paterno LIKE'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'%'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'apellido_paterno'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'%'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'apellido_materno'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$conditions</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Alumno.apellido_materno LIKE'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'%'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'apellido_materno'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'%'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//Bloque #3 Condiciones tabla Examenes</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$alumnoid</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$conditions</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene.alumno_id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$alumnoid</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$conditions</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene.user_id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$user</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//Bloque #4 Condiciones de intervalos de fecha</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fechaInicio</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$conditions</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene.created &gt;'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$fechaInicio</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fechaFin</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$conditions</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene.created &lt;='</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span><span style="color: #000088;">$fechaFin</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' 23:59:59'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$formadepago</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$conditions</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene.forma_de_pago'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span><span style="color: #000088;">$formadepago</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resultado</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$conditions</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene.resultado'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span><span style="color: #000088;">$resultado</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//Bloque #5 query</span>
<span style="color: #000088;">$conditions</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Examene.statusid &lt;&gt;'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$examenes</span><span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">paginate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$conditions</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h3>Bloque #1 asignación de variables</h3>
<p>En este caso se manejan dos tablas distintas de la base de datos, están relacionadas entre si, Alumnos y Examenes, utilicé asignación de variables para mas comodidad en su manejo, pero no son necesarias.</p>
<h3>Bloque #2 Condiciones de tabla Alumnos</h3>
<p>Las condiciones determinan cuando hay datos en los campos, si no hay datos, no hay condición que aplicar y nada que meter en el array, las primeras tres condiciones pertenecen a la tabla alumnos, de la cual se va a buscar por nombre NO exacto por eso los LIKE y la concatenación del símbolo de porcentaje. Para que esto funcione, las relaciones en el modelo deben estar previamente establecidas.</p>
<h3>Bloque #3 Condiciones de tabla Examenes</h3>
<p>En el segundo bloque ponemos las condiciones de la otra tabla, nada especial ya que los valores de esos campos deben ser exactos.</p>
<h3>Bloque #4 Condiciones de intervalos de fecha</h3>
<p>Para cuando tenemos intervalos de fechas y tenemos el formato en Datetime, es necesario concatenar la hora en la que termina el dia, si no lo hiciéramos contaría hasta la hora 00:00:00 no devolviéndonos los resultados del ultimo dia especificado.</p>
<h3>Bloque #5 Query</h3>
<p>La función paginate, se utiliza casi de la misma manera que un <a href="http://book.cakephp.org/view/1030/Complex-Find-Conditions" title="Complex Find Conditions" target="_blank">find</a> y listo automagicamente cakephp devolverá solo los exámenes de los campos donde se les haya especificado algun dato, notese que este tipo de búsqueda es de tipo AND, o sea cada campo va filtrando aun mas la búsqueda, en lugar de añadir nuevas coincidencias.</p>
<p>Cualquier duda o comentario es bienvenido.<br />
Referencias<br />
<a href="http://book.cakephp.org/view/1030/Complex-Find-Conditions" title="Documentación oficial cakephp" target="_blank">Complex Find Conditions</a><br />
<a href="http://book.cakephp.org/view/164/pagination" target="_blank">Pagination in cakephp</a></p>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.punksolid.com/busquedas-de-filtros-complejos-en-cakephp/2011/&via=Punksolid&text=Busquedas de filtros complejos en CakePHP&related=José Palazuelos:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.punksolid.com/busquedas-de-filtros-complejos-en-cakephp/2011/&via=Punksolid&text=Busquedas de filtros complejos en CakePHP&related=José Palazuelos:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.punksolid.com/busquedas-de-filtros-complejos-en-cakephp/2011/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>cakephp-instaweb</title>
		<link>http://www.punksolid.com/cakephp-instaweb/2011/</link>
		<comments>http://www.punksolid.com/cakephp-instaweb/2011/#comments</comments>
		<pubDate>Thu, 12 May 2011 08:12:43 +0000</pubDate>
		<dc:creator>Punksolid</dc:creator>
				<category><![CDATA[Aplicaciones]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[programación]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[desarrollo]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Ubuntu 10.10]]></category>
		<category><![CDATA[Ubuntu 11.04]]></category>

		<guid isPermaLink="false">http://www.punksolid.com/?p=636</guid>
		<description><![CDATA[cakephp-instaweb server es un webserver pequeño con todas las configuraciones necesarias para desarrollar en cakephp, no necesitas instalar todo el entorno php. Funciona igual al django-runserver, solo en la terminal te colocas en la carpeta de la aplicación, corres el comando y listo, tendrás tu app funcionando en http://localhost.com:3000 Si usas Ubuntu 10.10 y cakephp [...]]]></description>
			<content:encoded><![CDATA[<p><strong><img class="alignright" title="Cakephp" src="http://cakephp.org/img/new.png" alt="cakephp" width="134" height="132" />cakephp-instaweb</strong> server es un webserver pequeño con todas las configuraciones necesarias para desarrollar en cakephp, no necesitas instalar todo el entorno php. Funciona igual al django-runserver, solo en la terminal te colocas en la carpeta de la aplicación, corres el comando y listo, tendrás tu app funcionando en http://localhost.com:3000</p>
<p>Si usas Ubuntu 10.10 y cakephp 1.3.8 te marcará un error</p>
<blockquote>
<h3>CGI Script Error</h3>
<h3>Premature end of script headers.</h3>
</blockquote>
<p>Si instalaste cakephp-instaweb desde los repositorios de maverick se habrá instalado la versión 0.4.X, el error anterior se soluciona con la versión mas nueva 0.5-1 para instalarlo primero debes desinstalar completamente el cakephp-instaweb y luego <a href="https://launchpad.net/ubuntu/natty/amd64/cakephp-instaweb/0.5-1">descargar el .deb desde launchpad para Ubuntu Natty</a>, no causa conflicto alguno.</p>
<p>Con eso se habrá solucionado el problema.</p>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.punksolid.com/cakephp-instaweb/2011/&via=Punksolid&text=cakephp-instaweb&related=José Palazuelos:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.punksolid.com/cakephp-instaweb/2011/&via=Punksolid&text=cakephp-instaweb&related=José Palazuelos:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.punksolid.com/cakephp-instaweb/2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Select o SelectTag en CakePhp 1.2</title>
		<link>http://www.punksolid.com/select-o-selecttag-en-cakephp-12/2009/</link>
		<comments>http://www.punksolid.com/select-o-selecttag-en-cakephp-12/2009/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 06:16:47 +0000</pubDate>
		<dc:creator>Punksolid</dc:creator>
				<category><![CDATA[programación]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.punksolid.com/?p=347</guid>
		<description><![CDATA[Me confundí un poco a la hora de ocupar un selectTag en cakephp 1.2,  y al buscar no lo encontré rapido, viendo la API me funcionó de la siguiente manera. select(Nombre,$options(array)) echo $form-&#62;select&#40;'tipocuenta',array&#40;0=&#62;'Cuenta Corriente',1=&#62;'Cuenta de Ahorros'&#41;&#41;; TweetTweet]]></description>
			<content:encoded><![CDATA[<p>Me confundí un poco a la hora de ocupar un selectTag en cakephp 1.2,  y al buscar no lo encontré rapido, viendo la API me funcionó de la siguiente manera.<br />
select(Nombre,$options(array))</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tipocuenta'</span><span style="color: #339933;">,</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'Cuenta Corriente'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'Cuenta de Ahorros'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.punksolid.com/select-o-selecttag-en-cakephp-12/2009/&via=Punksolid&text=Select o SelectTag en CakePhp 1.2&related=José Palazuelos:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.punksolid.com/select-o-selecttag-en-cakephp-12/2009/&via=Punksolid&text=Select o SelectTag en CakePhp 1.2&related=José Palazuelos:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.punksolid.com/select-o-selecttag-en-cakephp-12/2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Conectar la placa Arduino con PHP a travez de PHP Serial</title>
		<link>http://www.punksolid.com/conectar-la-placa-arduino-con-php-a-travez-de-php-serial/2008/</link>
		<comments>http://www.punksolid.com/conectar-la-placa-arduino-con-php-a-travez-de-php-serial/2008/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 05:59:12 +0000</pubDate>
		<dc:creator>Punksolid</dc:creator>
				<category><![CDATA[Aplicaciones]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[programación]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.punksolid.com/?p=114</guid>
		<description><![CDATA[Este tutorial sirve para conectar Arduino con PHP de manera mas directa sobre windows con XAMPP y la extensión PHP Serial, que prácticamente debería servir para cualquier dispositivo que se quiera conectar al puerto Serial de la computadora, aunque mi prueba es por USB. Guía Rápida Descarga e instala XAMPP. Descarga la extensión y los [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" title="XAMPP" src="http://www.noticiastech.com/wordpress/wp-content/uploads/2007/07/xammp.jpg" alt="" width="252" height="173" />Este tutorial sirve para conectar Arduino con PHP de manera mas directa sobre windows con XAMPP y la extensión <a href="http://www.easyvitools.com/phpserial/index.html">PHP Serial</a>, que prácticamente debería servir para cualquier dispositivo que se quiera conectar al puerto Serial de la computadora, aunque mi prueba es por USB.</p>
<p><strong>Guía Rápida<br />
</strong></p>
<ol>
<li><a href="http://sourceforge.net/projects/xampp/">Descarga e instala XAMPP</a>.</li>
<li>Descarga la extensión y los archivos de ejemplo de <a href="http://www.easyvitools.com/download/download.html">PHP Serial</a>.</li>
<li>Coloca el *.dll en las librerías de PHP y activalas en el php.ini.</li>
<li>Pon el Xampp en modo CGI.</li>
<li>Conecta y sube código de prueba al Arduino.</li>
<li>Inicia el Apache.</li>
<li>Usa archivo de prueba "sms_list.php" que viene en el paquete de PHP Serial .</li>
<li>Ejecútalo y Suerte.</li>
</ol>
<p><strong>Guía Detallada</strong></p>
<p>Una vez instalado XAMPP en windows descarga la extension y los archivos de <a href="http://www.easyvitools.com/download/download.html">PHP Serial</a> una vez descompreso copia el archivo <strong>php_ser.dll </strong>en la carpeta de extensiones de PHP que usualmente suele ser para PHP5</p>
<p><strong>C:/PHP/ext/</strong></p>
<p>ahora debes buscar el <strong>php.ini </strong>dentro de la carpeta<strong> C:\xampp\php</strong> en el caso de XAMPP y abrirlo con un bloc de notas, aunque recomiendo <a href="http://notepad-plus.sourceforge.net/es/site.htm">NOTEPAD+</a> que es el que uso, y agregar la extencion que copiamos anteriormente, para hacer eso solo debemos agregar la siguiente linea donde están las demas dll, ejemplo:</p>
<p><strong>extension=php_ser.dll</strong></p>
<p>guarda y cierra el php.ini.</p>
<p>si no estas usando XAMPP talvez asi ya puedas utilizarlo, solo reinicia el apache, pero si eres usuario de XAMPP debes configurarlo para que corra como CGI, ya que por default corre como modulo de apache, para cambiar esto debemos:</p>
<ol>
<li>Ir a<strong> C:\xampp\apache\conf\extra/httpd-xampp.conf </strong>y buscar donde estén las siguientes lineas y descomentar las lineas 1 y 2 y comentar la 3.<br />
<em> </em></p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">&lt;em&gt;<span style="color: #adadad; font-style: italic;">#ScriptAlias /php/ &quot;C:/xampp/php/&quot;</span>
<span style="color: #adadad; font-style: italic;">#Action application/x-httpd-php &quot;/php/php-cgi.exe&quot;</span>
<span style="color: #00007f;">LoadModule</span> php5_module <span style="color: #7f007f;">&quot;C:/xampp/apache/bin/php5apache2.dll&quot;</span>
<span style="color: #00007f;">AddType</span> application/x-httpd-php-source .phps&lt;/em&gt;</pre></div></div>

<p><em> </em></li>
<li>Ir a <em> </em><strong>C:\xampp\apache\conf/httpd.conf </strong>y buscar<strong> </strong><em>&lt;Directory /&gt; </em>y dejarlo como sigue:<em><br />
</em><em> </em></p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">&lt;em&gt;Options <span style="color: #0000ff;">FollowSymLinks</span>
<span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">None</span>
<span style="color: #adadad; font-style: italic;">#Order deny,allow</span>
<span style="color: #adadad; font-style: italic;">#Deny from all</span>
&lt;/em&gt;</pre></div></div>

<p><em> </em><br />
<em> </em></li>
</ol>
<p>Ahora si pueden reiniciar el Apache, algo que pude notar es que el tiempo de respuesta es algo lento, si alguien puede mejorarlo que me lo notifique, no sé si es la mejor manera de comunicarlo con PHP en windows, pero eso ya es cuestion de cada quien.</p>
<p><span id="more-114"></span></p>
<p><strong>Codigo Arduino</strong></p>
<p>He tomado el codigo prestado del proyecto de <a href="http://www.j4mie.org/2008/02/15/how-to-make-a-physical-gmail-notifier/">GMAIL_NOTIFIER_LAMP</a> que si la placa recibe el valor "M" enciende el led si recibe "N" lo apaga:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> outPin <span style="color: #339933;">=</span> <span style="color: #0000dd;">13</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Especificamos el pin de salida</span>
<span style="color: #993333;">int</span> mail <span style="color: #339933;">=</span> LOW<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Is there new mail?</span>
<span style="color: #993333;">int</span> val<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Value read from the serial port</span>
&nbsp;
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 pinMode<span style="color: #009900;">&#40;</span>outPin<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// sets the digital pin as output</span>
 Serial.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">19200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 Serial.<span style="color: #202020;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// Read from serial port</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>Serial.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
  val <span style="color: #339933;">=</span> Serial.<span style="color: #202020;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>val <span style="color: #339933;">==</span> <span style="color: #ff0000;">'M'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  mail <span style="color: #339933;">=</span> HIGH<span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>val <span style="color: #339933;">==</span> <span style="color: #ff0000;">'N'</span><span style="color: #009900;">&#41;</span> mail <span style="color: #339933;">=</span> LOW<span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Set the status of the output pin</span>
 digitalWrite<span style="color: #009900;">&#40;</span>outPin<span style="color: #339933;">,</span> mail<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>El Codigo PHP para encendido pueden usar el de ejemplo de PHPSerial, el que lleva por nombre sms_list.php solo recuerden modificar por su puerto COM en mi caso es el COM4 y los baud a 19200 en caso de ser USB.</p>
<p>Suerte!! Cualquier problema lo publican en los comentarios</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=2024186&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=2024186&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/2024186?pg=embed&amp;sec=2024186">Arduino</a> from <a href="http://vimeo.com/user339787?pg=embed&amp;sec=2024186">Punksolid</a> on <a href="http://vimeo.com?pg=embed&amp;sec=2024186">Vimeo</a>.</p>
<h3>Actualización!! (22/Nov/09)</h3>
<p><em>Este articulo fue escrito hace tiempo,  creo que ya cambió la version de <strong>XAMPP </strong>con la que fue probado, e incluso ya salió una nueva version de PHP_Serial en la que ya no se ocupa el modo CGI, segun lo leido en los comentarios, este articulo parece ya no funcionar.</em></p>
<h3>Referencia</h3>
<p><a href="http://www.easyvitools.com/phpserial/php_ser_reference.html">Instrucciones de Instalación y API de PHP Serials (En Ingles)</a></p>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.punksolid.com/conectar-la-placa-arduino-con-php-a-travez-de-php-serial/2008/&via=Punksolid&text=Conectar la placa Arduino con PHP a travez de PHP Serial &related=José Palazuelos:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.punksolid.com/conectar-la-placa-arduino-con-php-a-travez-de-php-serial/2008/&via=Punksolid&text=Conectar la placa Arduino con PHP a travez de PHP Serial &related=José Palazuelos:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.punksolid.com/conectar-la-placa-arduino-con-php-a-travez-de-php-serial/2008/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>Arduino y PHP en Windows</title>
		<link>http://www.punksolid.com/arduino-y-php-en-windows/2008/</link>
		<comments>http://www.punksolid.com/arduino-y-php-en-windows/2008/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 06:57:48 +0000</pubDate>
		<dc:creator>Punksolid</dc:creator>
				<category><![CDATA[programación]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.punksolid.com/?p=110</guid>
		<description><![CDATA[Se me hace raro que en la web oficial de Arduino no venga como conectar la placa Arduino + PHP de manera directa, hay unos métodos a través de proxys o cosas similares, el caso es que lo he logrado implementando la extensión PHPSerials que descargué desde http://www.easyvitools.com/phpserial/index.html, son pocas pero suficientes funciones que permiten [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignright" style="width: 208px"><img title="Arduino" src="http://arduino.cc/en/uploads/Main/arduino316.jpg" alt="Foto por Nicholas Zambetti" width="198" height="137" /><img title="Xampp" src="http://janckos.files.wordpress.com/2008/04/xampp_logo.jpg" alt="" width="205" height="181" /><p class="wp-caption-text">Foto por Nicholas Zambetti</p></div>
<p>Se me hace raro que en la <a href="http://www.arduino.cc/playground/Main/InterfacingWithSoftware">web oficial de Arduino</a> no venga como conectar la placa Arduino + PHP de manera directa, hay unos métodos a través de proxys o cosas similares, el caso es que lo he logrado implementando la extensión PHPSerials que descargué desde <a href="http://www.easyvitools.com/phpserial/index.html">http://www.easyvitools.com/phpserial/index.html</a>, son pocas pero suficientes funciones que permiten leer y escribir sobre el puerto serial, bajo windows XP y sobre XAMPP con Arduino USB,los únicos problemas que noté fue la velocidad, y que al parecer la versión de la extensión es solo para estudiantes o algo similar.</p>
<p>Si no puedes lograr la conexion, comentalo y te respondo detalladamente.</p>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.punksolid.com/arduino-y-php-en-windows/2008/&via=Punksolid&text=Arduino y PHP en Windows&related=José Palazuelos:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.punksolid.com/arduino-y-php-en-windows/2008/&via=Punksolid&text=Arduino y PHP en Windows&related=José Palazuelos:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.punksolid.com/arduino-y-php-en-windows/2008/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

