当前位置: 首页>>代码示例>>PHP>>正文


PHP DataMapper::delete方法代码示例

本文整理汇总了PHP中DataMapper::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP DataMapper::delete方法的具体用法?PHP DataMapper::delete怎么用?PHP DataMapper::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataMapper的用法示例。


在下文中一共展示了DataMapper::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Section

 function delete_with_sub()
 {
     // getting the subsections
     $c = new Section();
     $c->where('parent_section', $this->id);
     $c->get();
     // delete all subsections relations
     $c->delete_all();
     // delete all children
     $cont = new Content();
     $cont->get_where_parent_section($this->id);
     $cont->delete_all();
     // update all the sections sort after that section
     // that in the same parent section
     $s = new Section();
     $s->where('sort >', $this->sort);
     $s->where('parent_section', $this->parent_section);
     $s->get();
     foreach ($s->all as $item) {
         $item->sort--;
         $item->save();
     }
     //delete this section
     parent::delete($object);
 }
开发者ID:sigit,项目名称:vunsy,代码行数:25,代码来源:section.php

示例2: delete

 function delete($object = '')
 {
     if (empty($object)) {
         $this->deattach();
     }
     return parent::delete($object);
 }
开发者ID:blumine,项目名称:vunsy,代码行数:7,代码来源:content.php

示例3: delete

 function delete($o = null, $log = true)
 {
     if ($log) {
         $this->logActivity('deleted');
     }
     parent::delete();
 }
开发者ID:broofa,项目名称:socipedia,代码行数:7,代码来源:basemodel.php

