PHP CI Framework Implementation and modification

Source: Internet
Author: User

<?php
Defined (' BasePath ') or exit (' No Direct script access allowed ');

Class Welcome extends My_controller {

/**
* Index Page for the 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 was 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 would
* Map to/index.php/welcome/<method_name>
* @see https://codeigniter.com/user_guide/general/urls.html
*/
Public Function Index ()
{
/*
Query table
$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> ';
}*/


/*
Add Table Data
$data =array (
' UserName ' = ' Zhang San ',
' UserID ' = ' 123 ',
);
$bool = $this->db->insert (' Pergoods ', $data);
Var_dump ($bool);
*/


/*
Modify
$data =array (
' UserName ' = ' John Doe ',
' UserID ' = ' 456 ',
);

$bool = $this->db->update (' Pergoods ', $data, Array (' RecordID ' =>42));
Var_dump ($bool);
*/


/*
Delete
$bool = $this->db->delete (' Pergoods ', Array (' RecordID ' =>42));
Var_dump ($bool);
*/



Consistent operation
$res = $this->db->select (' Recordid,username,userid ')
->from (' Pergoods ')
->where (' RecordID >= ', ten)//recordid greater than or equal to 10
->limit (3,2)//Skip two query three article
->order_by (' RecordID desc ')
->get ();

Var_dump ($res->result ());
Displays a recently executed SQL
echo $this->db->last_query ();



/*
where operation
$res = $this->db->where (' UserName ', ' Liu Zheng ')->get (' Pergoods ');
$res = $this->db->where (' UserName! = ', ' Liu Zheng ')->get (' Pergoods ');
$res = $this->db->where (Array (' UserName ' = ' Liu Zheng '))->get (' Pergoods ');
$res = $this->db->where (Array (' UserName ' = ' Liu Zheng ', ' RecordID > ' = ') '->get (' pergoods ');
echo $this->db->last_query ();
*/


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

}

PHP CI Framework Implementation and modification

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.