示例#1
0
 /**
  * Check if model is valid before operating
  *
  * @return void
  */
 public static function check_model()
 {
     $model = get_called_class();
     if (empty(static::$resolved_models[$model])) {
         parent::check_model();
         $idc = static::get_id_col();
         if (!array_key_exists($idc, static::$attrs)) {
             static::add_attr($idc, array("type" => 'int', "is_unsigned" => true, "is_primary" => true, "is_autoincrement" => true));
         }
         if (!static::has_attr('created_at')) {
             static::add_attr('created_at', array("type" => 'datetime', "default" => 'CURRENT_TIMESTAMP'));
         }
         if (!static::has_attr('updated_at')) {
             static::add_attr('updated_at', array("type" => 'datetime'));
         }
         $model::check_relations();
     }
 }