redbean 1.3 Error:Fatal error: Uncaught [22007] - SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value: 'pact.1' thrown in D:\pact\classes\rb.php on line 902

1,692 views
Skip to first unread message

carl anderson

unread,
Jun 24, 2011, 1:43:08 PM6/24/11
to redbeanphp
redbean version:1.3

PHP Code:
R::setup("mysql:host=127.0.0.1;dbname=pact",'root','pact2') ;
$clauses = R::find('clause') ; // works just fine

$clause = R::dispense('clause') ;
$clause->id = 'redbean.1' ;
$clause->library = 'redbean' ;
$clause->xml = 'words from redbean' ;
R::store($clause) ;

Error:
Fatal error: Uncaught [22007] - SQLSTATE[22007]: Invalid datetime
format: 1292 Truncated incorrect DOUBLE value: 'pact.1' thrown in D:
\pact\classes\rb.php on line 902

SHOW create table clause:
'clause', 'CREATE TABLE `clause` (
`id` varchar(45) NOT NULL,
`library` varchar(45) NOT NULL,
`xml` longtext,
PRIMARY KEY (`id`,`library`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8'

Existing Table Data:
INSERT INTO `clause` (`id`,`library`,`xml`) VALUES ('pact.
1','lib1','some xml text goes here');
INSERT INTO `clause` (`id`,`library`,`xml`) VALUES ('2','lib1','some
more xml');
INSERT INTO `clause` (`id`,`library`,`xml`) VALUES
('cfa60d','lib2','xmltext goes here');
INSERT INTO `clause` (`id`,`library`,`xml`) VALUES
('6f1a12','lib2','xmltext goes here');

gabor

unread,
Jun 24, 2011, 3:05:10 PM6/24/11
to redbeanphp
Hi there,
Welcome to the forum.

I tried to run this code, but over here it works..?
Could be that you are running MySQL in STRICT mode, some Windows
distros happen to be configured that way:

http://stackoverflow.com/questions/2690205/mysql-how-to-check-if-a-string-is-a-valid-date-time-or-datetime

try to turn off stict mode:
SET sql_mode = '';

Cheers
Gabor

carl anderson

unread,
Jun 24, 2011, 4:49:06 PM6/24/11
to redbeanphp
Gabor,

Thanks for all your work on redbean - really great!

And thanks for the quick response!

Yes, the MySQL server (5.5.13) was running in strict mode but
changing the setting as you recommended and restarting only eliminated
the "error" generation.

The table is still not being updated. My PHP version is 5.3.5.

The error message is odd because I'm not using any time/date fields or
DOUBLE fields - only text fields. Puzzling.


On Jun 24, 12:05 pm, gabor <gabordemo...@gmail.com> wrote:
> Hi there,
> Welcome to the forum.
>
> I tried to run this code, but over here it works..?
> Could be that you are running MySQL in STRICT mode, some Windows
> distros happen to be configured that way:
>
> http://stackoverflow.com/questions/2690205/mysql-how-to-check-if-a-st...

carl anderson

unread,
Jun 24, 2011, 6:03:04 PM6/24/11
to redbeanphp
FYI - my workaround was to leave the 'id' field alone and create a new
"id_clause" field that I will populate with data.
The query fails if the 'id' field is deleted from the MySQL table OR
if I try to assign a value to the id property of a bean ($clause->id =
111 ;).

So the 'id' field of the table just stays as NULL values and is not
part of the primary key.


'CREATE TABLE `clause` (
`library` varchar(45) NOT NULL,
`xml` longtext,
`id_clause` varchar(45) NOT NULL DEFAULT '''',
`id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id_clause`,`library`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8'
Reply all
Reply to author
Forward
0 new messages