File tree Expand file tree Collapse file tree
user_guide_src/source/database/results Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 number Diff line number Diff line change 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
77echo $ row ->reverse_name (); // or methods defined on the 'User' class
Original file line number Diff line number Diff line change 11<?php
22
3+ namespace App \Entities ;
4+
35class 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 {
Original file line number Diff line number Diff line change 22
33$ query = $ db ->query ('YOUR QUERY ' );
44
5- $ rows = $ query ->getCustomResultObject (' User ' );
5+ $ rows = $ query ->getCustomResultObject (\ App \ Entities \ User::class );
66
77foreach ($ 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}
Original file line number Diff line number Diff line change 22
33$ query = $ db ->query ('YOUR QUERY ' );
44
5- $ row = $ query ->getCustomRowObject (0 , ' User ' );
5+ $ row = $ query ->getCustomRowObject (0 , \ App \ Entities \ User::class );
66
77if (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 number Diff line number Diff line change 11<?php
22
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