I have no idea :-(
$this->Gallery->findAll(
"Gallery.id = '$id'",
array('Gallery.name','Image.filename')
);
Doesn't work (returns FALSE), while
$this->Gallery->findAll(
"Gallery.id = '$id'"
);
and
$this->Gallery->findAll(
"Gallery.id = '$id'",
array('Gallery.name')
);
works fine.
The same is with:
$this->Gallery->read(
array('Gallery.name','Gallery.description','Image.filename'),
$id );
returns false while
$this->Gallery->read(
array('Gallery.name','Gallery.description'),
$id );
and
$this->Gallery->read(
null,
$id );
works OK.
Models are extremely simple:
class Gallery extends AppModel
{
var $name = 'Gallery';
var $hasMany = array('Image' => array('className' => 'Image'));
}
class Image extends AppModel
{
var $name = 'Image';
var $belongsTo = array('Gallery' => array('className' =>
'Gallery'));
var $hasMany = array('Comment' => array('className' =>
'Comment'));
}
On Feb 3, 1:49 am, "Grant Cox" <[EMAIL PROTECTED]> wrote:
> The problem is that "name" is ambiguous - do you mean the Gallery.name
> or the Image.name ?
>
> As a convention, you should prefix all your fields with the model
> name, so your query would be:
> $this->Gallery->findAll("Gallery.id = '$id'",
> array("Gallery.name","Gallery.description","Image.filename") );
>
> or even just
> $this->Gallery->read(
> array('Gallery.name','Gallery.description','Image.filename'),
>
> $id )
>
> as I assume your Gallery.id field is unique :)
>
> peper wrote:
> > Hi.
> > I'm new in CakePHP. My problem is:
> > I've got Gallery(id,name,description) and
> > Image(id,name,filename,gallery_id) models.
> > When I make:
> > $this->Gallery->findAll("id = '$id'");
>
> > I get a Gallery and related imges. Works fine. But I want only gallery
> > name, description images filename, so I do:
> > $this->Gallery->findAll("id = '$id'",
> > array("name","description","Image.filename")
> > );
>
> > and it returnes false :-(
>
> > What's wrong ?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---