MySQL Stored Procedures + Yii

How would a stored procedure in MySQL work with Yii?

Would there be a benefit from having the stored procedure in MySQL rather than stored in Yii's AR?

If anybody has any suggestions, or could point me towards a resource (I couldn’t find any) that would be great  :)

Read about Yii Dao in the manual.

I've done so, but couldn't find anything.

When I say stored procedure, I mean one that's actually stored in the database.

What do you mean by "stored in Yii AR"?

SP has its own benefit because it is more efficient.

Quote

What do you mean by "stored in Yii AR"?

Good question. I thought I saw somewhere that the AR cached queries, or something happy happened with caching, but I was skimming.

Quote

SP has its own benefit because it is more efficient.

Which is why I’m considering switching that ugly query from my other thread (Making a component) to a SP, then calling it with Yii. Just wasn’t sure if Yii has any more magic to help with that or not  ;D.

Let DBMS do what it is capable of. Do not overuse AR. Otherwise you may end up spending a lot more time seeking solutions with AR while the solution may not be as good as using SP.

Quote

I've done so, but couldn't find anything.

Really not, but it´s a good place to begin.

Yii Dao allows you to use proper funcions and command from the database. Learn this is your first step.

The second step is learn how to use PDO to configure a call to stored procedures.

After this last step, you'll just have to map you SP call to Yii Dao.

Hope this can help (sorry, I know this steps just in theory, i haven't developed it yet, so I don't have code to show you)

I think sclark’s simple question was : Is there any notable performance benefits of SP to AR? That’s my question too.

sclark : I think what qiang means is we should give first pref. to SP.

I think Qiang means that you should not use AR for everything you want to do.

Use SP if you have complex statements to do. If not, I recommend AR. I’ve done a lot of complex queries and statements usign AR with good performance.