views:

284

answers:

0

EDIT: Paul Witschger (doctrine-user group) suggested I change the default primary key (system/application/plugins/doctrine_pi.php) back to 'id' and change any primary keys in my MySQL tables that differ from this. It worked. Thanks

Hi,

Should I change all of my uniquely-named MySQL database primary keys (for all tables that use Doctrine) to 'id' to avoid getting errors related to Doctrine's default primary key set in the plugin 'doctrine_pi.php'?

To further elaborate, I am getting the following reoccurring error, this time after trying to login to my login page:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'u.book_id' in 'field list'' in...

I suspect the problem resides at a MySQL table used for my login, of which has a primary key called

id

Marc B originally solved an identical problem for me in this post

http://stackoverflow.com/questions/2702229/doctrine-codeigniter-mysql-crud-errors

when I had the same problem with a different table within the same database. Following his suggestion, I changed the default primary key located at

system/application/plugins/doctrine_pi.php

from 'id' to 'book_id':

<?php
// system/application/plugins/doctrine_pi.php

...

// set the default primary key to be named 'id', integer, 4 bytes
Doctrine_Manager::getInstance()->setAttribute(
    Doctrine::ATTR_DEFAULT_IDENTIFIER_OPTIONS,
    array('name' => 'book_id', 'type' => 'integer', 'length' => 4));

and that solved my previous problem. However, my login page stopped working. However, when I changed it back to 'id' the login page worked again but my previous problem came back.

So what is the safe thing to do? Change all of my primary keys to 'id' (will that solve the problem without causing some other problem I am not aware of). Or should I add some lines of code in doctrine_pi.php?