开发者

Passing object from PHP to Mysql Stored procedure

开发者 https://www.devze.com 2022-12-24 13:18 出处:网络
Scenario :- I have to call MYSQL stored procedure from PHP and do some operations (around 15 commands) on the database.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号