17 de noviembre de 2007

La nueva forma de hacer busquedas

Hoy tratando de ayudar a un usuario en el IRC, termine descubriendo existe una nueva forma de utilizar las funciones find, findAll y findCount. Resulta que buscando mas flexibilidad para un futuro (palabras del mismo gwoo :) ) estas llamadas han sido cambiadas y ahora todas se hacen con la funcion find, donde se aclara cual de los 3 tipos es:


"count"

Busca el numero de filas que cumplen la busqueda especificada. Ejemplo de uso:

Post->find('count', array('conditions' => array('Post.comments_count' => '<>));

"first"

Busca la primera fila que cumple con la busqueda especificada. Ejemplo de uso:

Post->find('first', array('conditions' => array('Post.comments_count' => '<>), 'order' => 'Post.date ASC'));

"all"

Busca todas las filas que cumplen con la busqueda especifica. Ejemplo de uso:

Post->find('all', array('limit' => 10, 'order' => 'Post.date ASC'));


Y eso es todo. No es muy dificil de implementar, pero mas vale empezar a hacerlo cuanto antes, porque prontamente findAll y findCount van a ser metodos deprecados, y son algunos de los metodos que mas se usan, por lo tanto los mas dificiles de cambiar.

Saludos!

9 comentarios:

CresceNet dijo...
Este comentario ha sido eliminado por un administrador del blog.
Quest dijo...

buenos tips... pero creo que podrías dejar en claro que esos tips solo son para cakephp 1.2.x.

Saludos

mbavio dijo...

quest: Tienes razon, nunca aclare que este blog habla solo de la version 1.2... Por eso he cambiado el titulo del blog. Gracias por el recordatorio! Saludos.

Anónimo dijo...

Comunidad Orkut CakePHP en español

http://www.orkut.com/Community.aspx?cmm=33563127

Gente, les dejo una invitación a la nueva comunidad de CakePHP (entorno de desarrollo para PHP).

Pido disculpas a quienes no les interese.

Transplante de Cabelo dijo...

Hello. This post is likeable, and your blog is very interesting, congratulations :-). I will add in my blogroll =). If possible gives a last there on my blog, it is about the Transplante de Cabelo, I hope you enjoy. The address is http://transplante-de-cabelo.blogspot.com. A hug.

Dante dijo...

Hola , te falto el find("list") que se usa para cuando queres armar un dropdown en la vista:

$this->Modelo->find("list", array("fields"=>array("Modelo.id","Modelo.titulo")))


saludos!

Anónimo dijo...

miley cyrus nude [url=http://www.ipetitions.com/petition/mileycyrus]miley cyrus nude[/url] paris hilton nude [url=http://www.ipetitions.com/petition/parishilt]paris hilton nude[/url] kim kardashian nude [url=http://www.ipetitions.com/petition/kimkardashian45]kim kardashian nude[/url] kim kardashian nude [url=http://www.ipetitions.com/petition/celebst]kim kardashian nude[/url]

Anónimo dijo...

ruin in payment all to be conversant with this disencumber of grade [url=http://www.casinoapart.com]casino[/url] totting up at the greatest [url=http://www.casinoapart.com]online casino[/url] manual with 10's of late-model [url=http://www.casinoapart.com]online casinos[/url]. alternative to batch in [url=http://www.casinoapart.com/articles/play-roulette.html]roulette[/url], [url=http://www.casinoapart.com/articles/play-slots.html]slots[/url] and [url=http://www.casinoapart.com/articles/play-baccarat.html]baccarat[/url] at this [url=http://www.casinoapart.com/articles/no-deposit-casinos.html]no song far of people's whiz of casino[/url] , www.casinoapart.com
the finest [url=http://de.casinoapart.com]casino[/url] to UK, german and all to the world. so in end up the treatment of the pre-eminent [url=http://es.casinoapart.com]casino en linea[/url] ban us now.

Anónimo dijo...

A broad good physical condition program tailored to an own wishes undoubtedly pinpoint on anecdote or more clear-cut skills, and on age-[3] or health-related needs such as bone health.[4] Numberless sources[citation needed] also cite disposition, sexual and nervous health as an important part of whole fitness. This is again presented in textbooks as a triangle made up of three points, which reproduce physical, poignant, and psychotic fitness. Incarnate good shape can also hamper or handle numerous inveterate salubrity conditions brought on next to ailing lifestyle or aging.[5] Working pass‚ can also remedy people forty winks better. To stay healthy it is important to combat in actual activity.
Training

Certain or task-oriented [url=http://www.pella.pl]fitness[/url] is a living soul's gifts to complete in a determined vigour with a sound know-how: as case, sports or military service. Individual to training prepares athletes to put on stream in their sports.

Examples are:

400 m sprint: in a sprint the athlete necessity be trained to master-work anaerobically all the way through the race.
Marathon: in this specimen the athlete must be trained to work aerobically and their persistence requisite be built-up to a maximum.
Multifarious fire fighters and police officers subject oneself to typical fitness testing to determine if they are skilled of the physically exacting tasks required of the job.
Members of the Collective States Army and Army Nationalist Convoy have to be skilled to pass the Army Palpable Good shape Check-up (APFT).