Hey, after you implement doctrine inside yii, how will you use the Yii model scheme but with doctrine?
Right now you do:
User::model()->find(1)
While having User defined as 'class User extends CActiveRecord', right?
If i then change it to Doctrine, using 'class Cliente extends Doctrine_Record', will Yii accept it as its child? so i can do:
User::model()->find(1)
[code]
// test.php
// ...
$userTable = Doctrine::getTable('User');
$user = $userTable->find(1);
[/code]
Will assume I then have to use CFormModel as a class for all models I want to work with Yii functions, such as :
(class UserSearchForm extends CFormModel)
$form=new UserSearchForm; $form->attributes=$_POST['UserSearchForm'];
$listDB = $form->simpleSearch(); //my search function with Doctrine query inside it.
Total 3 comments
After a bit of testing stuff out I found that the best solution would probably be :
Adding this to the model (generated by doctrine) public static function model($className=CLASS) { return Doctrine::getTable($className); }
So you can then just do :
$user = User::model()->findOneByEmail($mail);
Instead of : $user = Doctrine::getTable('User')->findOneByEmail($mail);
This would be used to replicate the Yii AR implementation in models : $user=User::model()->find('LOWER(email)=?',array($mail));
Argh!
When I say "class Cliente" I meant "class User".
Btw, would it be possible to get a quick example of this working?
Hey, after you implement doctrine inside yii, how will you use the Yii model scheme but with doctrine?
Right now you do:
User::model()->find(1)
While having User defined as 'class User extends CActiveRecord', right?
If i then change it to Doctrine, using 'class Cliente extends Doctrine_Record', will Yii accept it as its child? so i can do:
User::model()->find(1)
[code]
// test.php
// ... $userTable = Doctrine::getTable('User');
$user = $userTable->find(1);
[/code]
Will assume I then have to use CFormModel as a class for all models I want to work with Yii functions, such as : (class UserSearchForm extends CFormModel) $form=new UserSearchForm; $form->attributes=$_POST['UserSearchForm'];
$listDB = $form->simpleSearch(); //my search function with Doctrine query inside it.
Leave a comment
Please login to leave your comment.