<?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>Comentarios en: Autocompletar ajax</title>
	<atom:link href="http://cakephp.hospedaxes.com/autocompletar-ajax/feed" rel="self" type="application/rss+xml" />
	<link>http://cakephp.hospedaxes.com/autocompletar-ajax</link>
	<description>Blog sobre desarrollo web con cakephp en español por Hospedaxes</description>
	<lastBuildDate>Tue, 01 Dec 2009 08:26:32 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Por: bernal</title>
		<link>http://cakephp.hospedaxes.com/autocompletar-ajax/comment-page-1#comment-74</link>
		<dc:creator>bernal</dc:creator>
		<pubDate>Mon, 16 Feb 2009 10:05:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.hospedaxes.com/blog-cakephp/?p=10#comment-74</guid>
		<description>Me alegro de que hayas solucionado el problema, a mi no se me ocurría donde podía estar el fallo. De todas formas, que no funcione set::combine es muy raro, a nosotros nos funciona perfectamente, igual es debido a que utilizas una versión del cakephp 1.2, que no es la final y tenían algún bug con esa clase, aunque me parece bastante raro.

Un saludo y muchas gracias por visitarnos.</description>
		<content:encoded><![CDATA[<p>Me alegro de que hayas solucionado el problema, a mi no se me ocurría donde podía estar el fallo. De todas formas, que no funcione set::combine es muy raro, a nosotros nos funciona perfectamente, igual es debido a que utilizas una versión del cakephp 1.2, que no es la final y tenían algún bug con esa clase, aunque me parece bastante raro.</p>
<p>Un saludo y muchas gracias por visitarnos.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Nelli</title>
		<link>http://cakephp.hospedaxes.com/autocompletar-ajax/comment-page-1#comment-73</link>
		<dc:creator>Nelli</dc:creator>
		<pubDate>Mon, 16 Feb 2009 10:02:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.hospedaxes.com/blog-cakephp/?p=10#comment-73</guid>
		<description>Hola bernal,

Como no funcciona con Set::combine al final he encontrado el modo de hacerlo a mano. O sea que gererar array a mano: 

function autocomplete_loc()  {

	$str = trim($this-&gt;data[&#039;Empresa&#039;][&#039;localidad&#039;]);
	$str = str_replace(&quot;á&quot;,&quot;a&quot;,$str);
	$str = str_replace(&quot;é&quot;,&quot;e&quot;,$str);
	$str = str_replace(&quot;í&quot;,&quot;i&quot;,$str);
	$str = str_replace(&quot;ó&quot;,&quot;o&quot;,$str);
	$str = str_replace(&quot;ú&quot;,&quot;u&quot;,$str);
	$str = str_replace(&quot;Á&quot;,&quot;A&quot;,$str);
	$str = str_replace(&quot;É&quot;,&quot;E&quot;,$str);
	$str = str_replace(&quot;Í&quot;,&quot;I&quot;,$str);
	$str = str_replace(&quot;Ó&quot;,&quot;O&quot;,$str);
	$str = str_replace(&quot;Ú&quot;,&quot;U&quot;,$str);
	$str = str_replace(&quot;Ñ&quot;,&quot;ñ&quot;,$str);

$condicion = &quot;REPLACE (REPLACE( REPLACE( REPLACE( REPLACE( REPLACE ( Localidade.nombre,&#039;á&#039;,&#039;a&#039;), &#039;é&#039;,&#039;e&#039;),&#039;í&#039;,&#039;i&#039;),&#039;ó&#039;,&#039;o&#039;),&#039;ú&#039;,&#039;u&#039;),&#039;Ñ&#039;,&#039;ñ&#039;) LIKE &#039;$str%&#039;&quot;;
$localidades1=$this-&gt;Localidade-&gt;findAll($condicion,array(&#039;Localidade.nombre&#039;),&#039;Localidade.nombre&#039;);

foreach($localidades1 as $key=&gt;$value)
{

	foreach($value as $k=&gt;$v)
	{

			$loc[]=$v[&quot;nombre&quot;];
	}
}

$this-&gt;set(&#039;localidades&#039;, $loc);
$this-&gt;render(&#039;autocomplete_loc&#039;,&#039;ajax&#039;);

}


Así funcciona.

Muchas gracias por todo.
Saludos</description>
		<content:encoded><![CDATA[<p>Hola bernal,</p>
<p>Como no funcciona con Set::combine al final he encontrado el modo de hacerlo a mano. O sea que gererar array a mano: </p>
<p>function autocomplete_loc()  {</p>
<p>	$str = trim($this-&gt;data['Empresa']['localidad']);<br />
	$str = str_replace(&#8221;á&#8221;,&#8221;a&#8221;,$str);<br />
	$str = str_replace(&#8221;é&#8221;,&#8221;e&#8221;,$str);<br />
	$str = str_replace(&#8221;í&#8221;,&#8221;i&#8221;,$str);<br />
	$str = str_replace(&#8221;ó&#8221;,&#8221;o&#8221;,$str);<br />
	$str = str_replace(&#8221;ú&#8221;,&#8221;u&#8221;,$str);<br />
	$str = str_replace(&#8221;Á&#8221;,&#8221;A&#8221;,$str);<br />
	$str = str_replace(&#8221;É&#8221;,&#8221;E&#8221;,$str);<br />
	$str = str_replace(&#8221;Í&#8221;,&#8221;I&#8221;,$str);<br />
	$str = str_replace(&#8221;Ó&#8221;,&#8221;O&#8221;,$str);<br />
	$str = str_replace(&#8221;Ú&#8221;,&#8221;U&#8221;,$str);<br />
	$str = str_replace(&#8221;Ñ&#8221;,&#8221;ñ&#8221;,$str);</p>
<p>$condicion = &#8220;REPLACE (REPLACE( REPLACE( REPLACE( REPLACE( REPLACE ( Localidade.nombre,&#8217;á&#8217;,'a&#8217;), &#8216;é&#8217;,'e&#8217;),&#8217;í&#8217;,'i&#8217;),&#8217;ó&#8217;,'o&#8217;),&#8217;ú&#8217;,'u&#8217;),&#8217;Ñ&#8217;,'ñ&#8217;) LIKE &#8216;$str%&#8217;&#8221;;<br />
$localidades1=$this-&gt;Localidade-&gt;findAll($condicion,array(&#8217;Localidade.nombre&#8217;),&#8217;Localidade.nombre&#8217;);</p>
<p>foreach($localidades1 as $key=&gt;$value)<br />
{</p>
<p>	foreach($value as $k=&gt;$v)<br />
	{</p>
<p>			$loc[]=$v["nombre"];<br />
	}<br />
}</p>
<p>$this-&gt;set(&#8217;localidades&#8217;, $loc);<br />
$this-&gt;render(&#8217;autocomplete_loc&#8217;,'ajax&#8217;);</p>
<p>}</p>
<p>Así funcciona.</p>
<p>Muchas gracias por todo.<br />
Saludos</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Nelli</title>
		<link>http://cakephp.hospedaxes.com/autocompletar-ajax/comment-page-1#comment-70</link>
		<dc:creator>Nelli</dc:creator>
		<pubDate>Fri, 13 Feb 2009 13:46:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.hospedaxes.com/blog-cakephp/?p=10#comment-70</guid>
		<description>He probado generar array localidades sin usar Set::combine, porque allí es donde fallaba. 

Entonces ahora creo un array $loc donde este el listado de localidades (el resultado de la búsqueda). 

Resulta que las busca bien , pero no sé porque, en el listado muestra solo la primera letra. O sea que cuando hago 
$loc[]=$v2[&quot;nombre&quot;]; 
asigna solo la primera letra. Sabes porque pasa eso?
Aquí está el codigo.
Gracias


$condicion = &quot;REPLACE (REPLACE( REPLACE( REPLACE( REPLACE( REPLACE ( Localidade.nombre,&#039;á&#039;,&#039;a&#039;), &#039;é&#039;,&#039;e&#039;),&#039;í&#039;,&#039;i&#039;),&#039;ó&#039;,&#039;o&#039;),&#039;ú&#039;,&#039;u&#039;),&#039;Ñ&#039;,&#039;ñ&#039;) LIKE &#039;$str%&#039;&quot;;
$localidades1=$this-&gt;Localidade-&gt;findAll($condicion,array(&#039;Localidade.nombre&#039;),&#039;Localidade.nombre&#039;);

foreach($localidades1 as $key=&gt;$value)
{

	foreach($value as $k=&gt;$v)
	{
		foreach($v as $k2=&gt;$v2)
		{
			$loc[]=$v2[&quot;nombre&quot;];
		}
	}
}

$this-&gt;set(&#039;localidades&#039;, $loc);
$this-&gt;render(&#039;autocomplete_loc&#039;,&#039;ajax&#039;);</description>
		<content:encoded><![CDATA[<p>He probado generar array localidades sin usar Set::combine, porque allí es donde fallaba. </p>
<p>Entonces ahora creo un array $loc donde este el listado de localidades (el resultado de la búsqueda). </p>
<p>Resulta que las busca bien , pero no sé porque, en el listado muestra solo la primera letra. O sea que cuando hago<br />
$loc[]=$v2["nombre"];<br />
asigna solo la primera letra. Sabes porque pasa eso?<br />
Aquí está el codigo.<br />
Gracias</p>
<p>$condicion = &#8220;REPLACE (REPLACE( REPLACE( REPLACE( REPLACE( REPLACE ( Localidade.nombre,&#8217;á&#8217;,'a&#8217;), &#8216;é&#8217;,'e&#8217;),&#8217;í&#8217;,'i&#8217;),&#8217;ó&#8217;,'o&#8217;),&#8217;ú&#8217;,'u&#8217;),&#8217;Ñ&#8217;,'ñ&#8217;) LIKE &#8216;$str%&#8217;&#8221;;<br />
$localidades1=$this-&gt;Localidade-&gt;findAll($condicion,array(&#8217;Localidade.nombre&#8217;),&#8217;Localidade.nombre&#8217;);</p>
<p>foreach($localidades1 as $key=&gt;$value)<br />
{</p>
<p>	foreach($value as $k=&gt;$v)<br />
	{<br />
		foreach($v as $k2=&gt;$v2)<br />
		{<br />
			$loc[]=$v2["nombre"];<br />
		}<br />
	}<br />
}</p>
<p>$this-&gt;set(&#8217;localidades&#8217;, $loc);<br />
$this-&gt;render(&#8217;autocomplete_loc&#8217;,'ajax&#8217;);</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: bernal</title>
		<link>http://cakephp.hospedaxes.com/autocompletar-ajax/comment-page-1#comment-69</link>
		<dc:creator>bernal</dc:creator>
		<pubDate>Fri, 13 Feb 2009 13:15:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.hospedaxes.com/blog-cakephp/?p=10#comment-69</guid>
		<description>No se me ocurre qué decirte. La única idea que tengo es que me mandes un enlace del ejemplo que estás haciendo o el código de la aplicación para intentar buscar el error.</description>
		<content:encoded><![CDATA[<p>No se me ocurre qué decirte. La única idea que tengo es que me mandes un enlace del ejemplo que estás haciendo o el código de la aplicación para intentar buscar el error.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Nelli</title>
		<link>http://cakephp.hospedaxes.com/autocompletar-ajax/comment-page-1#comment-68</link>
		<dc:creator>Nelli</dc:creator>
		<pubDate>Fri, 13 Feb 2009 13:03:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.hospedaxes.com/blog-cakephp/?p=10#comment-68</guid>
		<description>He probado y no funcciona, $localidades no tiene valor.
Uso Cakephp 1.2</description>
		<content:encoded><![CDATA[<p>He probado y no funcciona, $localidades no tiene valor.<br />
Uso Cakephp 1.2</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: bernal</title>
		<link>http://cakephp.hospedaxes.com/autocompletar-ajax/comment-page-1#comment-67</link>
		<dc:creator>bernal</dc:creator>
		<pubDate>Fri, 13 Feb 2009 12:12:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.hospedaxes.com/blog-cakephp/?p=10#comment-67</guid>
		<description>Prueba a cambiar la línea:
$this-&gt;set(’localidades’, set::combine($this-&gt;Localidade-&gt;findAll($condicion,array(’Localidade.nombre’,’Localidade.id’),’Localidade.nombre’), “{n}.Localidade.id”,”{n}.Localidade.nombre”));

Por:
$this-&gt;set(&#039;localidades&#039;, Set::combine($this-&gt;Localidade-&gt;find(&#039;all&#039;,array(&#039;conditions&#039;=&gt;$condicion,&#039;fields&#039;=&gt;array(&#039;Localidade.nombre&#039;,&#039;Localidade.id&#039;),&#039;order&#039;=&gt;&#039;Localidade.nombre DESC&#039;)), &quot;{n}.Localidade.id&quot;,&quot;{n}.Localidade.nombre&quot;));

No entiendo muy bien porqué falla, está haciendo bien la consulta, pero está generando mal el array de localidades.

¿Qué versión de cakephp estás usando?</description>
		<content:encoded><![CDATA[<p>Prueba a cambiar la línea:<br />
$this->set(’localidades’, set::combine($this->Localidade->findAll($condicion,array(’Localidade.nombre’,’Localidade.id’),’Localidade.nombre’), “{n}.Localidade.id”,”{n}.Localidade.nombre”));</p>
<p>Por:<br />
$this->set(&#8217;localidades&#8217;, Set::combine($this->Localidade->find(&#8217;all&#8217;,array(&#8217;conditions&#8217;=>$condicion,&#8217;fields&#8217;=>array(&#8217;Localidade.nombre&#8217;,'Localidade.id&#8217;),&#8217;order&#8217;=>&#8217;Localidade.nombre DESC&#8217;)), &#8220;{n}.Localidade.id&#8221;,&#8221;{n}.Localidade.nombre&#8221;));</p>
<p>No entiendo muy bien porqué falla, está haciendo bien la consulta, pero está generando mal el array de localidades.</p>
<p>¿Qué versión de cakephp estás usando?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Nelli</title>
		<link>http://cakephp.hospedaxes.com/autocompletar-ajax/comment-page-1#comment-66</link>
		<dc:creator>Nelli</dc:creator>
		<pubDate>Fri, 13 Feb 2009 11:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.hospedaxes.com/blog-cakephp/?p=10#comment-66</guid>
		<description>dos columnas perdon!</description>
		<content:encoded><![CDATA[<p>dos columnas perdon!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Nelli</title>
		<link>http://cakephp.hospedaxes.com/autocompletar-ajax/comment-page-1#comment-65</link>
		<dc:creator>Nelli</dc:creator>
		<pubDate>Fri, 13 Feb 2009 11:57:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.hospedaxes.com/blog-cakephp/?p=10#comment-65</guid>
		<description>CREATE TABLE IF NOT EXISTS `localidades` (
  `id` int(11) NOT NULL auto_increment,
  `provincia_id` int(11) NOT NULL,
  `nombre` varchar(255) character set utf8 collate utf8_spanish_ci NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=8123 ;


pero he probado tambien con dos tablas: (&#039;id&#039;, &#039;nombre&#039;)</description>
		<content:encoded><![CDATA[<p>CREATE TABLE IF NOT EXISTS `localidades` (<br />
  `id` int(11) NOT NULL auto_increment,<br />
  `provincia_id` int(11) NOT NULL,<br />
  `nombre` varchar(255) character set utf8 collate utf8_spanish_ci NOT NULL,<br />
  PRIMARY KEY  (`id`)<br />
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=8123 ;</p>
<p>pero he probado tambien con dos tablas: (&#8217;id&#8217;, &#8216;nombre&#8217;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: bernal</title>
		<link>http://cakephp.hospedaxes.com/autocompletar-ajax/comment-page-1#comment-64</link>
		<dc:creator>bernal</dc:creator>
		<pubDate>Fri, 13 Feb 2009 11:50:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.hospedaxes.com/blog-cakephp/?p=10#comment-64</guid>
		<description>Otra preguntilla, cuál es la estructura de la tabla localidades. Porque diría que no tiene la estructura que nosotros usamos habitualmente y por eso el error.</description>
		<content:encoded><![CDATA[<p>Otra preguntilla, cuál es la estructura de la tabla localidades. Porque diría que no tiene la estructura que nosotros usamos habitualmente y por eso el error.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Nelli</title>
		<link>http://cakephp.hospedaxes.com/autocompletar-ajax/comment-page-1#comment-63</link>
		<dc:creator>Nelli</dc:creator>
		<pubDate>Fri, 13 Feb 2009 11:46:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.hospedaxes.com/blog-cakephp/?p=10#comment-63</guid>
		<description>Array([0]=&gt;Array([localidade]=&gt;Array([nombre]=&gt;Zaragoza)) [1]=&gt;Array([localidade]=&gt;Array([nombre]=&gt;Zarapicos))</description>
		<content:encoded><![CDATA[<p>Array([0]=&gt;Array([localidade]=&gt;Array([nombre]=&gt;Zaragoza)) [1]=&gt;Array([localidade]=&gt;Array([nombre]=&gt;Zarapicos))</p>
]]></content:encoded>
	</item>
</channel>
</rss>
