Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
类型:错误消息:调用字符串文件名为:CI\application\models\Country\u model.php的成员函数result(),行号:34_Php_Jquery_Mysql_Codeigniter_Jquery Jtable - Fatal编程技术网

类型:错误消息:调用字符串文件名为:CI\application\models\Country\u model.php的成员函数result(),行号:34

类型:错误消息:调用字符串文件名为:CI\application\models\Country\u model.php的成员函数result(),行号:34,php,jquery,mysql,codeigniter,jquery-jtable,Php,Jquery,Mysql,Codeigniter,Jquery Jtable,请帮忙。我卡住了。无法使搜索按钮在筛选器中工作 jTable编码点火器3。干杯 类型:错误消息:调用字符串文件名为:CI\application\models\Country\u model.php的成员函数结果行号:34 这是我的model.php public function get_country() { if(empty($this->input->post('country_name'))){ $country_name=NULL;

请帮忙。我卡住了。无法使搜索按钮在筛选器中工作 jTable编码点火器3。干杯

类型:错误消息:调用字符串文件名为:CI\application\models\Country\u model.php的成员函数结果行号:34

这是我的model.php

public function get_country() {

    if(empty($this->input->post('country_name'))){
        $country_name=NULL;




    $result = $this->db->query("SELECT country_id, country_code, country_name, surface_area,
            continent_name, continent, population, capital_city, record_date
            FROM  country 
            WHERE deleted = 0
            ORDER BY " . filter_input(INPUT_GET, "jtSorting") . " 
            LIMIT " . filter_input(INPUT_GET, "jtStartIndex") . "," . filter_input(INPUT_GET, "jtPageSize") . ";");

    $this->db->where('deleted','0');
    } else {

        $country_name = filter_input(INPUT_POST, 'country_name');
        $result = ("SELECT country_id, country_code, country_name, surface_area,
            continent_name, continent, population, capital_city, record_date
            FROM  country 
            WHERE deleted = 0 AND
            country_name LIKE '%".$country_name."%'"
                . "ORDER BY " . filter_input(INPUT_GET, "jtSorting") . " 
            LIMIT " . filter_input(INPUT_GET, "jtStartIndex") . "," . filter_input(INPUT_GET, "jtPageSize") . ";");

    }
    $rows = array();
    foreach ($result->result() as $row) {

        $rows[] = $row;
    }
    return $rows;
}
这是我的controller.php

public function get_country() {

    $this->load->model('Country_model');
    $rows = $this->Country_model->get_country();
    $result = $this->db->get("country");
    $recordCount = $result->num_rows();
    $jTableResult = array();
    $jTableResult['Result'] = "OK";
    $jTableResult['TotalRecordCount'] = $recordCount;
    $jTableResult['Records'] = $rows;
    print json_encode($jTableResult);
}
还有my view.php

<div class="filtering">
    <form>
        Country Name: <input type="text" name="country_name" id="country_name" />

                        country_name: {
                        title: 'Country Name',
                                width: '17%'
                        },
                        country_code: {
                        title: 'Country Code',
                                width: '11%'
                        },
                        surface_area: {
                        title: 'Surface Area',
                                width: '13%'
                        },
                        continent_name: {
                        title: 'Continent Name',
                                width: '13%'
                        },
                        continent: {
                        title: 'Continent Code',
                                width: '11%'
                        },
                        population: {
                        title: 'Population',
                                width: '13%'
                        },
                        capital_city: {
                        title: 'Capital City',
                                width: '11%'
                        },
                        record_date: {
                        title: 'Record Date',
                                width: '11%',
                                type: 'date',
                                displayFormat: 'dd.mm.yy',
                                create: false,
                                edit: false,
                                sorting: false
                        }
                },

        $('#LoadRecordsButton').click(function (e) {
            e.preventDefault();
            $('#countryTable').jtable('load', {
                country_name: $('#country_name').val(),
            });
        });

        $('#LoadRecordsButton').click();

    });

</script>

你在其他方面犯了一个错误

$result=SELEC。。。 必须是这样的

$result=$this->db->querySELEC


希望它能纠正您的问题……

我觉得这个错误很清楚。如果$result是对象,则在中指定查询结果,但在else中指定字符串。您可能只是忘记了执行查询。我不知道Codeigniter,但有消息告诉我,在已经有where子句的查询上调用where可能会导致SQL错误。基本的错误检查应该抓住这一点,我是一个编程新手,所以我总是忽略一些简单的东西。。。谢谢你@jeroen