Primary key column(s) (id) are not columns in this table ()

南楼画角 提交于 2019-12-01 22:08:58

Zend_Db_Table_Abstract contains a protected property called _primary which defaults to id.

It assumes that id is the table's primary key and is a sequence (auto increment).

Since your table definition says that id is a primary key, you should get rid of the second SQL command that adds an index on the id column. Since its already a primary key, it is an index.

Delete the table and re-create it using the create table statement you have in your question, just don't do the CREATE INDEX part. After that you should be able to continue.

I think that your SQL schema is incorrect. Try to create table with primary kyy like this:

CREATE TABLE guestbook (
    id INTEGER NOT NULL AUTO_INCREMENT,
    email VARCHAR(32) NOT NULL DEFAULT 'noemail@test.com',
    comment TEXT NULL,
    created DATETIME NOT NULL,
    PRIMARY KEY (id)
);

This error might be induced by (accidentally) using md5(null) as the cache ID. Or any other customary values, for that matter, e.g. 1, 0, true, false. However, null is very likely to be the culprit in this context, as it could be produced by an undefined variable.

A fix could be as simple as:

    $cache = Zend_Registry::get('cache');
    $cache->remove(md5(null));

I had the same issue. The problem was that database was created in guestbook-dev.db instead of guestbook.db. You can check it by looking into this files. The solution was to change scripts/load.sqlite.php from
defined('APPLICATION_ENV') || define('APPLICATION_ENV', (null === $env) ? 'development' : $env);
to:
defined('APPLICATION_ENV') || define('APPLICATION_ENV', (null === $env) ? 'production' : $env);
and, of course, running the script once again.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!