示例4: delete

 /**
  * Delete this student or related object.
  * If no parameters are set, this method deletes current student and all participant record related with this student.
  * @param DataMapper|string $object related object to delete from relation.
  * @param string $related_field relation internal name.
  */
 public function delete($object = '', $related_field = '')
 {
     if (empty($object) && !is_array($object) && !empty($this->id)) {
         $participant = new Participant();
         $participant->where_related($this);
         $participant->get();
         $participant->delete_all();
     }
     parent::delete($object, $related_field);
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:16,代码来源:student.php

示例5: delete

 /**
  * Delete this test or related object.
  * If no parameters are set, this method deletes current test and all files associated with this test.
  * @param DataMapper|string $object related object to delete from relation.
  * @param string $related_field relation internal name.
  */
 public function delete($object = '', $related_field = '')
 {
     if (empty($object) && !is_array($object) && !empty($this->id)) {
         $path_to_test_files = 'private/uploads/unit_tests/test_' . $this->id;
         if (file_exists($path_to_test_files)) {
             unlink_recursive($path_to_test_files, TRUE);
         }
     }
     parent::delete($object, $related_field);
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:16,代码来源:test.php

示例6: delete

 /**
  * Deletes relations (if parameters are set) or this object from database.
  * All comments which replies to this one will be deleted as well.
  * @param DataMapper|string $object related object to delete from relation.
  * @param string $related_field relation internal name.
  */
 public function delete($object = '', $related_field = '')
 {
     $this_id = $this->id;
     if (empty($object) && !is_array($object) && !empty($this_id)) {
         $comments = $this->comment->get_iterated();
         foreach ($comments as $comment) {
             $comment->delete();
         }
     }
     parent::delete($object, $related_field);
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:17,代码来源:comment.php

示例7: delete

 /**
  * delete that section with all it's subsections
  * plus eliminate the gap between it's siblings sort
  **/
 public function delete($object = '', $related_field = '')
 {
     if (empty($object)) {
         // update all the sections sort after that section
         // that in the same parent section
         $s = new Section();
         $s->where('sort >', $this->sort);
         $s->where('parent_section', $this->parent_section);
         $s->get();
         foreach ($s as $item) {
             $item->sort--;
             $item->save();
         }
     }
     //delete this section
     parent::delete($object, $related_field);
 }
开发者ID:kabircse,项目名称:Codeigniter-Egypt,代码行数:21,代码来源:section.php

示例8: delete

 /**
  * Delete this object from database or specified relations.
  * If this object is deleted, all student files will be deleted as well.
  * @param DataMapper|string $object related object to delete from relation.
  * @param string $related_field relation internal name.
  */
 public function delete($object = '', $related_field = '')
 {
     $this_id = $this->id;
     $this_task_set_id = $this->task_set_id;
     $this_student_id = $this->student_id;
     parent::delete($object, $related_field);
     if (empty($object) && !is_array($object) && !empty($this_id)) {
         $task_set = new Task_set();
         $task_set->get_by_id($this_task_set_id);
         if ($task_set->exists()) {
             $student_files = $task_set->get_student_files($this_student_id);
             if (count($student_files) > 0) {
                 foreach ($student_files as $file) {
                     @unlink($file['filepath']);
                 }
             }
         }
     }
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:25,代码来源:solution.php

示例9: delete

 /**
  * Delete this period or related object.
  * If no parameters are set, this method deletes current period and re-sort all other periods.
  * @param DataMapper|string $object related object to delete from relation.
  * @param string $related_field relation internal name.
  */
 public function delete($object = '', $related_field = '')
 {
     if (empty($object) && !is_array($object) && !empty($this->id)) {
         $lower_periods = new Period();
         $lower_periods->order_by('sorting', 'asc');
         $lower_periods->where('sorting > ', $this->sorting);
         $lower_periods->get_iterated();
         $ids = array();
         foreach ($lower_periods as $lower_period) {
             $ids[] = $lower_period->id;
         }
         if (count($ids) > 0) {
             $this->db->set('sorting', 'sorting-1', FALSE);
             $this->db->where_in('id', $ids);
             $this->db->update('periods');
         }
     }
     parent::delete($object, $related_field);
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:25,代码来源:period.php

示例10: delete

 function delete($object = '')
 {
     if (empty($object)) {
         $c = $this->children();
         foreach ($c as $item) {
             $item->delete();
         }
     }
     $this->deattach();
     return parent::delete($object);
 }
开发者ID:sigit,项目名称:vunsy,代码行数:11,代码来源:content.php

示例11: delete

 /**
  * Deletes relations (if parameters are set) or this object from database.
  * All solutions related to this task set will be deleted as well.
  * @param DataMapper|string $object related object to delete from relation.
  * @param string $related_field relation internal name.
  */
 public function delete($object = '', $related_field = '')
 {
     $this_id = $this->id;
     if (empty($object) && !is_array($object) && !empty($this_id)) {
         $solutions = new Solution();
         $solutions->get_by_related('task_set', 'id', $this_id);
         foreach ($solutions as $solution) {
             set_time_limit(ini_get('max_execution_time'));
             $solution->delete();
         }
     }
     parent::delete($object, $related_field);
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:19,代码来源:task_set.php

示例12: array

 /**
  * Convert an associative array back into a DataMapper model.
  *
  * If $fields is provided, missing fields are assumed to be empty checkboxes.
  * Alse if $sub_array is TRUE, will save related object provided by sub array
  *
  * @param    DataMapper $object The DataMapper Object to save to.
  * @param    array $data A an associative array of fields to convert.
  * @param    array $fields Array of 'safe' fields.  If empty, only includes the database columns.
  * @param    bool $sub_array If TRUE - will save provided by subarray related obj
  * @param    bool $save If TRUE, then attempt to save the object automatically.
  * @return    array|bool A list of newly related objects, or the result of the save if $save is TRUE.
  * If $sub_array TRUE, return array('error','created_ids')
  */
 function save_from($object, $data, $fields = '', $sub_array = FALSE, $save = TRUE)
 {
     // keep track of newly related objects
     $new_related_objects = array();
     $error = '';
     //error string
     $created_ids = array();
     //stores array of newly created ids ('related_class_name' => array(ids))
     // Assume all database columns.
     // In this case, simply store $fields that are in the $data array.
     $object_fields = $object->fields;
     if (in_array('password', $object_fields)) {
         $object_fields[] = 'password_confirm';
     }
     foreach ($data as $k => $v) {
         if (in_array($k, $object_fields)) {
             $object->{$k} = $v;
         }
     }
     if (!empty($fields)) {
         // If $fields is provided, assume all $fields should exist.
         foreach ($fields as $f) {
             if (array_key_exists($f, $object->has_one)) {
                 // Store $has_one relationships
                 $c = get_class($object->{$f});
                 $rel = new $c();
                 $id = isset($data[$f]) ? $data[$f] : 0;
                 $rel->get_by_id($id);
                 if ($rel->exists()) {
                     // The new relationship exists, save it.
                     $new_related_objects[$f] = $rel;
                 } else {
                     // The new relationship does not exist, delete the old one.
                     $object->delete($object->{$f}->get());
                 }
             } else {
                 if (array_key_exists($f, $object->has_many)) {
                     // Store $has_many relationships
                     $c = get_class($object->{$f});
                     $ids = isset($data[$f]) ? $data[$f] : FALSE;
                     $has_join_table = false;
                     if (!empty($object->has_many[$f]['join_table'])) {
                         $has_join_table = true;
                         //so, do not delete the record, only the relation
                     }
                     if ($sub_array) {
                         $error_classes_to_check = array();
                         $created_ids[$f] = array();
                         if (empty($ids)) {
                             $old_related_obj = $object->{$f}->select('id')->get();
                             if ($has_join_table) {
                                 $object->delete($old_related_obj);
                                 //delete relation to related object
                             } else {
                                 $old_related_obj->delete_all();
                                 //delete related object
                             }
                         } else {
                             $related_ids = array();
                             foreach ($ids as $related_row) {
                                 $create = false;
                                 if (isset($related_row['id']) && $related_row['id']) {
                                     $id = $related_row['id'];
                                     $related_ids[] = $id;
                                     //add to list of provided ids
                                     unset($related_row['id']);
                                     //useless any more
                                 } else {
                                     $id = null;
                                     $create = true;
                                 }
                                 $related_obj = new $c($id);
                                 foreach ($related_row as $column => $value) {
                                     $related_obj->{$column} = $value;
                                     //fill object with new values
                                 }
                                 if ($create) {
                                     //create new record
                                     if (!$related_obj->save()) {
                                         $error .= $related_obj->error->string;
                                     } else {
                                         $created_ids[$f][] = $related_obj->id;
                                         //add id to returned array
                                     }
                                 }
                                 $error_classes_to_check[] = $f;
//.........这里部分代码省略.........
开发者ID:andrewkrug,项目名称:repucaution,代码行数:101,代码来源:save_from.php

示例13: delete

 /**
  * delete this content from database
  * that will deattach the content from it's parent 
  * and remove the sort gab between siblings 
  * 
  * @param $object
  * @param $related_field
  * @return boolean
  */
 public function delete($object = '', $related_field = '')
 {
     $this->deattach();
     return parent::delete($object, $related_field);
 }
开发者ID:kabircse,项目名称:Codeigniter-Egypt,代码行数:14,代码来源:content.php

示例14: delete

 /**
  * Deletes relations (if parameters are set) or this object from database.
  * @param DataMapper|string $object related object to delete from relation.
  * @param string $related_field relation internal name.
  */
 public function delete($object = '', $related_field = '')
 {
     $this_id = $this->id;
     parent::delete($object, $related_field);
     if (empty($object) && !is_array($object) && !empty($this_id)) {
         $tests = new Test();
         $tests->where_related($this);
         $tests->get();
         if ($tests->result_count()) {
             foreach ($tests->all as $test) {
                 $test->delete();
             }
         }
         $path = 'private/uploads/task_files/task_' . intval($this_id) . '/';
         if (file_exists($path)) {
             unlink_recursive($path, TRUE);
         }
     }
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:24,代码来源:task.php

示例15: array

 /**
  * Convert an associative array back into a DataMapper model.
  *
  * If $fields is provided, missing fields are assumed to be empty checkboxes.
  *
  * @param	DataMapper $object The DataMapper Object to save to.
  * @param	array $data A an associative array of fields to convert.
  * @param	array $fields Array of 'safe' fields.  If empty, only includes the database columns.
  * @param	bool $save If TRUE, then attempt to save the object automatically.
  * @return	array|bool A list of newly related objects, or the result of the save if $save is TRUE
  */
 function from_array($object, $data, $fields = '', $save = FALSE)
 {
     // keep track of newly related objects
     $new_related_objects = array();
     // Assume all database columns.
     // In this case, simply store $fields that are in the $data array.
     if (empty($fields)) {
         $fields = $object->fields;
         foreach ($data as $k => $v) {
             if (in_array($k, $fields)) {
                 $object->{$k} = $v;
             }
         }
     } else {
         // If $fields is provided, assume all $fields should exist.
         foreach ($fields as $f) {
             if (array_key_exists($f, $object->has_one)) {
                 // Store $has_one relationships
                 $c = get_class($object->{$f});
                 $rel = new $c();
                 $id = isset($data[$f]) ? $data[$f] : 0;
                 $rel->get_by_id($id);
                 if ($rel->exists()) {
                     // The new relationship exists, save it.
                     $new_related_objects[$f] = $rel;
                 } else {
                     // The new relationship does not exist, delete the old one.
                     $object->delete($object->{$f}->get());
                 }
             } else {
                 if (array_key_exists($f, $object->has_many)) {
                     // Store $has_many relationships
                     $c = get_class($object->{$f});
                     $rels = new $c();
                     $ids = isset($data[$f]) ? $data[$f] : FALSE;
                     if (empty($ids)) {
                         // if no IDs were provided, delete all old relationships.
                         $object->delete($object->{$f}->select('id')->get()->all);
                     } else {
                         // Otherwise, get the new ones...
                         $rels->where_in('id', $ids)->select('id')->get();
                         // Store them...
                         $new_related_objects[$f] = $rels->all;
                         // And delete any old ones that do not exist.
                         $old_rels = $object->{$f}->where_not_in('id', $ids)->select('id')->get();
                         $object->delete($old_rels->all);
                     }
                 } else {
                     // Otherwise, if the $data was set, store it...
                     if (isset($data[$f])) {
                         $v = $data[$f];
                     } else {
                         // Or assume it was an unchecked checkbox, and clear it.
                         $v = FALSE;
                     }
                     $object->{$f} = $v;
                 }
             }
         }
     }
     if ($save) {
         // Auto save
         return $object->save($new_related_objects);
     } else {
         // return new objects
         return $new_related_objects;
     }
 }
开发者ID:mehulsbhatt,项目名称:sparks-datamapper,代码行数:79,代码来源:array.php


注:本文中的DataMapper::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。