2013-11-28 43 views
0

我正在使用CodeigniterGrocery Crud來連接MySQLPhpMyAdmin中的數據庫。未存儲在數據庫中的日期值

我按照教程的說法安裝了所有東西,但錯誤總是存在的。

我的問題是:我有一個簡單的表格(3個字段,一個用於名稱,另一個用於姓氏,另一個用於出生日期),前兩個使用varchar (255),出生日期使用DATE。當我添加新記錄或更新現有記錄時,它說它成功地完成了這項工作,但實際上並沒有。並只與DATE字段。我可以完美地添加和更新其他2列。

任何想法?

編輯:我添加了要求的代碼。這是得到病人的Controller

<?php if (!defined('BASEPATH')) 
    exit('No direct script access allowed'); 
class GetPatients extends CI_Controller 
{ 

    function __construct() 
    { 
     parent::__construct(); 

     $this->load->database(); 
     $this->load->helper('url'); 

     $this->load->library('grocery_CRUD'); 
    } 

    public function index() 
    { 
     echo "<h1>Welcome to the world of Codeigniter</h1>"; //Just an example to ensure that we get into the function 
     die(); 
    } 

    public function dbpatients() 
    { 
     $this->grocery_crud->set_table('patient'); 
     $output = $this->grocery_crud->render(); 

     $this->_example_output($output); 
    } 

    function _example_output($output = null) 
    { 
     $this->load->view('patients_view',$output); 
    } 

} 
+0

你可以發表你的代碼的例子..? –

+0

@Aminadha確定,讓我編輯問題。 –

+0

@Aminadha如果您需要任何其他內容,請讓我知道。 –

回答

1

mysql date col只支持數字或字符串作爲賦值。 你可以轉換你的日期格式

$datestring = "%Y%m%d"; 
    $time = time(); 
    $date = mdate($datestring, $time); 
相關問題