laravel mysql pdo,更改Laravel中的基本PDO配置

My shared web host have some problems with query prepares and I want to enable PDO's emulated prepares, there's no option for this in the config\database.php.

Is there any way I can do that in Laravel?

解決方案

You can add an "options" array to add options to your Database Connection within config/database.php:

'mysql' => [

'driver' => 'mysql',

'host' => env('DB_HOST', 'localhost'),

'port' => env('DB_PORT', '3306'),

'database' => env('DB_DATABASE', 'forge'),

'username' => env('DB_USERNAME', 'forge'),

'password' => env('DB_PASSWORD', ''),

'charset' => 'utf8',

'collation' => 'utf8_unicode_ci',

'prefix' => '',

'strict' => false,

'engine' => null,

// Additional options here

'options' => [PDO::ATTR_EMULATE_PREPARES => true, PDO::MYSQL_ATTR_COMPRESS => true,]

],

You will see I've also switched on MYSQL_ATTR_COMPRESS for my connection.

You can find more information on some of the options they have built in here:

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/392562.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/392562.shtml
英文地址,請注明出處:http://en.pswp.cn/news/392562.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Java多線程-工具篇-BlockingQueue

Java多線程-工具篇-BlockingQueue 轉載 http://www.cnblogs.com/jackyuj/archive/2010/11/24/1886553.html 這也是我們在多線程環境下,為什么需要BlockingQueue的原因。作為BlockingQueue的使用者,我們再也不需要關心什么時候需要阻塞線程,什…

leetcode 204. 計數質數

統計所有小于非負整數 n 的質數的數量。 示例 1: 輸入:n 10 輸出:4 解釋:小于 10 的質數一共有 4 個, 它們是 2, 3, 5, 7 。 解題思路 大于等于5的質數一定和6的倍數相鄰。例如5和7,11和13,17和19等等&#xff1b…

JAVA 網絡編程小記

在進行JAVA網絡編程時,發現寫入的數據對方等200ms左右才會收到。起初認為是JAVA自已進行了 Cache。進行flush也沒有效果。查看JDK代碼,Write操作直接調用的native方法,說明JAVA層面并沒有緩存。再看flush,只是一個空方法. FileOut…

vue生成靜態js文件_如何立即使用Vue.js生成靜態網站

vue生成靜態js文件by Ond?ej Polesn通過Ond?ejPolesn 如何立即使用Vue.js生成靜態網站 (How to generate a static website with Vue.js in no time) You have decided to build a static site, but where do you start? How do you select the right tool for the job wit…

查看文件夾大小的4種方法,總有一種是你喜歡的

有必要檢查文件夾的大小,以確定它們是否占用了太多的存儲空間。此外,如果你通過互聯網或其他存儲設備傳輸文件夾,還需要查看文件夾大小。 幸運的是,在Windows設備上查看文件夾大小非常容易。窗口中提供了圖形化和基于命令行的應用程序,為你提供了多種方法。 如何在Windo…

Python 獲取服務器的CPU個數

在使用gunicorn時,需要設置workers, 例如: gunicorn --workers3 app:app -b 0.0.0.0:9000 其中,worker的數量并不是越多越好,推薦值是CPU的個數x21, CPU個數使用如下的方式獲取: python -c impo…

多種數據庫連接工具_20多種熱門數據工具及其不具備的功能

多種數據庫連接工具In the past few months, the data ecosystem has continued to burgeon as some parts of the stack consolidate and as new challenges arise. Our first attempt to help stakeholders navigate this ecosystem highlighted 25 Hot New Data Tools and W…

怎么連接 mysql_怎樣連接連接數據庫

這個博客是為了說明怎么連接數據庫第一步:肯定是要下載數據庫,本人用的SqlServer2008,是從別人的U盤中拷來的。第二步:數據庫的登錄方式設置為混合登錄,步驟如下:1.打開數據庫這是數據庫界面,要…

webstorm環境安裝配置(less+autoprefixer)

