views:

192

answers:

1

Hi All,

Scenario :- I have to call MYSQL stored procedure from PHP and do some operations ( around 15 commands ) on the database

Problem :- I have to call stored procedure with 36 parameters. Lot of parameters . I don't think it is a good idea to pass these many individual parameters and even heard passing individul parameters increases network traffic.

Looking for :- I created a Data Object at PHP side and is there any way I can create similar kind of Object in MYSQL and pass this object as a parameter and extract the data from the object in MYSQL stored procedure

Thanks for your help Regards Kiran

+1  A: 

You can't pass objects between different programs. Only variables of scalar type can be passed.
You can use some serialization mechanism to convert your data array into string and back.

The easiest serialization mechanism is split-based, we all used in our first gueastbook script :)
There are also json encoding and PHP serialize() among widely used ones.

Col. Shrapnel
Thanks for quick response . I can serialize in PHP and again unserialize in PHP . But here I want to pass the serialized object as a parameter to MYSQL stored procedure and want to unserialize in MYSQL.
I know that you want to pass the serialized object as a parameter to MYSQL stored procedure. So, you have to invent some unserialize function for your stored procedure. Or google it. It can be not php serialize format though. I don't see much problem with passing all parameters though. You can iinsert it into temporary table and then select from within procedure
Col. Shrapnel
Thanks for throwing me the ideas . Now I am clear on this and going to invent some unserialize function for my stored procedure. I don't think It is a big deal now. Once again thanks for your advise