Wednesday, October 29, 2008

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: