Yii Framework Forum: MySQL Stored Procedures + Yii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

MySQL Stored Procedures + Yii Rate Topic: ***** 1 Votes

#1 User is offline   smclark89 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 119
  • Joined: 20-June 09
  • Location:NY, USA

Posted 29 June 2009 - 12:48 PM

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  :)
0

#2 User is offline   ricardograna 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 376
  • Joined: 31-March 09
  • Location:Manaus/AM - Brazil

Posted 29 June 2009 - 01:19 PM

Read about Yii Dao in the manual.
0

#3 User is offline   smclark89 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 119
  • Joined: 20-June 09
  • Location:NY, USA

Posted 29 June 2009 - 04:24 PM

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

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

#4 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,900
  • Joined: 04-October 08
  • Location:DC, USA

Posted 29 June 2009 - 04:38 PM

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

SP has its own benefit because it is more efficient.
0

#5 User is offline   smclark89 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 119
  • Joined: 20-June 09
  • Location:NY, USA

Posted 29 June 2009 - 07:51 PM

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.


0

#6 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,900
  • Joined: 04-October 08
  • Location:DC, USA

Posted 29 June 2009 - 08:52 PM

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.
0

#7 User is offline   ricardograna 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 376
  • Joined: 31-March 09
  • Location:Manaus/AM - Brazil

Posted 07 July 2009 - 07:41 AM

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)
0

#8 User is offline   Orijit 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 22-November 10

Posted 15 February 2011 - 01:02 AM

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.
0

#9 User is offline   ricardograna 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 376
  • Joined: 31-March 09
  • Location:Manaus/AM - Brazil

Posted 15 February 2011 - 05:25 PM

View PostOrijit, on 15 February 2011 - 01:02 AM, said:

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.
Yes, It Is!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users