Problems creating SQLite tables


I’m sure this is a n00b problem but I need your help.

I’m trying to create the scaffolding as described on page 8 of the Yii Blog tutorial (1.0.7), but whenever I model a table I get:

[color="#0000FF"]>> model Post

Warning: the table ‘Post’ does not exist in the database.

unchanged Post.php

The following model classes are successfully generated:


If you have a ‘db’ database connection, you can test these models now with:



I was having a problem even creating the table prior to this:

[color="#0000FF"]>> model User

exception ‘CDbException’ with message ‘CDbConnection failed to open the DB connection: SQLSTATE[HY000] [14] unable to open database file’ in /Library/WebServer/Documents/yii_test/framework/db/CDbConnection.php:248

Stack trace:

#0 /Library/WebServer/Documents/yii_test/framework/db/CDbConnection.php(223): CDbConnection->open()

#1 /Library/WebServer/Documents/yii_test/framework/db/CDbConnection.php(202): CDbConnection->setActive(true)

#2 /Library/WebServer/Documents/yii_test/framework/base/CModule.php(353): CDbConnection->init()

#3 /Library/WebServer/Documents/yii_test/framework/base/CApplication.php(338): CModule->getComponent(‘db’)

#4 /Library/WebServer/Documents/yii_test/framework/cli/commands/shell/ModelCommand.php(267): CApplication->getDb()

#5 /Library/WebServer/Documents/yii_test/framework/cli/commands/ShellCommand.php(142): ModelCommand->run(Array)

#6 /Library/WebServer/Documents/yii_test/framework/cli/commands/ShellCommand.php(99): ShellCommand->runShell()

#7 /Library/WebServer/Documents/yii_test/framework/console/CConsoleCommandRunner.php(62): ShellCommand->run(Array)

#8 /Library/WebServer/Documents/yii_test/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner->run(Array)

#9 /Library/WebServer/Documents/yii_test/framework/base/CApplication.php(133): CConsoleApplication->processRequest()

#10 /Library/WebServer/Documents/yii_test/framework/yiic.php(31): CApplication->run()

#11 /Library/WebServer/Documents/yii_test/framework/yiic(15): require_once(’/Library/WebSer…’)

#12 {main}[/color]

but after using an SQLite tool (SQLite Database Browser) to create the table the initial error went away and now I’m stuck at this point.

I’ve run php_info from the cli and it reports that my php ini file is where it should be (and there’s only one ini file being returned in any case).

[color="#FF8C00"]Configuration File (php.ini) Path => /usr/local/php5/lib

Loaded Configuration File => /usr/local/php5/lib/php.ini

Scan this dir for additional .ini files => /usr/local/php5/php.d[/color]

I’m running PHP 5.2.2 on Apache 1.3.4 on Mac OS X 10.4.11

any help would be great,



Sounds like one of three things:

  1. The SQLite module is not available/loaded/configured in your PHP runtime

  2. There is a permissions problem on the SQLite file or you have specified the path wrong

  3. There is no post table in the DB, and you need to create one…



What is the result of this command?

$ sqlite3 blog.db .dump | grep CREATE

Thanks very much for this. sorry I’ve been away for a bit (work).

  1. The SQLite module is loaded - but perhaps mis-configured

  2. The SQLite file has been chmod’ed to 777

  3. I hard coded the post table into the SQLite file - but I thought the Scaffolding CRUD command would do this all for me.

thanks again I’ll have a look at the SQLite configuration.


I shall run the command and post the out put here. Thanks very much for your assistance.