Safwen Posted September 11, 2013 Share Posted September 11, 2013 Hi guys, i have created manually (from the sql window of my PHPMYADMIN) a new table named 'pst_horaire' like this the problem i have that where i want to insert a new line from a customized controller i have created , the insertion fails and i don't know why this is how i try to insert in the table $difference = Tools::getValue("diffdays"); for ($i=0; $i <=$difference ; $i++) { $debut = Tools::getValue("horaire_debut_".$i); $fin = Tools::getValue("horaire_fin_".$i); $date_formation = Tools::getValue("date_day_".$i); $res=Db::getInstance()->insert("horaire", array( 'horaire_debut' => 'salut', 'horaire_fin' => 'bye', 'date_day' => '2013-09-11 10:44:51', 'id_product' => 20, 'id_seller' => 21, )); if($res) echo 'ok'; else echo 'not ok'; } can anyone help me to fix this please ? Link to comment Share on other sites More sharing options...
vekia Posted September 11, 2013 Share Posted September 11, 2013 have you got any error message? what you've got in result in $res variable? try with simple query: Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'horaire` (FIELDS HERE) VALUES (VALUES HERE)'); of course define fields and values Link to comment Share on other sites More sharing options...
Safwen Posted September 11, 2013 Author Share Posted September 11, 2013 Thank you Vekia i fixed it the issue was in my Class Horaire.php in the validator of my id_product <?php class Horaire extends ObjectModel { /** @var string Name */ public $horaire_debut; /** @var string Name */ public $horaire_fin; /** @var string formationdate */ public $date_day; /** @var integer seller id */ public $id_seller; /** @var integer product id */ public $id_product; public static $definition = array( 'table' => 'horaire', 'primary' => 'id_horaire', 'multilang' => true, 'multilang_shop' => true, 'fields' => array( 'horaire_debut' => array('type' => self::TYPE_STRING, 'validate' => 'isHoraireDebut', 'size' => 10), 'horaire_fin' => array('type' => self::TYPE_STRING, 'validate' => 'isHoraireFin', 'size' => 10), 'date_day' => array('type' => self::TYPE_STRING, 'validate' => 'isDateDay', 'size' => 30), 'id_seller' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), ), ); public function getFields() { parent::validateFields(); $fields['horaire_debut'] = pSQL($this->horaire_debut); $fields['horaire_fin'] = pSQL($this->horaire_fin); $fields['date_day'] = $this->date_day; $fields['id_seller'] = $this->id_seller; $fields['id_product'] = $this->id_product; return $fields; } } ?> Link to comment Share on other sites More sharing options...
Safwen Posted September 11, 2013 Author Share Posted September 11, 2013 You can mark it as [sOLVED] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now