Passing object from PHP to Mysql Stored procedure
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 individual 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开发者_C百科 MYSQL stored procedure
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.
精彩评论