コード例 #1
0
ファイル: model.php プロジェクト: syjzwjj/quyeba
 public function delete($filter, $subSdf = 'delete')
 {
     if ($subSdf && !is_array($subSdf)) {
         $subSdf = $this->getSubSdf($subSdf);
     }
     $allHas = (array) $this->has_parent;
     foreach ($allHas as $k => $v) {
         if (array_key_exists($k, $allHas)) {
             $subInfo = explode(':', $allHas[$k]);
             $modelInfo = explode('@', $subInfo[0]);
             $appId = $modelInfo[1] ? $modelInfo[1] : $this->app->app_id;
             $o = app::get($appId)->model($modelInfo[0]);
             $pkey = $o->_getPkey($this->table_name(), $subInfo[2], $this->app->app_id);
             $tFilter = $filter;
             if ($filter[$pkey['c']]) {
                 $tmp = array();
                 $tmp = $filter[$pkey['c']];
                 unset($tFilter[$pkey['c']]);
                 $tFilter[$pkey['p']] = $tmp;
             }
             $o->delete($tFilter, $v[1]);
         }
     }
     $allHas = array_merge((array) $this->has_many, (array) $this->has_one);
     foreach ((array) $subSdf as $k => $v) {
         if (array_key_exists($k, $allHas)) {
             // $subInfo = array();
             $subInfo = explode(':', $allHas[$k]);
             $modelInfo = explode('@', $subInfo[0]);
             $appId = $modelInfo[1] ? $modelInfo[1] : $this->app->app_id;
             $pkey = $this->_getPkey($modelInfo[0], $subInfo[2], $appId);
             $this->get_pk_list($filter);
             $tFilter = $filter;
             if ($filter[$pkey['p']]) {
                 $tmp = array();
                 $tmp = $filter[$pkey['p']];
                 unset($tFilter[$pkey['p']]);
                 $tFilter[$pkey['c']] = $tmp;
             }
             $o = app::get($appId)->model($modelInfo[0]);
             $o->delete($tFilter, $v[1]);
         }
     }
     if ($this->use_meta) {
         $pk = $this->get_pk_list($filter);
         foreach ($this->metaColumn as $col) {
             $obj_meta = new dbeav_meta($this->table_name(true), $col);
             $obj_meta->delete($pk);
         }
     }
     return parent::delete($filter);
 }