Laravel 5与Postgres SQL

编程入门 行业动态 更新时间:2024-10-23 21:30:53
本文介绍了Laravel 5与Postgres SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用以postgres为数据库的Laravel 5.我已经配置了postgres 9.4和pgAdmin III,它们都可以正常工作.当我尝试运行迁移时,它给我错误:

I’m working on Laravel 5 with postgres as database. I’ve configured postgres 9.4 and pgAdmin III and these are working normally. When I try to run migrate it is giving me error:

[PDOException] 找不到驱动程序

[PDOException] could not find driver

这是我的database.php

This is my database.php

'default' => 'pgsql', 'pgsql' => [ 'driver' => 'pgsql', 'host' => '127.0.0.1', 'database' => 'fms', 'username' => 'postgres', 'password' => 'root', 'charset' => 'utf8', 'prefix' => '', 'schema' => 'public', ],

虽然我最初是由于Windows 7上的postgres配置,但是我尝试使用纯PHP使其完美运行

Initially I though, it was due to configuration of postgres on windows 7 but I tried with plain php it works perfect

<?php $host = "host=127.0.0.1"; $port = "port=5432"; $dbname = "dbname=fms"; $db = pg_connect( "$host $port $dbname user=postgres password=root" ); if(!$db){ echo "Error : Unable to open database\n"; } else { echo "Opened database successfully\n"; } ?>

我还启用了 php_pgsql 和 php_pdo_sql .我不确定如何在laravel 5上解决此问题.

I’ve enabled php_pgsql and php_pdo_sql in wamp as well. I’m not sure how to fix this on laravel 5.

推荐答案

正如您所说,您已经选择了Default Database作为Postgres SQL

As you said you already choosed Default Database as Postgres SQL

'default' => 'pgsql',

这是必须取消对php配置设置(php.ini)

It is a must that you need to uncomment the pdo and postgres shared object in your php configuration settings (php.ini)

即,您需要在php.ini中取消注释以下行

i.e., You need to uncomment the following lines in your php.ini

extension=pdo_pgsql.so extension=pgsql.so

注意:

做完这些更改后,别忘了停止并启动apache(或者使用php-fpm代替).

Don't forget to stop and start your apache after doing this changes (or php-fpm if using that instead).

更多推荐

Laravel 5与Postgres SQL

本文发布于:2023-10-13 10:25:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1487695.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Laravel   Postgres   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!