Welcome Guest, Not a member yet? Register   Sign In
adding date to datebase
#1

[eluser]Mohammed Zayan[/eluser]
I use this code in my model

Code:
function addBook($photo_link){
        $data = array(
            'id'          => NULL,
            'book_cat_id' => $this->input->post('cat'),
            'book_name'   => $this->input->post('name')
        );
        $q = $this->db->insert('book', $data);
        if($q){
            $id = $this->db->insert_id('book');
            $data = array(
                'id'            => NULL,
                'book_id'       => $id,
                'book_cat_id'   => $this->input->post('cat'),
                'language_id'   => 1,
                'name'          => $this->input->post('name'),
                'auther'        => $this->input->post('auther'),
                'photo_link'    => $photo_link,
                'dwonload_link' => $this->input->post('dwonload_link'),
                'view_link'     => $this->input->post('view_link'),
                'about'         => $this->input->post('about'),
                'creation_date' => date('d-m-Y')
            );
            $query = $this->db->insert('book_translation', $data);
            if($query){
                return TRUE;
            }
        }
    }

but creation_date field like this 0000-00-00
Is the way I use wrong?
#2

[eluser]Mohammed Zayan[/eluser]
my table structure in this photo
http://im26.gulfup.com/2012-05-13/1336919768201.jpg
I think it will help.
#3

[eluser]InsiteFX[/eluser]
If using a MySQL DateTime field then use this.
Code:
$now = date("Y-m-d H:i:s");
// your creation_date
'creation_date' => $now

// MySQL Date
// for the way you have it use this
$now = date("Y-m-d");
// your creation_date
'creation_date' => $now
#4

[eluser]Mohammed Zayan[/eluser]
Thank you now it works




Theme © iAndrew 2016 - Forum software by © MyBB