如何声明Zend_Db_Table_Row数据库表?

时间:2011-12-17 01:37:24

标签: zend-framework zend-db zend-db-table

我有以下zendframework模型类

class Application_Model_DbTable_Mobile extends Zend_Db_Table_Abstract {

protected $_name = 'mobile';
protected $_rowClass = 'Application_Model_Mobile';
}

对象类

class Application_Model_Mobile extends Zend_Db_Table_Row_Abstract {



}

但是当我尝试直接从o Application Model_Mobile中保存时,它会返回错误

 $m = new Application_Model_Mobile();
 $m->name = 'Mobile Test';
 $m->save();

 Application error
 Exception information:

 Message: Specified column "chave" is not in the row 

我怎么能告诉Application_Model_Celular有移动表?

1 个答案:

答案 0 :(得分:0)

尝试:

class Application_Model_Mobile extends Zend_Db_Table_Row_Abstract {
     protected $_tableClass = 'Application_Model_DbTable_Mobile';


}

通常你不会以这种方式使用Zend_Db(尽管你可能有充分的理由)。执行此操作的标准方法是不定义Application_Model_Mobile类,只需将代码编写为:

$table = new Application_Model_DbTable_Mobile();
$m = $table->createRow();
$m->name = 'Mobile Test';
$m->save();