You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i tried to create an entry in a MySQL-Database. My model/table has a column which is defined not null. For MySQL (maybe for other RDMS also) an empty string is not null, so it can be used within insertions. But Phalcon misinterpretes it. Phalcon thinks that it is not valid. That is wrong.
My System is:
Phalcon Version 1.3.4
PHP 5.5
MySQL 5.6
CREATETABLE `dummy` (
`id`smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`name`varchar(80) NOT NULL,
PRIMARY KEY (`id`)
);
// create object and set an empty (not null) value$myModel = newdummy();
$myModel->name = '';
// show that 'name' is empty, but not nullecho"<pre>";
var_dump($myModel->toArray());
echo"</pre>";
// try to create (insert into table)// and show errors if something was wrongif( !$myModel->create() ) {
echo"an error occured:<br>";
foreach( $myModel->getMessages() as$message ) {
$this->flash->error((string) $message);
}
}
result:
array(2) {
["id"]=>
NULL
["name"]=>
string(0) ""
}
an error occured:
name is required
The text was updated successfully, but these errors were encountered:
swen100
changed the title
create model with empty (not null) values fails when column is defined "not Null"
saving a model with empty (not null) values set fails when column is defined "not Null"
Nov 14, 2014
swen100
changed the title
saving a model with empty (not null) values set fails when column is defined "not Null"
saving a model with empty (not null) values fails when column is defined "not Null"
Nov 14, 2014
i tried to create an entry in a MySQL-Database. My model/table has a column which is defined not null. For MySQL (maybe for other RDMS also) an empty string is not null, so it can be used within insertions. But Phalcon misinterpretes it. Phalcon thinks that it is not valid. That is wrong.
My System is:
Phalcon Version 1.3.4
PHP 5.5
MySQL 5.6
result:
if i use straight sql like this:
all works fine.
The value i have set is empty, but it is not Null. With phalcon the creation of a new object fails. In my opinion it should not fail, but it does...
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: