作者:郭楠v | 来源:互联网 | 2023-09-07 19:40
When running phpunit, I get:
1 2
| 1) MysqlRelationsTest::testMysqlRelations
Failed asserting that 0 matches expected 1. |
The problem code is the following:
1 2 3 4 5
| // SQL has many
$book = new Book(array('title' => 'Game of Thrones'));
$user->books()->save($book);
$user = MysqlUser::find($user->id); // refetch
$this->assertEquals(1, count($user->books)); |
count($user->books) returns 0. It works on travis, but not my computer. I have spent hours trying to work out why T_T.
Has anyone else had this problem and/or know a fix?
该提问来源于开源项目:jenssegers/laravel-mongodb
Fixed! MySQL was returning integers as strings. mysqlnd returns native data types. Thanks for your help.
1
| sudo apt-get install php5-mysqlnd |