Home  >  Article  >  Backend Development  >  怎么查看android回传给php-server(依托discuz的接口)参数后执行的sql语句

怎么查看android回传给php-server(依托discuz的接口)参数后执行的sql语句

WBOY
WBOYOriginal
2016-06-13 12:04:41887browse

如何查看android回传给php-server(依托discuz的接口)参数后执行的sql语句
项目配置描述如下:
服务器端:discuz,正在调试连接android的服务器端接口(用来接收android端发送过来的请求)
客户端:Android4.4

问题流程描述如下:
android端在论坛发帖后,使用httppost封装参数,通过httpclient发送到php端的相关url;在php端执行相关的sql操作,通过mysql_query返回true或者false给android端。

问题描述如下:
现在在android端得到发帖返回的结果是{"result":"post failed"} ,(ˇ?ˇ) 想到可能是php端在执行sql操作时发生了错误,想查看php端执行的sql语句。由于我的php接口是依托于discuz的,如果单独将该接口通过zend studio部署到Apache的htdocs,我试过,没有部署成功,无法接收android端发送的参数

想咨询下大家,
1)有没有可能将此接口部署到apache以接收android端的数据(win7,apache,mysql,php5.25,zend studio 10.0)
2)如果没有,怎么调试android端传送给php服务端的参数;现在主要想查看回传给php服务端后,执行的sql语句。

先谢谢大家了
------解决方案--------------------
这个问题刚好我也遇到了,解决办法如下
找到:\source\class\discuz\discuz_error.php,并打开
搜索:show_error($type, $errormsg, $phpmsg = '', $typemsg = '')
在show_error函数下面,用file_put_contents函数将$errormsg打印到一个txt里面

public static function show_error($type, $errormsg, $phpmsg = '', $typemsg = '') {<br />		global $_G;<br />file_put_contents(DISCUZ_ROOT.'./appapi/log.txt',$errormsg.PHP_EOL,FILE_APPEND);<br />		ob_end_clean();<br />		$gzip = getglobal('gzipcompress');<br />		ob_start($gzip ? 'ob_gzhandler' : null);<br />//后面的就不复制了...<br /><br />}

缺点就是,discuz的所有sql错误都会记录在里面,当然一般discuz报的sql错误还是很少的
------解决方案--------------------
若你想和discuz的数据完美结合,并减少开发时间的话,建议你还是用discuz已有的DB类和方法
我不知道zend 在哪里处理了sql,不过执行sql错误,你可以用mysql_error()获取错误信息,用file_put_contents输出到一个txt里面
------解决方案--------------------
把你接口的相关代码亮出来。
没代码怎么解决问题。。。
------解决方案--------------------
这个需要看你的接口了,能不能手工单独调试?
如果能,你只需要关心传送的参数
------解决方案--------------------
像你这样对发挥数据做了包装的系统,需要对客户端和服务端分开来调试

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:phpexcel出错Next article:php怎的显示mysql的warning信息