CI 筆記 資料庫

來源:互聯網
上載者:User

標籤:

demo:

     1.  建立資料庫,driver, 

    欄位 name,telphone,idcard,car,content

 

  2. 建立model,Driver_model.php檔案,

  建立add方法,

    public function add($data)    {        $this->db->insert(‘driver‘,$data);        $this->output->enable_profiler(TRUE);    }

 

  3. 控制器調用,建立driver控制器

  

    public function add()    {        $this->load->model(‘driver_model‘,‘drv‘);        $data = array(                ‘name‘ => $this->input->get(‘name‘),                ‘telphone‘ => $this->input->get(‘telphone‘),                ‘car‘ => $this->input->get(‘car‘),                ‘idcard‘ => $this->input->get(‘idcard‘),                ‘content‘ => $this->input->get(‘content‘)            );        $this->drv->add($data);    }

 

  4. 建立view視圖

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head>    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">    <title>driver add</title></head><body>    <form action="driver/add" >        <table>            <th>                <tr></tr>                <tr>添加司機</tr>            </th>            <tr>                <td>姓名:</td>                <td><input type="text" name="name" /></td>            </tr>            <tr>                <td>手機:</td>                <td><input type="text" name="telphone" /></td>            </tr>            <tr>                <td>身份證:</td>                <td><input type="text" name="idcard" /></td>            </tr>            <tr>                <td>車輛</td>                <td><input type="text" name ="car"/></td>            </tr>            <tr>                <td>備忘;</td>                <td><input type="text" name="content" /></td>            </tr>            <tr>                <td></td>                <td><input type="submit" /></td>            </tr>        </table>    </form>    </body></html>

 

----------------------------------------

走過的彎路,在輸入安全類中,將input->get , 輸入成input->post

第二個是,從admin的總的控制器中,跳轉時,跳轉路徑不正常,重寫的路由規則,在config裡router檔案中,添加如下規則,否則跳轉時,控制器的url片段上,有admin的總控制器的名字。

 

$route[‘admin/([a-z]+)/([a-z]+)‘] = ‘/$1/$2‘;

 

CI 筆記 資料庫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.