doutangshuan6473 2019-05-19 15:41
浏览 114

Laravel 5.8 Eloquent不会在firstOrCreate上引用值

Laravel 5.8 newbie. Receiving data in json format from an api, converting in array, and trying to save it on the db. the firstOrCreate is returning a sql error cause one filed has commas into it and Eloquent is not quoting the values. So doing

$order = Connector::firstOrCreate($connector);

where the $connector array has field like:

'description' => 'bla bla, bla bla, bla. Bla bla bla, bla'

Is there a way to make Eloquent auto quoting values (i.e. in the .env file)?

php artisan tinker and then

DB::connection()->getPdo();

returns:

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,
     },
   }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化