2008-09-17 15 views

cevap

2

(Örnek 11.61. Parenthesizing Boole ifadeleri örneği)


// Build this query: 
// SELECT product_id, product_name, price 
// FROM "products" 
// WHERE (price < 100.00 OR price > 500.00) 
//  AND (product_name = 'Apple') 

$minimumPrice = 100; 
$maximumPrice = 500; 
$prod = 'Apple'; 

$select = $db->select() 
      ->from('products', 
        array('product_id', 'product_name', 'price')) 
      ->where("price < $minimumPrice OR price > $maximumPrice") 
      ->where('product_name = ?', $prod); 

0

yukarıdaki referans harika, ama ya dizelerle oynuyorsanız?

Burada olur

// Build this query: 
// SELECT product_id, product_name, price 
// FROM "products" 
// WHERE (product_name = 'Bananas' OR product_name = 'Apples') 
//  AND (price = 100) 

$name1 = 'Bananas'; 

$name2 = 'Apples'; 

$price = 100; 

$select = $db->select() 

->from('products', 
        array('product_id', 'product_name', 'price')) 

->where("product_name = '" . $name1 . "' OR product_name = '" . $name2 . "'") 

->where("price=?", $price); 

Bunu umut olur ... dizeleriyle Yukarıdaki örnek. Dizeleri düzgün çalışması için beni kandırmaya çalıştım.

Şerefe.

+0

Cevabınız için teşekkürler, minnettarım. –