File tree Expand file tree Collapse file tree 6 files changed +8
-6
lines changed
user_guide_src/source/database/results Expand file tree Collapse file tree 6 files changed +8
-6
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
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 ;
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 ;
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
8
echo $ row ->email ; // access attributes
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