DeyaEldeen
DeyaEldeen

Reputation: 11827

Why a YII blog connects to sqlite well, but not to mysql?

I have successfully rolled a test blog that supports restful api using Yii 1.1.x, I use ampps in mac, everything works fine when I use SQLite database, I'm able to see all API responses normally, I followed this tutorial and did some fixes of the source code in that page.

the problem is, when I switched to MYSQL database by

switching from

'db'=>array(
    'connectionString' => '"mysql:host=localhost,dbname=testdrive" Username="root" Password="1234"'),

to

'db'=>array(
    'connectionString'=>'mysql:host=localhost;dbname=test',
    'username'=>'deya',
    'password'=>'',
    //'tablePrefix' => "post",
),

in config/main.php

then this error shows up

Error 500 The table "{{post}}" for active record class "Post" cannot be found in the database.

the database structure is

enter image description here

if this is usefull, you can find the source code of my test blog source code

Upvotes: 0

Views: 76

Answers (1)

Muhammad Uzair Khan
Muhammad Uzair Khan

Reputation: 82

try using 127.0.0.1 instead of localhost. Also, can you post start of your models/Post.php code here?

Update: Please let us know if your issue is resolved. The code seems to be fine. Does the user:deya have access to the DBName 'test' ? Can you login as deya from phpmyadmin without password?

Secondly , make sure DB 'test' has table named 'post' . If so,try using 127.0.0.1 as your host

Upvotes: 1

Related Questions