コード例 #1
0
 /**
  * Check where there is a non-related colour with the same colour name
  * @param DBModel $model
  * @return type
  */
 function model_is_duplicate(DBModel $model)
 {
     $related_models = array();
     if ($model->is_parent()) {
         foreach (get_children_models($model) as $item) {
             $related_models[] = $item->modelid;
         }
     } else {
         foreach (get_sibling_models($model) as $item) {
             $related_models[] = $item->modelid;
         }
     }
     $related_models[] = get_parent_model($model)->modelid;
     return DBModel::count(array('conditions' => array(' (trim(lower(modelname)) = ?) and ( modelid not in (?) ) ', trim(strtolower($model->modelname)), $related_models))) > 0;
 }