1. The relevant contents of the database are completed in application/config/database.php including hostname username password, etc.
2. Create a new file application/controllers/guanlicon.php
The code is as follows
<?php
Class Guanlicon extends ci_controller{
Public Function __construct ()
{
Parent::__construct ();
$this->load->model (' Guanlimo ');
$this->load->helper (' Url_helper ');
}
Public Function View ()
{
$this->load->view (' Customer-yonghuguanli ');
}
}
?>
3. Create a new file application/models/guanlimo.php
<?php
Class Guanlimo extends ci_model{
Public Function __construct ()
{
Parent::__construct ();
$this->load->database ();
}
Public Function Yonghu ()
{
$sql = "SELECT * from T_user";//sql statement reads all the contents of the built table
$query = $this->db->query ($sql);
$result = $query->result_array ();
return $result;//Read Library
}
}
The CI framework php read MySQL database