node安裝: 參考地址:http://www.runoob.com/nodejs/nodejs-install-setup.html 1.下載node安裝包并完成安裝 2.在開始菜單打開node 3.查看是否安裝完成(npm是node自帶安裝的) 命令:node -v npm -v less安裝&#xff1a…

leetcode 659. 分割數組為連續子序列(貪心算法)

給你一個按升序排序的整數數組 num(可能包含重復數字),請你將它們分割成一個或多個子序列,其中每個子序列都由連續整數組成且長度至少為 3 。 如果可以完成上述分割,則返回 true ;否則,返回 fa…

將JAVA編譯為EXE的幾種方法

< DOCTYPE html PUBLIC -WCDTD XHTML StrictEN httpwwwworgTRxhtmlDTDxhtml-strictdtd> 將JAVA編譯為EXE的幾種方法 -------------------------------------------------------------------------------- 將Java應用程序本地編譯為EXE的幾種方法(建議使用JOVE和JET)  a.…

文本訓練集_訓練文本中的不穩定性

文本訓練集介紹 (Introduction) In text generation, conventionally, maximum likelihood estimation is used to train a model to generate a text one token at a time. Each generated token will be compared against the ground-truth data. If any token is different …

山東省賽 傳遞閉包

https://vjudge.net/contest/311348#problem/A 思路&#xff1a;用floyd傳遞閉包處理點與點之間的關系&#xff0c;之后開數組記錄每個數字比它大的個數和小的個數&#xff0c;如果這個個數超過n/2那么它不可能作為中位數&#xff0c;其他的都有可能。 #include<bits/stdc.h…

如何使用動態工具提示構建React Native圖表

by Vikrant Negi通過Vikrant Negi 如何使用動態工具提示構建React Native圖表 (How to build React Native charts with dynamic tooltips) Creating charts, be it on the web or on mobile apps, has always been an interesting and challenging task especially in React …

如何解決ajax跨域問題(轉)

由 于此前很少寫前端的代碼(哈哈&#xff0c;不合格的程序員啊)&#xff0c;最近項目中用到json作為系統間交互的手段&#xff0c;自然就伴隨著眾多ajax請求&#xff0c;隨之而來的就是要解決 ajax的跨域問題。本篇將講述一個小白從遇到跨域不知道是跨域問題&#xff0c;到知道…

mysql并發錯誤_又談php+mysql并發數據出錯問題

最近&#xff0c;項目中的所有crond定時盡量取消&#xff0c;改成觸發式。比如每日6點清理數據。原來的邏輯&#xff0c;寫一個crond定時搞定現在改為觸發式6點之后第一個玩家/用戶 進入&#xff0c;才開始清理數據。出現了一個問題1 如何確保第一個玩家觸發&#xff1f;updat…

leetcode 621. 任務調度器(貪心算法)

給你一個用字符數組 tasks 表示的 CPU 需要執行的任務列表。其中每個字母表示一種不同種類的任務。任務可以以任意順序執行&#xff0c;并且每個任務都可以在 1 個單位時間內執行完。在任何一個單位時間&#xff0c;CPU 可以完成一個任務&#xff0c;或者處于待命狀態。 然而&…

英國腦科學領域_來自英國A級算法崩潰的數據科學家的4課

英國腦科學領域In the UK, families, educators, and government officials are in an uproar about the effects of a new algorithm for scoring “A-levels,” the advanced level qualifications used to evaluate students’ knowledge of specific subjects in preparati…

MVC發布后項目存在于根目錄中的子目錄中時的css與js、圖片路徑問題

加載固定資源js與css <script src"Url.Content("~/Scripts/js/jquery.min.js")" type"text/javascript"></script> <link href"Url.Content("~/Content/css/shop.css")" rel"stylesheet" type&quo…

telegram 機器人_學習使用Python在Telegram中構建您的第一個機器人

telegram 機器人Imagine this, there is a message bot that will send you a random cute dog image whenever you want, sounds cool right? Let’s make one!想象一下&#xff0c;有一個消息機器人可以隨時隨地向您發送隨機的可愛狗圖像&#xff0c;聽起來很酷吧&#xff1…