Skip to content

Commit cda8c90

Browse files
committed
update various docs to use DB:expr() properly (refs #4617)
1 parent 6458ca7 commit cda8c90

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

classes/Kohana/Database.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,7 @@ public function quote($value)
485485
*
486486
* You can also use SQL methods within identifiers.
487487
*
488-
* // The value of "column" will be quoted
489-
* $column = $db->quote_column('COUNT("column")');
488+
* $column = $db->quote_column(DB::expr('COUNT(`column`)'));
490489
*
491490
* Objects passed to this function will be converted to strings.
492491
* [Database_Expression] objects will be compiled.

guide/database/examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ In this example, we loop through an array of whitelisted input fields and for ea
2525

2626
//copy the query & execute it
2727
$pagination_query = clone $query;
28-
$count = $pagination_query->select('COUNT("*") AS mycount')->execute()->get('mycount');
28+
$count = $pagination_query->select(DB::expr('COUNT(*)) AS mycount')->execute()->get('mycount');
2929

3030
//pass the total item count to Pagination
3131
$config = Kohana::$config->load('pagination');

guide/database/results.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ To return a non-associative array, leave `$key` as NULL and just pass a `$value`
7070

7171
Sometime you only want a single value from a query. The `get()` method returns the value of the named column from the current row. The second parameter, `$default`, is used to supply a default value when the result is NULL.
7272

73-
$total_users = DB::select(array('COUNT("username")', 'total_users'))->from('users')->execute()->get('total_users', 0);
73+
$total_users = DB::select(array(DB::expr('COUNT(`username`)'), 'total_users'))->from('users')->execute()->get('total_users', 0);
7474

7575
### Select - `cached()`
7676

0 commit comments

Comments
 (0)