Laravel 5.8新手。从api接收json格式的数据,将其转换为数组,然后尝试将其保存在数据库中。 firstOrCreate返回一个SQL错误,原因是一个字段中有逗号,而Eloquent没有引用这些值。 这样做
$order = Connector::firstOrCreate($connector);
$ connector数组的字段如下:
'description' => 'bla bla, bla bla, bla. Bla bla bla, bla'
是否有一种方法可以使雄辩的自动报价值(即.env文件中的值)?
php artisan tinker
,然后
DB::connection()->getPdo();
返回:
PDO {#2937
inTransaction: false,
attributes: {
CASE: NATURAL,
ERRMODE: EXCEPTION,
AUTOCOMMIT: 1,
PERSISTENT: false,
DRIVER_NAME: "mysql",
SERVER_INFO: "Uptime: 453 Threads: 8 Questions: 203 Slow queries: 0 Opens: 25 Flush tables: 1 Open tables: 15 Queries per second avg: 0.448",
ORACLE_NULLS: NATURAL,
CLIENT_VERSION: "mysqlnd 5.0.12-dev - 20150407 - $Id: 7cc7cc96e675f6d72e5cf0f267f48e167c2abb23 $",
SERVER_VERSION: "5.5.5-10.3.15-MariaDB-1:10.3.15+maria~bionic",
STATEMENT_CLASS: [
"PDOStatement",
],
EMULATE_PREPARES: 0,
CONNECTION_STATUS: "127.0.0.1 via TCP/IP",
DEFAULT_FETCH_MODE: BOTH,
},
}