Skip to content

Commit fff435c

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.5
Conflicts: psalm_autoload.php
2 parents 9954ccf + 45ce53b commit fff435c

File tree

9 files changed

+32
-13
lines changed

9 files changed

+32
-13
lines changed

psalm_autoload.php

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
$dirs = [
2727
'tests/_support/Controllers',
2828
'tests/_support/_controller',
29+
'tests/system/Config/fixtures',
2930
];
3031

3132
foreach ($dirs as $dir) {

user_guide_src/source/database/events.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ DBQuery
2121
This event is triggered whenever a new query has been run, whether successful or not. The only parameter is
2222
a :doc:`Query </database/queries>` instance of the current query. You could use this to display all queries
2323
in STDOUT, or logging to a file, or even creating tools to do automatic query analysis to help you spot
24-
potentially missing indexes, slow queries, etc. An example usage might be:
24+
potentially missing indexes, slow queries, etc.
25+
26+
An example usage might be:
2527

2628
.. literalinclude:: events/001.php
+15-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
<?php
22

33
// In app/Config/Events.php
4-
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
4+
5+
namespace Config;
6+
7+
use CodeIgniter\Events\Events;
8+
use CodeIgniter\Exceptions\FrameworkException;
9+
use CodeIgniter\HotReloader\HotReloader;
10+
11+
// ...
12+
13+
Events::on(
14+
'DBQuery',
15+
static function (\CodeIgniter\Database\Query $query) {
16+
log_message('info', (string) $query);
17+
}
18+
);

user_guide_src/source/database/results/003.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
$query = $db->query('SELECT * FROM users;');
44

5-
foreach ($query->getResult('User') as $user) {
6-
echo $user->name; // access attributes
5+
foreach ($query->getResult(\App\Entities\User::class) as $user) {
6+
echo $user->name; // access attributes
77
echo $user->reverseName(); // or methods defined on the 'User' class
88
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
$query = $db->query('SELECT * FROM users LIMIT 1;');
4-
$row = $query->getRow(0, 'User');
4+
$row = $query->getRow(0, \App\Entities\User::class);
55

6-
echo $row->name; // access attributes
6+
echo $row->name; // access attributes
77
echo $row->reverse_name(); // or methods defined on the 'User' class

user_guide_src/source/database/results/013.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<?php
22

3+
namespace App\Entities;
4+
35
class User
46
{
57
public $id;
68
public $email;
79
public $username;
810

9-
protected $last_login;
11+
protected $lastLogin;
1012

1113
public function lastLogin($format)
1214
{

user_guide_src/source/database/results/014.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
$query = $db->query('YOUR QUERY');
44

5-
$rows = $query->getCustomResultObject('User');
5+
$rows = $query->getCustomResultObject(\App\Entities\User::class);
66

77
foreach ($rows as $row) {
88
echo $row->id;
99
echo $row->email;
10-
echo $row->last_login('Y-m-d');
10+
echo $row->lastLogin('Y-m-d');
1111
}

user_guide_src/source/database/results/015.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
$query = $db->query('YOUR QUERY');
44

5-
$row = $query->getCustomRowObject(0, 'User');
5+
$row = $query->getCustomRowObject(0, \App\Entities\User::class);
66

77
if (isset($row)) {
8-
echo $row->email; // access attributes
9-
echo $row->last_login('Y-m-d'); // access class methods
8+
echo $row->email; // access attributes
9+
echo $row->lastLogin('Y-m-d'); // access class methods
1010
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<?php
22

3-
$row = $query->getCustomRowObject(0, 'User');
3+
$row = $query->getCustomRowObject(0, \App\Entities\User::class);

0 commit comments

Comments
 (0)