Laravel 5.5 - Eloquent - 使用 "datetime(6)" 字段从 MySQL table 中检索 "microseconds"

Laravel 5.5 - Eloquent - Retrieve "microseconds" from MySQL table with "datetime(6)" field

我在从 MySQL 5.7 table 中检索 datetime(6) 字段时遇到问题。 如果我 运行 它直接来自 mysql 客户端,它会起作用:

mysql> SELECT arrival from table1 limit 1;
+----------------------------+
| arrival                    |
+----------------------------+
| 2016-06-22 16:52:06.260000 |
+----------------------------+
1 row in set (0.00 sec)

mysql>

但使用 Eloquent 从 Laravel 获取字段时,未报告微秒:

class Table1Model extends Model
{
   protected $table = 'table1';
}

class Table1Controller extends Controller
{
   public function index()
   {
       $data = Table1Model::first()->arrival;
       dd($data);
   }
}

// the output is: "2016-06-22 16:52:06"

这是一个 Eloquent 问题吗?怎么得到微秒?

谢谢。

谢谢@apokryfos,真的...这是一个错误。

我使用 RAW 查询找到了一个简单的解决方法:

class Table1Model extends Model
{
   protected $table = 'table1';
}

class Table1Controller extends Controller
{
   public function index()
   {
       $query = Table1Model::select(
            DB::raw(
                  CONVERT(CAST(arrival AS DATETIME(3)), CHAR)
            )
       );
       $data = $query->get();
       dd($data);
   }
}
// the output is: "2016-06-22 16:52:06.260"