your query does not create returned data in a form that CakePHP
understands to build it's data structure for. set debug level to 2 and
see what cake does
On 9/13/07, Chris <[EMAIL PROTECTED]> wrote:
>
> Hi Guys
>
> Sorry for the NEwbie question, I'm now 2hours into my CakePHP'ing.
> Anyway I would like to be able to perform a moderately complex SQL
> query on my database. But I'm taking little baby steps so am trying to
> just do an SQL LIKE search so my Controller looks like...
>
> function index()
> {
> $sql = 'SELECT * FROM posts WHERE title LIKE \'%widget%\' LIMIT 0, 30
> ';
> $this->set('posts', $this->Post->query($sql));
>
>
> }
>
> and my index view becomes...
>
> <?php foreach ($posts as $post): ?>
>
> <tr>
> <td><?php echo $post['Post']['id']; ?></td>
> <td>
> <?php echo $html->link($post['Post']['title'], "/posts/
> view/".$post['Post']['id']); ?>
> </td>
> <td><?php echo $post['Post']['username']; ?></td>
> </tr>
> <?php endforeach; ?>
>
> But I get this error coming up repeatedly,
>
> Undefined index: Post in /path/to/app/views/posts/index.thtml on line
> Number
>
>
> A simple findAll works...
> $this->set('posts', $this->Post->findAll(NULL,NULL,NULL,
> 10,NULL,NULL));
>
> Can anyone tell me what it is I'm doing wrong.
>
> Thanks in advance
>
> Chris
>
>
> >
>
--
(the old fart) the advice is free, the lack of crankiness will cost you
- its a fine line between a real question and an idiot
http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---