<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Bappoint extends CI_Controller {
function index()
{
$this->load->view('home');
}
function search()
{
header('Content-Type: application/json');
$this->load->model('common_model');
$key = $this->input->post('search_key');
$users = $this->common_model->get_search($key);
//$this->output->enable_profiler();
echo json_encode($users->result());
}
}
?>
common_model.php(模型)
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Common_model extends CI_Model
{
public function get_search($key)
{
$this->db->like('fname', $key, 'both');
return $this->db->get('users');
}
}?>
1条答案
按热度按时间fv2wmkja1#
bappoint.php(控制器)
common_model.php(模型)
home.php(视图)
mysql查询