0

i have a small problem with my script i can't add dates into database , when i remove it i can add records to db but if i add date it dosn't work here is my code : $db = JFactory::getDBO();

    $query=$db->getQuery(true);




        $columns=array('id_cours','jour','num','date_echeance');//
        $values = array($id,$jour,$i,$data['date_debut']);


        echo($data['date_debut']);
        $query->insert($db->quoteName('#__pgm_cotisation'))
            ->columns($db->quoteName($columns))
            ->values(implode(',',$values));


        $db->setQuery($query);
        $db->execute();
        die('stopped');

        /////


        $id_cotisation=$this->getMaxID();


        $query=$db->getQuery(true);
        $values = array($id,$destinataire,$id_cotisation);
        $columns=array('id_cours','destinataire','id_cotisation');

        $query->insert($db->quoteName('#__pgm_factures'))
            ->columns($db->quoteName($columns))
            ->values(implode(',',$values));

        $db->setQuery($query);
        $db->execute();

2 Answers2

0

thank you i used echo $query->dump(); to check a query and then i seen that date is like this xxxx-xx-xx xx:xx:xx then i added this 'xxxx-xx-xx xx:xx:xx' and now it works.

        $columns=array('id_cours','jour','num','date_echeance');//
        $values = array($id,$jour,$i,"'".$data['date_debut']."'");

thank you any way.

0

you could use:

$db->quote($data['date_debut'])

which is something else than $db->quoteName