I’m attempting to do a simple AR findAll() like it’s done in the Phonebook demo:
return Contact::model()->findAll();
which returns:
Array
(
[0] => stdClass Object
(
[id] => 1
[name] => James Blake
[phone] => 123-123-1234
)
[1] => stdClass Object
(
[id] => 3
[name] => Thomas Maiden
[phone] => 567-567-5678
)
)
but with this:
$ftypes = Foodtypes::model()->findAll();
instead of getting the 5 records that are in the table, I’m getting an object of schema info on the table.
I’m a newbie to Yii (2 days), so hoping for someone to read this who experienced a similar result?
Thanks in advance, I’m dumbfounded
UPDATE: I attempted to perform the same query on a table with quite a few more records (~1000):
Restaurants::model()->findAll()
, and although I could understand if it took a little while, it actually became unresponsive, more than once. Sounds like a configuration/environment issue maybe? I’m working using the latest XAMPP, under Windows 7, fyi.
And not sure why this didn’t post to the Bug Discussion section, I meant to, my apologies.
UPDATE: Here’s my trace, the SQL statement looks just fine
15:45:28.794713 trace system.db.CDbCommand
Querying SQL: SHOW COLUMNS FROM `tbl_foodtypes`
in C:\xampp\htdocs\emenu.com\api\protected\models\Foodtypes.php (19)
in
C:\xampp\htdocs\emenu.com\api\protected\modules\ajax\controllers\MenuController.php
(24)
in C:\xampp\htdocs\emenu.com\api\index.php (13)
15:45:28.800051 trace system.db.CDbCommand
Querying SQL: SHOW CREATE TABLE `tbl_foodtypes`
in C:\xampp\htdocs\emenu.com\api\protected\models\Foodtypes.php (19)
in
C:\xampp\htdocs\emenu.com\api\protected\modules\ajax\controllers\MenuController.php
(24)
in C:\xampp\htdocs\emenu.com\api\index.php (13)
15:27:41.329886 trace system.db.ar.CActiveRecord
Foodtypes.findAll()
in
C:\xampp\htdocs\emenu.com\api\protected\modules\ajax\controllers\MenuController.php
(24)
in C:\xampp\htdocs\emenu.com\api\index.php (13)
15:27:41.331985 trace system.db.CDbCommand
Querying SQL: SELECT * FROM `tbl_foodtypes` `t`
in
C:\xampp\htdocs\emenu.com\api\protected\modules\ajax\controllers\MenuController.php
(24)
in C:\xampp\htdocs\emenu.com\api\index.php (13)
UPDATE: Just one last thing; I used Gii to create the AR Models. It must be working in my environment since the Phonebook demo works, so is it possibly a Gii Model Generation problem ?
2077