Hi there,
Since my Gii tool is unable to generate model for my table, I have to write it myself. And either I’m doing something wrong with accessing such model or I made a mistake in declaring it.
I used existing, working model from another app and MySQL database and only changed table name and table columns names, so at least in theory there should be no error in model definition. At least in theory…
Once again I read through "Active Record: Reading Record" and used as simple approach as it can be, i.e.:
$users = Users::model()->findAll();
foreach($users as $user)
{
print_r($user);
}
I was supposing to see all my records in the table for which Users model was created (all my users) but instead of that I saw some garbage that looks like table schema or ActiveRecord definition:
994
I changed to DAO approach:
$sql = 'SELECT * FROM WWW_USERS';
$connection = Yii::app()->db;
$command = $connection->createCommand($sql);
$dataReader = $command->query();
$rows = $dataReader->readAll();
print_r($rows);
And immediately got supposed results - i.e. list of all records in DB table.
Has anyone got any idea, what am I doing wrong, that AR approach doesn’t seems to be working, while DAO works like a charm?