Révision 4444412d
Ajouté par Julien Enselme il y a environ 10 ans
drupal7/includes/database/database.inc | ||
---|---|---|
28 | 28 |
* Most Drupal database SELECT queries are performed by a call to db_query() or |
29 | 29 |
* db_query_range(). Module authors should also consider using the PagerDefault |
30 | 30 |
* Extender for queries that return results that need to be presented on |
31 |
* multiple pages, and the Tablesort Extender for generating appropriate queries |
|
32 |
* for sortable tables. |
|
31 |
* multiple pages (see https://drupal.org/node/508796), and the TableSort |
|
32 |
* Extender for generating appropriate queries for sortable tables |
|
33 |
* (see https://drupal.org/node/1848372). |
|
33 | 34 |
* |
34 | 35 |
* For example, one might wish to return a list of the most recent 10 nodes |
35 | 36 |
* authored by a given user. Instead of directly issuing the SQL query |
36 | 37 |
* @code |
37 |
* SELECT n.nid, n.title, n.created FROM node n WHERE n.uid = $uid LIMIT 0, 10; |
|
38 |
* SELECT n.nid, n.title, n.created FROM node n WHERE n.uid = $uid |
|
39 |
* ORDER BY n.created DESC LIMIT 0, 10; |
|
38 | 40 |
* @endcode |
39 | 41 |
* one would instead call the Drupal functions: |
40 | 42 |
* @code |
41 | 43 |
* $result = db_query_range('SELECT n.nid, n.title, n.created |
42 |
* FROM {node} n WHERE n.uid = :uid', 0, 10, array(':uid' => $uid)); |
|
44 |
* FROM {node} n WHERE n.uid = :uid |
|
45 |
* ORDER BY n.created DESC', 0, 10, array(':uid' => $uid)); |
|
43 | 46 |
* foreach ($result as $record) { |
44 | 47 |
* // Perform operations on $record->title, etc. here. |
45 | 48 |
* } |
... | ... | |
2380 | 2383 |
} |
2381 | 2384 |
|
2382 | 2385 |
/** |
2383 |
* Executes a query string and saves the result set to a temporary table. |
|
2386 |
* Executes a SELECT query string and saves the result set to a temporary table.
|
|
2384 | 2387 |
* |
2385 | 2388 |
* The execution of the query string happens against the active database. |
2386 | 2389 |
* |
2387 | 2390 |
* @param $query |
2388 |
* The prepared statement query to run. Although it will accept both named and
|
|
2389 |
* unnamed placeholders, named placeholders are strongly preferred as they are
|
|
2390 |
* more self-documenting. |
|
2391 |
* The prepared SELECT statement query to run. Although it will accept both
|
|
2392 |
* named and unnamed placeholders, named placeholders are strongly preferred
|
|
2393 |
* as they are more self-documenting.
|
|
2391 | 2394 |
* @param $args |
2392 | 2395 |
* An array of values to substitute into the query. If the query uses named |
2393 | 2396 |
* placeholders, this is an associative array in any order. If the query uses |
Formats disponibles : Unified diff
Update drupal 7.27 -> 7.28