Skip to content
New issue

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

Fix quote function to correctly interpret NULL values (insert, update) #67

Closed
wants to merge 1 commit into from

Conversation

FxNion
Copy link

@FxNion FxNion commented May 30, 2013

When inserting an array of datas which have some keys not set to a value, the quote function intepret it as '' instead of NULL. And when the target field is an integer in db, the result stored is 0

When inserting an array of datas which have some keys not set to a value, the quote function intepret it as '' instead of NULL. And when the target field is an integer in db, the result stored is 0
@vrana
Copy link
Owner

vrana commented Jun 26, 2013

Please provide an example of previously wrong behavior. The patch doesn't make much sense to me. If $val is null then isset($val) returns false.

@FxNion
Copy link
Author

FxNion commented Jul 15, 2013

You are right, and i really apologize.

After some hollidays and severals tests i understood my error: I thank that i was passing a null value in parameters, but in fact it was already an empty string.

And the second error (in the patch) was to use == instead of === to compare '' to NULL and as you can guess, in php ''==NULL is true. Bad.

Sorry again.

$connection->exec(" CREATE TABLE test (id int(10), parent_test_id int(10) DEFAULT NULL, name varchar(255))");

$db = new NotORM($connection);                  
$db->debug=true;
$db->test()->insert(array( "id"=>1, "parent_test_id"=>'', "name"=>"test insert"));
//0 will be stored in the field ...

@halilim
Copy link

halilim commented Jan 8, 2014

So there is no problem? If so, what about closing? I always feel bad about needlessly high bug / open pull request counts on open source projects :)

@vrana vrana closed this Jan 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants