user514340 user514340 - 7 months ago 10
PHP Question

How can I modify the primary key name in Doctrine

The Doctrine will set "id" as the default primary key, how can I modify it?
My table only has two colums, there are "type_code" and "type_name", and "type_code" is the prmary key.

Answer

here is sample table definition would help you :)

class typetable extends Doctrine_Record
{
public function setTableDefinition()
{
  $this->setTableName('your table name ');
  $this->hasColumn('type_code', 'integer', 8, array('type' => 'integer',
  'length' => 8, 'primary' => true, 'autoincrement' => true));
  $this->hasColumn('type_name', 'string', 255, array('type' =>
  'string', 'length' => 255));
}
 /////   extra code here ...... 
}