Integrates Doctrine with Yii applications
Resources ¶
Documentation ¶
http://code.google.com/p/doctrine-yii/w/list
Change Log ¶
May 28, 2009 ¶
- Initial release.
Integrates Doctrine with Yii applications
http://code.google.com/p/doctrine-yii/w/list
Solution
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));
Typo
Argh!
When I say "class Cliente" I meant "class User".
Btw, would it be possible to get a quick example of this working?
Usage
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.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.