Hi,
I’m working on an app that is releasing shortly, and I need a way to easily convert all my current Active Record queries over to MySQL stored procedures. I’ve never used stored procs before, but from what I have read it looks easy enough. The trouble is, I’m currently coding everything using Yii’s AR (which is GREAT) but the stored procs are not done yet by our DBA. Is there an easy way (without breaking anything/doing much coding) to just override the “find” method for my models (and other methods)? I understand Yii does a bunch of DB stuff in the background, but I just need a way so I can implement stored procs WITHOUT re-coding all my find() calls and everything - I can do that, its fine, I’m just trying to find a way to limit coding because I need to get this thing working in a month.
Also, I’m assuming stored procs with yii are pretty simple? Something like User::model()->execute(‘stored proc’) ?
What I was thinking of doing was this:
Change all my Models from extending Yii’s Active Record, to extending my custom class which has its own “find” method (and other methods like “findAll”) that just executes the stored proc in the DB. I’m assuming all my code will work correctly with little fuss this way? Will I have to also override “setAttributes” method or is this done automatically ? Keep in mind… in the production product we cannot be using active record, as my DBA is convinced otherwise (although if you can offer some convincing reasons why AR may be comparable to stored procs I might be able to convince them otherwise).
Thank you,
Michael