我只是从Laravel repo克隆了git并设置了pgSQL数据库的详细信息。接下来,我尝试使用artisan
创建session
表。
php artisan session:table
然而,这给了我以下错误:
X-Powered-By: PHP/5.3.16
Content-type: text/html
<br />
<b>Fatal error</b>: Uncaught exception 'Laravel\Database\Exception' with message 'SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "sessions" does not exist
LINE 1: SELECT * FROM "sessions" WHERE "id" = $1 LIMIT 1
^
SQL: SELECT * FROM "sessions" WHERE "id" = ? LIMIT 1
Bindings: array (
0 => 'i8qwmexP1joUkSLDH7naRayJDiSrLFGQa4xeubgz',
)' in /home/dev/public_html/laravel/database/connection.php:263
Stack trace:
#0 /home/dev/public_html/laravel/database/connection.php(183): Laravel\Database\Connection->execute('SELECT * FROM "...', Array)
#1 /home/dev/public_html/laravel/database/query.php(648): Laravel\Database\Connection->query('SELECT * FROM "...', Array)
#2 /home/dev/public_html/laravel/database/query.php(592): Laravel\Database\Query->get(Array)
#3 /home/dev/public_html/laravel/database/query.php(563): Laravel\Database\Query->first(Array)
#4 /home/dev/public_html/laravel/session/drivers/database.php(36): Laravel\Database\Query->find('i8qwmexP1joUkSL...')
#5 /home/dev/public_html/laravel/session/dri in <b>/home/dev/public_html/laravel/database/connection.php</b> on line <b>263</b><br />
当我将数据库驱动程序切换到mysql
时,我收到以下消息:
X-Powered-By: PHP/5.3.16
Content-type: text/html
You forgot to provide the task name.
执行SQL查询虽然有效,但artisan
没有。
CREATE TABLE `sessions` (
`id` VARCHAR(40) NOT NULL,
`last_activity` INT(10) NOT NULL,
`data` TEXT NOT NULL,
PRIMARY KEY (`id`)
);
使用pgSQL驱动程序时,如何解决此错误?不知道这里出了什么问题。
答案 0 :(得分:-1)
尝试从查询中删除单引号:
CREATE TABLE sessions (
id VARCHAR(40) NOT NULL,
last_activity INT(10) NOT NULL,
data TEXT NOT NULL,
PRIMARY KEY (id)
);