If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Generating CRUD Stored Procedures

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-14-10, 11:15
pinkfloyd43 pinkfloyd43 is offline
Registered User
 
Join Date: Dec 2010
Posts: 39
Generating CRUD Stored Procedures

Has anyone seen a tool for MYSql that generates stored procedures based on the database? Have not used MySQL that much and have found these tools to be helpful in generating the 'start' of stored procedures. I have a new applications that will have quite a few tables that will require this.

Thanks!
Reply With Quote
  #2 (permalink)  
Old 12-17-10, 13:35
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 623
Hi,

I have written a script in PHP which basically does what Crud does. It creates 4 stored procedures based on the primary key of the table in a database. If no primary key exists no stored procedures are created. The 4 stored procedures per table include one that perform a select on the entire table, another which selects using the primary key, another one which deletes based on the primary key and the last one which either updates or insert depending on whether the primary key exists.

This can be downloaded here
__________________
Ronan Cashell
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
  #3 (permalink)  
Old 12-18-10, 08:22
pinkfloyd43 pinkfloyd43 is offline
Registered User
 
Join Date: Dec 2010
Posts: 39
Generating CRUD Stored Procedures

Thanks for the input and I have downloaded the script. Now I just gotta figure out how to execute it. I am running a VM with TurnKeyLinux with the LAMP stack. I can access PHPMyAdmin, and other things but have no idea where to start.
Reply With Quote
  #4 (permalink)  
Old 12-18-10, 12:00
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 623
Hi,

basically it is a PHP script so this can be run from the command line using:

Code:
php phpCrud.php -u <username> -d <database>
There are additional parameters such as hostname, password and individual table.

It is not exactly a CRUD where it generates the CREATE table but reverse engineers the stored procedures based on the already existing tables in the database. I identify the primary key of the table and then make sure that access to the data is unique.

I have also created a mini screencast and have added this to the webpage where you can download the script.
__________________
Ronan Cashell
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
Reply

Tags
sp generation

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On