Hi all

I am create SQL over Doctrine 1.2:

$query = \Doctrine_Query::create();
$query->from('Zone object');
$query->innerJoin('object.Countries Countries');
$query->select('object.ID, object.Name, object.ZipPattern, 
Countries.ZipFrom');
$query->where('object.Shipping_ID = ?', $shippingID);
$query->andWhere('Countries.Country_ID = ?', $countryID);
$query->andWhere('CASE object.ZipPattern '
        . 'WHEN "s" THEN ? LIKE Countries.ZipFrom '
        . 'WHEN "n" THEN (? BETWEEN Countries.ZipFrom AND Countries.ZipTo) '
        . 'ELSE TRUE '
        . 'END', array($zip, $zip));
$query->orderBy('LENGTH(Countries.ZipFrom) DESC');

But if I am see to generated SQL, all columns in CASE function not replaced 
to real names in SQL server! Here is doctrine result over 
$query->getSqlQuery():

SELECT a.id AS a__id, a.name AS a__name, a.zippattern AS a__zippattern, 
a2.id AS a2__id, a2.zipfrom AS a2__zipfrom 
FROM zone a INNER JOIN zone_country a2 ON a.id = a2.shippingzone_id 
WHERE (a.shipping_id = ? AND a2.country_id = ? AND 
CASE object.ZipPattern WHEN "s" THEN ? LIKE Countries.ZipFrom WHEN "n" THEN 
(? BETWEEN Countries.ZipFrom AND Countries.ZipTo) ELSE TRUE END) 
ORDER BY LENGTH(a2.zipfrom) DESC

Where i'm making a mistake in creating sql?

Thank you for answer

Jaroslav


-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" 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 https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to