×ðÁú¿­Ê±

laravel¿ò¼Üdb³¬Ê±ÉèÖÃ

ÔÚʹÓÃlaravel¿ò¼Ü¿ª·¢Ó¦ÓóÌÐòʱ £¬¾­³ £»áÉæ¼°µ½ÓëÊý¾Ý¿â¾ÙÐн»»¥µÄÇéÐΡ£¿ÉÊÇ £¬ÔÚһЩÌØÊâµÄÇéÐÎÏ £¬ÎÒÃÇ¿ÉÄÜ»áÓöµ½Êý¾Ý¿â³¬Ê±µÄÎÊÌâ¡£Õâʱ £¬¾ÍÐèÒª¶Ôlaravel¿ò¼ÜµÄÊý¾Ý¿âÅþÁ¬¾ÙÐÐһЩÉèÖà £¬ÒÔ×èÖ¹·ºÆð³¬Ê±µÄÇéÐΡ£±¾ÎĽ«ÎªÄúÏÈÈÝÔõÑùÔÚlaravel¿ò¼ÜÖÐÉèÖÃÊý¾Ý¿âÅþÁ¬µÄ³¬Ê±Ê±¼ä¡£

Ò»¡¢Laravel¿ò¼ÜÖеÄÊý¾Ý¿âÅþÁ¬

ÔÚLaravel¿ò¼ÜÖÐ £¬ÎÒÃÇ¿ÉÒÔͨ¹ýʹÓÃIlluminateDatabaseDatabaseManagerÀàÀ´ÅþÁ¬²î±ðÀàÐ͵ÄÊý¾Ý¿â¡£Õâ¸öÀàÊÇLaravel¿ò¼ÜÖÐÓÃÀ´ÖÎÀíÊý¾Ý¿âÅþÁ¬µÄÖ÷ÒªÀà¡£

ÔÚLaravel¿ò¼ÜÖÐ £¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÒªÁìÀ´»ñÈ¡²î±ðÀàÐ͵ÄÊý¾Ý¿âÅþÁ¬£º

DB::connection(‘connection_name’)£º»ñÈ¡ÌØÃüÃû³ÆµÄÊý¾Ý¿âÅþÁ¬¡£

DB::getPdo()£º»ñÈ¡Ä¿½ñʹÓõÄPDOʵÀý¡£

DB::table(‘table_name’)£º»ñÈ¡Ö¸¶¨Ãü¾Ý±íµÄÅÌÎʽṹÆ÷ʵÀý¡£

ÔÚLaravel¿ò¼ÜÖÐ £¬ÎÒÃÇ¿ÉÒÔÔÚconfig/database.phpÎļþÖнç˵²î±ðµÄÊý¾Ý¿âÅþÁ¬ÉèÖÃÐÅÏ¢¡£ÀýÈç £¬ÏÂÃæÊÇÒ»¸öMySQLÊý¾Ý¿âÅþÁ¬ÉèÖõÄʾÀý£º

