Wednesday, October 29, 2008

AW: How do I query after baking?

That is how queries with pagination and conditions worked for me:
http://groups.google.ch/group/cake-php/msg/09277228f45365ac

Hope it helps!
Anja

-----Ursprüngliche Nachricht-----
Von: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] Im Auftrag von Jason Qualkenbush
Gesendet: Mittwoch, 29. Oktober 2008 16:38
An: CakePHP
Betreff: How do I query after baking?


I created the database, then the models. I tried out the scaffolding, and that worked great. Then I was able to "cake bake" to get controllers and views. Now I'm working on modifying this thing. I don't want to select all from the table, just items that don't have a comment.

<?php
class PatchesController extends AppController {

var $name = 'Patches';
var $helpers = array('Html', 'Form');

function index() {
$this->Patch->recursive = 0;
#$this->set('patches', $this->paginate());
$sql = "SELECT patches.* FROM patches,responses WHERE responses.patch_id <> patches.id";
$this->set('patches', $this->Patch->query($sql));
}

(The commented part is what bake gave me)

I tried doing the above, but I just get a blank page. I added "LIMIT 0, 30" to the query (because there are 3,000 rows) and just get an error. Is this a custom query? Do I need a custom query?

I keep searching for cakephp and query, but all I end up with is how to paginate a custom query. I just want to know how to do a query at all.

-Jason

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: