我有一个定义如下的字段:
class Subcategory extends BaseSubcategory {}
abstract class BaseSubcategory extends Doctrine_Record
{
public function setTableDefinition()
{
// ...
$this->hasColumn('meta_description', 'string', 255);
// ...
}
// ...
}
表格如下所示:
mysql> DESCRIBE subcategory;
+----------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
[...]
| meta_description | varchar(255) | YES | | NULL | |
[...]
+----------------------+------------------+------+-----+---------+----------------+
10 rows in set (0.00 sec)
这是我保存记录的代码
$m = new Subcategory;
// ...
$m->meta_description = null;
$m->save();
我收到以下验证错误
* 1 validator failed on meta_description (length)
为什么会这样?