hi, i test this code with mysql 5.XX on debian sid but is not work becouse you give a alias on same table and sql engine make self join and returning always default lang.
i changed this query:
# $c->add(GeoI18nPeer::CULTURE, $culture);
$default_culture = sfConfig::get('sf_i18n_default_culture');
$subSelect = GeoI18nPeer::CULTURE." = CASE WHEN (SELECT count(i18n.ID) FROM
".GeoI18nPeer::TABLE_NAME." as i18n
WHERE i18n.CULTURE='".$culture."' AND i18n.ID = GeoPeer.ID) > 0 THEN
'".$culture."' ELSE '".$default_culture."' END";
$c->add(GeoI18nPeer::CULTURE, $subSelect, Criteria::CUSTOM)
i add XxxPeer on doSelectWithI18n method and its work, but this is very ugly
hack becouse sub select working for XxxPeer::TABLE_NAME this is mean total
row count in XxxPeer::TABLE_NAME + 1 query.
PS: just a mysql tested...
Pazartesi 30 Nisan 2007 tarihinde, Franke Gordon şunları yazmıştı:
> ok. i have now test it with:
> mysql: 5.0
> sqlite: 2.1
> postgres: 8.2
>
> So i can test it on Wednesday with a ms sql but i can test it with a oracle
> database.
>
> So have anybody access to a oracle db and can test it???
>
> SQL Query:
> SELECT table.ID, geo.IS_ACTIVE, geo_i18n.NAME, geo_i18n.ID,
> geo_i18n.CULTURE FROM geo, geo_i18n WHERE geo.IS_ACTIVE=1 AND
> geo_i18n.CULTURE = CASE WHEN (SELECT count(i18n.ID) FROM geo_i18n as i18n,
> geo_i18n as parent WHERE i18n.CULTURE='it' AND i18n.ID = parent.ID) > 0
> THEN it' ELSE 'en' END AND geo.ID=geo_i18n.ID
>
> PHP Code:
> # $c->add(GeoI18nPeer::CULTURE, $culture);
> $default_culture = sfConfig::get('sf_i18n_default_culture');
> $subSelect = GeoI18nPeer::CULTURE." = CASE WHEN (SELECT count(i18n.ID) FROM
> ".GeoI18nPeer::TABLE_NAME." as i18n, ".GeoI18nPeer::TABLE_NAME." as parent
> WHERE i18n.CULTURE='".$culture."' AND i18n.ID = parent.ID) > 0 THEN
> '".$culture."' ELSE '".$default_culture."' END";
> $c->add(GeoI18nPeer::CULTURE, $subSelect, Criteria::CUSTOM);
>
>
> greetings
> Gordon
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected] im Auftrag von Franke Gordon
> Gesendet: So 29.04.2007 21:00
> An: [email protected]
> Betreff: [symfony-devs] AW: [symfony-devs] Re: AW: [symfony-devs] Re: patch
> for i18n tables
>
> Ok. If i understand the documentation right it must work with that. Please
> test it.
>
> # $c->add(TableI18nPeer::CULTURE, $culture);
> $default_culture = sfConfig::get('sf_i18n_default_culture');
> $subSelect = TableI18nPeer::CULTURE." = CASE WHEN (SELECT i18n.ID FROM
> ".TableI18nPeer::TABLE_NAME." as i18n WHERE i18n.CULTURE='".$culture."' AND
> i18n.ID = ".TablePeer::ID.") THEN '".$culture."' ELSE
> '".$default_culture."')"; $c->add(TableI18nPeer::CULTURE, $subSelect,
> Criteria::CUSTOM);
>
>
> Thanks.
> gordon
>
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected] [mailto:[EMAIL PROTECTED]
> Im Auftrag von Timu EREN Gesendet: Sonntag, 29. April 2007 02:59
> An: [email protected]
> Betreff: [symfony-devs] Re: AW: [symfony-devs] Re: patch for i18n tables
>
> Hi,
>
> This is not work with pgsql
>
> Persembe 26 Nisan 2007 tarihinde, Franke Gordon sunlari yazmisti:
> > I have test it only with a mysql ;(
> >
> > My code:
> > # $c->add(TableI18nPeer::CULTURE, $culture);
> > $default_culture = sfConfig::get('sf_i18n_default_culture');
> > $subSelect = TableI18nPeer::CULTURE." = IF((SELECT i18n.ID FROM
> > ".TableI18nPeer::TABLE_NAME." as i18n WHERE
> > i18n.CULTURE='".$culture."' AND i18n.ID = ".TablePeer::ID."),
> > '".$culture."', '".$default_culture."')";
> > $c->add(TableI18nPeer::CULTURE, $subSelect, Criteria::CUSTOM);
> >
> >
> > greetings
> > Gordon
> >
> > -----Ursprüngliche Nachricht-----
> > Von: [email protected]
> > [mailto:[EMAIL PROTECTED]
> > Im Auftrag von Fabien POTENCIER Gesendet: Donnerstag, 26. April 2007
> > 10:12
> > An: [email protected]
> > Betreff: [symfony-devs] Re: patch for i18n tables
> >
> >
> > To be included, you need to have a patch that works with every db
> > supported by Propel and symfony.
> >
> > Fabien
> >
> > Franke Gordon wrote:
> > > Hello,
> > >
> > >
> > >
> > > many peopel hast he problem that he get a empty database result if
> > > no translation data fort he record exist. i have modify/add
> > > (doSelect|doSelectOne|retrieveByPk)WithI18n functions. It makes a
> > > subselect and check if the culture exist if not it use the default
> > > culture.
> > >
> > >
> > >
> > > So my questions:
> > >
> > > Can i add this to the propel generator files?
> > >
> > > And with a optional parameter or per default?
> > >
> > >
> > >
> > > What you think about that?
> > >
> > >
> > >
> > >
> > >
> > > greetings
> > >
> > > Gordon
>
> --
> Saygilar && Iyi çalismalar
> Timu EREN (a.k.a selam)
>
>
>
>
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups
> "symfony developers" 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/symfony-devs?hl=en
> -~----------~----~----~----~------~----~------~--~---
--
Saygılar && İyi çalışmalar
Timu EREN (a.k.a selam)
signature.asc
Description: This is a digitally signed message part.
