php ci框架修改,PHP的CI框架實現增刪查改

defined('BASEPATH') OR exit('No direct script access allowed');

class Welcome extends MY_Controller {

/**

* Index Page for this controller.

*

* Maps to the following URL

*         http://example.com/index.php/welcome

*    - or -

*         http://example.com/index.php/welcome/index

*    - or -

* Since this controller is set as the default controller in

* config/routes.php, it's displayed at http://example.com/

*

* So any other public methods not prefixed with an underscore will

* map to /index.php/welcome/

* @see https://codeigniter.com/user_guide/general/urls.html

*/

public function index()

{

/*

//查詢表

$res=$this->db->get('pergoods');

//var_dump($res);

foreach($res->result() as $item){

echo $item->UserName;

echo $item->UserID;

echo $item->Goods;

echo $item->GdModel;

echo $item->GdNumber;

echo $item->GdTime;

echo '
';

}*/

/*

//增加表數據

$data=array(

'UserName'=>'張三',

'UserID'=>'123',

);

$bool=$this->db->insert('pergoods',$data);

var_dump($bool);

*/

/*

//修改

$data=array(

'UserName'=>'李四',

'UserID'=>'456',

);

$bool=$this->db->update('pergoods',$data,array('RecordID'=>42));

var_dump($bool);

*/

/*

//刪除

$bool=$this->db->delete('pergoods',array('RecordID'=>42));

var_dump($bool);

*/

//連貫操作

$res=$this->db->select('RecordID,UserName,UserID')

->from('pergoods')

->where('RecordID >=',10)  //RecordID大於等於10

->limit(3,2)    //跳過倆條查詢三條

->order_by('RecordID desc')

->get();

var_dump($res->result());

//顯示最近執行的一條sql

echo $this->db->last_query();

/*

//where操作

$res=$this->db->where('UserName','劉政')->get('pergoods');

$res=$this->db->where('UserName !=','劉政')->get('pergoods');

$res=$this->db->where(array('UserName'=>'劉政'))->get('pergoods');

$res=$this->db->where(array('UserName'=>'劉政','RecordID >'=>'10'))->get('pergoods');

echo $this->db->last_query();

*/

//$this->load->view('welcome_message');

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值