Hi,
I am using CI + Doctrine + MySQL and I am getting the following CRUD errors:
(1) When trying to create a new record in the database with this code:
$book_title = 'The Peloponnesian War';
$b = new Book();
$b-title = $book_title;
$b-price = 10.50;
$b-save();
I get this error:
Fatal error: Uncaught exeption 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'title' in 'field list' in ...
(2) When trying to fetch a record from the database and display on my view page with this code:
$book_title = 'The Peloponnesian War';
$title = $book_title;
$search_results = Doctrine::getTable('Book')-findOneByTitle($title);
echo $search_results-title; (in view file)
I get this error:
Fatal error: Uncaught exception 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[45S22]: Column not found: 1054 Unknown column 'b.id' in 'field list" in ...
And finally, when I try to update a record as follows:
$book_title = 'The Peloponnesian War';
$title = $book_title;
$u = Doctrine::getTable('Book')-find($title);
$u-title = $title;
$u-save();
I get a similar error:
Fatal error: Uncaught exception
'Doctrine_Connection_Mysql_Exception'
with message 'SQLSTATE[42S22]: Column
not found: 1054 Unknown column 'b.id'
in 'field list''in ...
Here is my Doctrine_Record model:
class Book extends Doctrine_Record{
public function setTableDefinition()
{
$this->hasColumn('book_id');
$this->hasColumn('isbn10','varchar',20);
$this->hasColumn('isbn13','varchar',20);
$this->hasColumn('title','varchar',100);
$this->hasColumn('edition','varchar',20);
$this->hasColumn('author_f_name','varchar',20);
$this->hasColumn('author_m_name','varchar',20);
$this->hasColumn('author_l_name','varchar',20);
$this->hasColumn('cond','enum',null, array('values' => array('as new','very good','good','fair','poor')));
$this->hasColumn('price','decimal',8, array('scale' =>2));
$this->hasColumn('genre','varchar',20);
}
public function setUp()
{
$this->setTableName('Book');
//$this->actAs('Timestampable');
}
Any assistance will be really appreciated. Thanks in advance.