<?php
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/<method_name>
* @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 '<br>';
}*/
/*
//增長表數據
$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');
}
}
php