We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
when i setup connection option as PDO::ATTR_ORACLE_NULLS =>PDO::NULL_EMPTY_STRING
and run
$db->insert("table", [ "name" => "foo", "email" => "foo@bar.com", "phone" => "" ]);
the phone field still insert as empty string not null , WHY??
The text was updated successfully, but these errors were encountered:
If you want to insert null data, try this:
$db->insert("table", [ "name" => "foo", "email" => "foo@bar.com", "phone" => $phone === "" ? null : $phone ]);
Sorry, something went wrong.
so the PDO::NULL_EMPTY_STRING doesn't work??
Because the empty string "" is still mapped as PDO::PARAM_STR inside https://github.com/catfan/Medoo/blob/master/src/Medoo.php#L744
""
PDO::PARAM_STR
Of course, you can just create your insert() method to handle those values and then call Medoo's insert().
insert()
function myInsert($data) { $result = []; foreach ($data as $key => $value) { $result[$key] = $value === "" ? null : $value } $database->insert("table", $result); }
No branches or pull requests
when i setup connection option as PDO::ATTR_ORACLE_NULLS =>PDO::NULL_EMPTY_STRING
and run
$db->insert("table", [ "name" => "foo", "email" => "foo@bar.com", "phone" => "" ]);
the phone field still insert as empty string not null , WHY??
The text was updated successfully, but these errors were encountered: