Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [ZendFramework]Zend_Db_Select where
nospor
post
Post #1





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




Chce uzyskac zapytanie (przykład z manuala):
  1. <?php
  2. //   SELECT product_id, product_name, price
  3. //   FROM "products"
  4. //   WHERE (price < 100.00 OR price > 500.00)
  5. //     AND (product_name = 'Apple')
  6.  
  7. $minimumPrice = 100;
  8. $maximumPrice = 500;
  9. $prod = 'Apple';
  10.  
  11. $select = $db->select()
  12.             ->from('products',
  13.                    array('product_id', 'product_name', 'price'))
  14.             ->where("price < $minimumPrice OR price > $maximumPrice")
  15.             ->where('product_name = ?', $prod);
  16. ?>

zastosowali: ->where("price < $minimumPrice OR price > $maximumPrice")
Chcialbym jednak uzyc bindowania i zrobic tak
  1. <?php
  2. ->where("price < ? OR price > ?", $minimumPrice, $maximumPrice);
  3. ?>

Oczywiscie to nie zadziala, bo where() przyjmuje tylko jedą wartosc do bindowania. W kodzie ani w dokumentacji nie znalazlem tego, a nie chce mi sie wierzyc by nie pomysleli o tym przy where()... Zapodanie tablicy wartosci tez nie dziala.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
ziqzaq
post
Post #2





Grupa: Zarejestrowani
Postów: 428
Pomógł: 128
Dołączył: 17.06.2007

Ostrzeżenie: (0%)
-----


Cytat
If you need to combine terms together using OR, use the orWhere() method. This method is used in the same way as the where() method, except that the term specified is preceded by OR, instead of AND.

Edit: źródło

Ten post edytował ziqzaq 19.02.2009, 09:49:21
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 7.10.2025 - 05:22