File tree Expand file tree Collapse file tree 6 files changed +13
-11
lines changed
user_guide_src/source/database/results Expand file tree Collapse file tree 6 files changed +13
-11
lines changed Original file line number Diff line number Diff line change 2
2
3
3
$ query = $ db ->query ('SELECT * FROM users; ' );
4
4
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
7
7
echo $ user ->reverseName (); // or methods defined on the 'User' class
8
8
}
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
3
$ query = $ db ->query ('SELECT * FROM users LIMIT 1; ' );
4
- $ row = $ query ->getRow (0 , ' User ' );
4
+ $ row = $ query ->getRow (0 , \ App \ Entities \ User::class );
5
5
6
- echo $ row ->name ; // access attributes
6
+ echo $ row ->name ; // access attributes
7
7
echo $ row ->reverse_name (); // or methods defined on the 'User' class
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ namespace App \Entities ;
4
+
3
5
class User
4
6
{
5
7
public $ id ;
6
8
public $ email ;
7
9
public $ username ;
8
10
9
- protected $ last_login ;
11
+ protected $ lastLogin ;
10
12
11
13
public function lastLogin ($ format )
12
14
{
Original file line number Diff line number Diff line change 2
2
3
3
$ query = $ db ->query ('YOUR QUERY ' );
4
4
5
- $ rows = $ query ->getCustomResultObject (' User ' );
5
+ $ rows = $ query ->getCustomResultObject (\ App \ Entities \ User::class );
6
6
7
7
foreach ($ rows as $ row ) {
8
8
echo $ row ->id ;
9
9
echo $ row ->email ;
10
- echo $ row ->last_login ('Y-m-d ' );
10
+ echo $ row ->lastLogin ('Y-m-d ' );
11
11
}
Original file line number Diff line number Diff line change 2
2
3
3
$ query = $ db ->query ('YOUR QUERY ' );
4
4
5
- $ row = $ query ->getCustomRowObject (0 , ' User ' );
5
+ $ row = $ query ->getCustomRowObject (0 , \ App \ Entities \ User::class );
6
6
7
7
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
10
10
}
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- $ row = $ query ->getCustomRowObject (0 , ' User ' );
3
+ $ row = $ query ->getCustomRowObject (0 , \ App \ Entities \ User::class );
You can’t perform that action at this time.
0 commit comments