catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.83k stars 1.15k forks source link

Prepared statement with INSERT #719

Closed mozart77 closed 6 years ago

mozart77 commented 6 years ago

Hi. Looks like a bug:

$db->insert('email_check',[
  'email' => 'test@example.org',
  'dt_expired' => Medoo::raw('DATE_ADD(NOW(), INTERVAL :hours HOUR)', [':hours' => 3])
 ]
)

Outputs:

PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in /usr/local/www/alter/.inc/Medoo.php on line 293

While debug outputs:

array(1) { 
 [0]=> string(107) "INSERT INTO `email_check` (`email`, `dt_expired`) 
 VALUES (:MeDoO_5_mEdOo, DATE_ADD(NOW(), INTERVAL 3 HOUR))" 
}

As you can see Medoo tries to substitute all params

catfan commented 6 years ago

This fixed on b80cb02