例子
<?php
defined('BASEPATH') OR exit('No direct script access allowed'); class Menu extends CI_Controller{
function __construct(){
parent::__construct();
$this->load->database(); //加载数据库配置
} public function getTop(){
echo 'TEST';
$res = $this->db->query('select id,name,url from web_menu');
//$r = $res->result(); //返回数据为对象类型
$r = $res->result_array(); //返回数据为数组类型
var_dump($r);
}
public function getBotton(){
$res = $this->db->query('select id,name,url from web_menufoot');
$r = $res->result_array(); //返回数据为数组类型
var_dump($r);
} public function delBotton(){
//$id = $this->input->post('id');
$id = 5;
$r = $this->db->query('delete from web_menufoot where id=?',$id);
echo $r; //返回执行成功的数目
} public function upTop(){
//$id = $this->input->post('id'); //获取传递的值
$id = 5;
$data = array(
'name' => '图片',
'mif_time' =>date("Y-m-d h:i:s",time()),
'mif_user' =>'Admin',
'mif_ip' =>'127.0.0.1',
);
$where = "id=".$id;
$r = $this->db->update('web_menu',$data,$where);
echo $r;
} }