Have you already populated the second table? In case not you could use a
hasOne or hasMany association, but you might have to change the layout of
the table itself.
Il giorno lunedì 25 febbraio 2013 14:10:45 UTC+1, bau ha scritto:
>
> I have these 2 tables: cd_biblio (which contains a list of books) and
> cd_bibliotem (which contains only the id of book and id of tag).
> I want to make a query where the user can choose also the tag of a book
> (in both tables the tags are numeric).
> In the cd_biblios controller I add:
>
> App::import('Model', 'CdBibliotem');$CdBibliotem = new CdBibliotem();
>
> I made the queries for cd_biblio table in this way:
>
> // General query$conditions = array(
> 'editore LIKE' => "%$e%",
> 'titolo LIKE' => "%$t%");
>
> And then for example:
>
> if (!$anno)
> $conditions[] = array('anno <=' => "$anno2"); if (!$anno2)
> $conditions[] = array('anno >=' => "$anno");
>
> Or:
>
> if (isset($menu)&&$menu!='')
> $conditions[]=array('classe LIKE' => "%$menu%");
>
> Now I need to do a inner join between these 2 tables to get all the books
> with a specific tags.
> I save tags in string, so I use:
> SELECT ... WHERE tags IN ('$tags');
> But I can't make a inner join using $conditions.
>
> I tried something like this:
>
> $tem = $CdBibliotem->query("SELECT * FROM cd_biblio INNER JOIN cd_bibliotem
> ON cd_biblio.codiceBiblio = cd_bibliotem.codiceBiblio WHERE codiceTematica IN
> ('$tematiche')"); $tem = Set::extract($tem,
> '{n}.cd_biblio');$conditions[]=array('cd_biblio.codiceBiblio IN (?)' =>
> '$tem');
>
> But it's not working. (I'm using ver 1.2)
>
>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.