mysql 存储过程 的PHP调用

aquastar 2010-12-07 10:29:06
比如写一个存储过程User_getAll()主体内容为 select * from user
如何用PHP得到一个数组?
我这样试过,当然是不行的:

$res=mysql_fetch_row(mysql_query("call User_getAll()")) ;
print_r($res);


如果设置out的话,不会一个个字段的设置吧?
...全文
90 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
aquastar 2010-12-07
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 acmain_chm 的回复:]

你就把call User_getAll()当普通select 处理就行了,不过你要确定一下你的call User_getAll()是否返回了多个结果集。
[/Quote]

好像不行啊,直接给我一个 supplied argument is not a valid MySQL result resource 的错误
懒得去死 2010-12-07
  • 打赏
  • 举报
回复
用MYSQLI吧。
iihero 2010-12-07
  • 打赏
  • 举报
回复
[Quote=引用楼主 aquastar 的回复:]
比如写一个存储过程User_getAll()主体内容为 select * from user
如何用PHP得到一个数组?
我这样试过,当然是不行的:
PHP code

$res=mysql_fetch_row(mysql_query("call User_getAll()")) ;
print_r($res);



如果设置out的话,不会一个个字段……
[/Quote]
就得一个个设置。
ACMAIN_CHM 2010-12-07
  • 打赏
  • 举报
回复
你就把call User_getAll()当普通select 处理就行了,不过你要确定一下你的call User_getAll()是否返回了多个结果集。
aquastar 2010-12-07
  • 打赏
  • 举报
回复
http://goby2008.javaeye.com/blog/695549 恩,按这个做了,mysqli接口是可以的
aquastar 2010-12-07
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 iihero 的回复:]

引用楼主 aquastar 的回复:
比如写一个存储过程User_getAll()主体内容为 select * from user
如何用PHP得到一个数组?
我这样试过,当然是不行的:
PHP code

$res=mysql_fetch_row(mysql_query("call User_getAll()")) ;
print_r($res);



如果设置out的……
[/Quote]

就没办法返回一个数组吗?

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