'mysql' => [
    'driver' => 'mysql',
    'host' => env('DB_HOST', '127.0.0.1'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('DB_DATABASE', 'forge'),
    'username' => env('DB_USERNAME', 'forge'),
    'password' => env('DB_PASSWORD', ''),
    'unix_socket' => env('DB_SOCKET', ''),
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'prefix' => '',
    'strict' => true,
    'engine' => null,
],

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÉèÖÃÐÅÏ¢ÖÐ £¬ÎÒÃÇ¿ÉÒÔÉèÖòî±ðµÄÊý¾Ý¿âÅþÁ¬²ÎÊý £¬ÀýÈ磺Êý¾Ý¿âЧÀÍÆ÷µÄIPµØµã¡¢¶Ë¿ÚºÅ¡¢Êý¾Ý¿âÃû³Æ¡¢Óû§Ãû¡¢ÃÜÂëµÈµÈ¡£

¶þ¡¢Êý¾Ý¿âÅþÁ¬µÄ³¬Ê±ÎÊÌâ

ÔÚһЩÇéÐÎÏ £¬ÎÒÃÇ¿ÉÄ᷺ܻÆðÊý¾Ý¿âÅþÁ¬³¬Ê±µÄÎÊÌâ¡£ÕâÖÖÇéÐÎͨ³£±¬·¢ÔÚÊý¾Ý¿â³¤Ê±¼äûÓÐÏìÓ¦»òÕßÍøÂçÅþÁ¬·ºÆðÎÊÌâµÄÇéÐÎÏ¡£µ±Êý¾Ý¿âÅþÁ¬³¬Ê±Ê± £¬×ðÁú¿­Ê±Ó¦ÓóÌÐò¿ÉÄ᷺ܻÆð¹ýʧ £¬ÉõÖÁÍ߽⡣Òò´Ë £¬ÎÒÃÇÐèÒª¶ÔLaravel¿ò¼ÜÖеÄÊý¾Ý¿âÅþÁ¬¾ÙÐÐһЩÉèÖà £¬ÒÔ×èÖ¹·ºÆð³¬Ê±µÄÇéÐΡ£

Èý¡¢Êý¾Ý¿âÅþÁ¬³¬Ê±µÄ½â¾ö¼Æ»®

ÔÚLaravel¿ò¼ÜÖÐ £¬ÎÒÃÇ¿ÉÒÔͨ¹ýÐÞ¸Äconfig/database.phpÎļþÖеÄÉèÖÃÐÅÏ¢ £¬À´ÉèÖÃÊý¾Ý¿âÅþÁ¬µÄ³¬Ê±Ê±¼ä¡£

µ¥¸öÊý¾Ý¿âÅþÁ¬µÄ³¬Ê±ÉèÖÃ

ÎÒÃÇ¿ÉÒÔÔÚµ¥¸öÊý¾Ý¿âÅþÁ¬µÄÉèÖÃÐÅÏ¢ÖÐ £¬ÉèÖÃÅþÁ¬µÄ³¬Ê±Ê±¼ä¡£ÀýÈç £¬ÎÒÃÇ¿ÉÒÔÔÚMySQLÊý¾Ý¿âÅþÁ¬µÄÉèÖÃÖÐÉèÖÃ’connect_timeout’²ÎÊý £¬À´ÉèÖÃÅþÁ¬µÄ³¬Ê±Ê±¼ä£º

'mysql' => [
    'driver' => 'mysql',
    'host' => env('DB_HOST', '127.0.0.1'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('DB_DATABASE', 'forge'),
    'username' => env('DB_USERNAME', 'forge'),
    'password' => env('DB_PASSWORD', ''),
    'unix_socket' => env('DB_SOCKET', ''),
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'prefix' => '',
    'strict' => true,
    'engine' => null,
    'options' => [
        PDO::ATTR_TIMEOUT => 5,
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        PDO::ATTR_PERSISTENT => false,
        PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8mb4', time_zone = '+08:00'",
        PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
        PDO::MYSQL_ATTR_READ_DEFAULT_FILE => '/usr/local/etc/my.cnf',
    ],
],

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÉèÖÃÐÅÏ¢ÖÐ £¬ÎÒÃÇÉèÖÃÁËPDO::ATTR_TIMEOUT²ÎÊýµÄֵΪ5Ãë¡£ÕâÒâζ×Å £¬ÈôÊÇÅþÁ¬µÄʱ¼äÁè¼Ý5Ãë £¬Laravel¿ò¼Ü¾Í»áÅ׳öÒ»¸öÅþÁ¬³¬Ê±µÄ¹ýʧ¡£

ËùÓÐÊý¾Ý¿âÅþÁ¬µÄ³¬Ê±ÉèÖÃ

ÎÒÃÇÒ²¿ÉÒÔÔÚconfig/database.phpÎļþÖÐ £¬ÉèÖÃËùÓÐÊý¾Ý¿âÅþÁ¬µÄ³¬Ê±Ê±¼ä¡£ÀýÈç £¬ÎÒÃÇ¿ÉÒÔÌí¼ÓÒÔÏ´úÂ룺

'options' => [
    PDO::ATTR_TIMEOUT => 5,
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    PDO::ATTR_PERSISTENT => false,
    PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8mb4', time_zone = '+08:00'",
    PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
    PDO::MYSQL_ATTR_READ_DEFAULT_FILE => '/usr/local/etc/my.cnf',
],

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÉèÖÃÐÅÏ¢ÖÐ £¬ÎÒÃÇͬÑùÉèÖÃÁËPDO::ATTR_TIMEOUT²ÎÊýµÄֵΪ5Ãë¡£ÕâÒâζ×Å £¬ÎÞÂÛÊÇÄĸöÊý¾Ý¿âÅþÁ¬ £¬ËüÃǵÄÅþÁ¬³¬Ê±Ê±¼ä¾ùΪ5Ãë¡£ÕâÖÖÉèÖ÷½·¨ £¬¿ÉÒÔÀû±ãµØͳһÖÎÀíËùÓеÄÊý¾Ý¿âÅþÁ¬ £¬²¢ÇÒÒ×ÓÚά»¤¡£

ËÄ¡¢×ܽá

ÔÚLaravel¿ò¼ÜÖÐ £¬Êý¾Ý¿âÅþÁ¬µÄ³¬Ê±ÎÊÌâÊÇÒ»¸ö·Ç¾­³£¼ûµÄÎÊÌ⡣ΪÁË×èÖ¹ÕâÖÖÎÊÌâµÄ±¬·¢ £¬ÎÒÃÇ¿ÉÒÔͨ¹ýÉèÖÃÊý¾Ý¿âÅþÁ¬µÄ³¬Ê±Ê±¼äÀ´½â¾öÕâ¸öÎÊÌâ¡£ËäÈ» £¬ÎÒÃÇ»¹¿ÉÒÔʹÓÃÆäËûµÄÒªÁìÀ´ÓÅ»¯Laravel¿ò¼ÜµÄÊý¾Ý¿âÅþÁ¬ £¬ÀýÈçʹÓÃÅþÁ¬³ØµÈÊÖÒÕÊֶΡ£²»¹ÜÊÇÄÄÖÖÒªÁì £¬¶¼¿ÉÒÔÈÃÎÒÃǸüºÃµØÖÎÀí¡¢ÓÅ»¯Laravel¿ò¼ÜµÄÊý¾Ý¿âÅþÁ¬ £¬´Ó¶øÌá¸ßÓ¦ÓóÌÐòµÄÐÔÄܺÍÎȹÌÐÔ¡£

ÒÔÉϾÍÊÇlaravel¿ò¼Üdb³¬Ê±ÉèÖõÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