Welcome Guest, Not a member yet? Register   Sign In
Doctrine Default Primary Key Problem (Again)
#1

[eluser]01010011[/eluser]
Hi,

Should I change all of my uniquely-named MySQL database primary keys 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:

Quote: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

Quote:id

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

Code:
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

Quote:system/application/plugins/doctrine_pi.php

from 'id' to 'book_id':

Code:
<?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.

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?


Messages In This Thread
Doctrine Default Primary Key Problem (Again) - by El Forum - 04-25-2010, 09:36 PM
Doctrine Default Primary Key Problem (Again) - by El Forum - 04-26-2010, 10:05 AM
Doctrine Default Primary Key Problem (Again) - by El Forum - 04-26-2010, 10:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB