用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1167|回复: 2
收起左侧

[HELP] 新人小白,CI后台如何写?

[复制链接]
发表于 2015-1-16 10:49:38 | 显示全部楼层 |阅读模式
前端APP
var sendData = {Mobile, Psw, Name};

后台由CI完成简单的查询,插入数据库操作
$Mobile = $this->input->post('Mobile', TRUE);
$query = $this->db->get_where('myTable', array('Mobile' => $Mobile), 1);
if(0 < $query->num_rows()) {
    $resultData = array (
        'result' => '号码已经存在'
    );
    echo json_encode($resultData);
}

但是现在在前端打印,发现返回的对象是NULL。
想请教一下大家:
1、哪些地方有问题?
2、如何在服务器上对PHP代码进行跟踪调试?

发表于 2015-1-16 11:44:28 | 显示全部楼层
先輸出看看有沒有取到值
echo $query->result_array(); //多筆
echo $query->row_array(); //單筆
 楼主| 发表于 2015-1-16 14:28:55 | 显示全部楼层
Closer 发表于 2015-1-16 11:44
先輸出看看有沒有取到值
echo $query->result_array(); //多筆
echo $query->row_array(); //單筆 ...


谢谢,我在浏览器中直接输入地址,提示:
call to a member function num_rows() on a non-object

代码:
$query = $this->db->get_where('myTable', array('Mobile' => $Mobile), 1);
if(0 < $query->num_rows()) {
    $resultData = array (
        'result' => '号码已经存在'
    );
    echo json_encode($resultData);
}

我在CI的用户指南中看到就是这么写的啊?

本版积分规则