Yii Framework Forum: Stored procs with Yii? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Stored procs with Yii? Rate Topic: -----

#1 User is offline   MichaelMackus 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 03-January 11

Posted 03 January 2011 - 02:25 PM

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
0

#2 User is offline   Trejder 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,197
  • Joined: 06-October 10
  • Location:Southern Poland

Posted 04 January 2011 - 03:40 AM

I'm having a similar problem. Can anyone help here, please?
Proud Cookbook author, though still learning powerful Yii! :] See my generic profile for more information. Cheers!
0

#3 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,353
  • Joined: 12-October 09
  • Location:Croatia

Posted 04 January 2011 - 03:47 AM

I haven't yet tried the stored procedure... but here are two interesting threads about them:

- http://www.yiiframew...hp?/topic/7001-
- http://www.yiiframew...p?/topic/13729-

Maybe you will get some idea from them
Find more about me.... btw. Do you know your WAN IP?
0

#4 User is offline   Trejder 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,197
  • Joined: 06-October 10
  • Location:Southern Poland

Posted 04 January 2011 - 04:27 AM

@mdomba: Thank you for useful links. Really good read. As always! :]

@MichaelMackus: I had some very basic attempts of using stored procedures in Yii, but when connecting to Oracle DB. There shouldn't be much difference between it and MySQL. But these are only beginners attempts, so I can't actually paste any code example here right now. I'm in the same situation as you are right now, I'm waiting for my DBA to finish stored procedures to start using it. If I get to some interesting conclusions, I'll for sure post here.
Proud Cookbook author, though still learning powerful Yii! :] See my generic profile for more information. Cheers!
0

#5 User is offline   MichaelMackus 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 03-January 11

Posted 04 January 2011 - 12:11 PM

@mdomba: Thank you for the constructive posts, I scanned through them and I'm sure I can make use of them.

@Trejder: Thanks, and I will definitely post my results as well. This is my first time working with Yii so I'm sure this will be interesting ;)
0

#6 User is offline   DigitalAlien 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 18-December 12

Posted 06 February 2013 - 04:47 PM

I realize this thread is old, but you said you would post your results, that was two years ago :) If you solved your issue could you share your results?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

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