知道为什么我的 Doctrine 1.2 模型返回整数定义字段的字符串值吗?
基本模型定义为:
abstract class Kwis_Model_Base_User extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('user');
$this->hasColumn('id', 'integer', 4, array(
'unsigned' => true,
'primary' => true,
'autoincrement' => true,
));
// more fields
// ...
}
表模型定义为:
class Kwis_Model_UserTable extends Kwis_Model_BaseTable
{
/**
* Returns an instance of this class.
*
* @return object Kwis_Model_UserTable
*/
public static function getInstance()
{
$table = Doctrine_Core::getTable('Kwis_Model_User');
return $table;
}
// other methods
// ...
}
示例控制器代码:
class TestController extends Zend_Controller_Action
{
public function indexAction()
{
$userTable = Kwis_Model_UserTable::getInstance();
$user = $userTable->find(1);
echo "<pre>" . var_dump($user->id) . "</pre>"; die();
}
}
产生的输出:
string '1' (length=1)
任何想法,非常感谢。;-)