sclark
(Smclark89)
June 29, 2009, 5:48pm
1
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
rickgrana
(Ricardo Grana)
June 29, 2009, 6:19pm
2
Read about Yii Dao in the manual.
sclark
(Smclark89)
June 29, 2009, 9:24pm
3
I've done so, but couldn't find anything.
When I say stored procedure, I mean one that's actually stored in the database.
qiang
(Qiang Xue)
June 29, 2009, 9:38pm
4
What do you mean by "stored in Yii AR"?
SP has its own benefit because it is more efficient.
sclark
(Smclark89)
June 30, 2009, 12:51am
5
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 .
qiang
(Qiang Xue)
June 30, 2009, 1:52am
6
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.
rickgrana
(Ricardo Grana)
July 7, 2009, 12:41pm
7
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)
Orijit
(B Orijit)
February 15, 2011, 6:02am
8
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.
rickgrana
(Ricardo Grana)
February 15, 2011, 10:25pm
9
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.