catfan / Medoo

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

Insert successfully while the column is set to not null #840

Closed gamefans123 closed 3 years ago

gamefans123 commented 5 years ago

MySQL5.6 表名:test a1(主键), a2(varchar200 不允许空), a3(varchar200 不允许空), a4(int)

$db->insert("test",["a1" => "35"]); 使用Medoo仍能正常插入(出错),使用下面则不能插入成功(正确)

$sql=$pdo->prepare("insert into test (a4) values (?)");
$sql->execute(array(12));

$pdo->exec("INSERT INTO test (a1) VALUES ('36')");

gamefans123 commented 5 years ago

Medoo 版本 1.6.1

$db = new Medoo([ 'database_type' => 'mysql', 'database_name' => 'testdb', 'server' => 'localhost', 'username' => 'root', 'password' => '123456', 'charset' => 'utf8mb4', 'port' => 3306, 'option' => [ PDO::ATTR_CASE => PDO::CASE_NATURAL, ] ]);


$pdo = new PDO("mysql:host=localhost;dbname=testdb;port=3306","root","123456");
$pdo -> query("set names utf8mb4");