delete() публичный статический Метод

Delete the value from the DB
С версии: 2.3
public static delete ( string $type, integer $id = null, string $name = null, array $options = null, array $pod = null )
$type string
$id integer
$name string
$options array
$pod array
Пример #1
0
 /**
  * Delete an object from tableless fields
  *
  * @param int $id
  * @param string $type
  * @param string $name
  *
  * @return bool
  *
  * @since 2.3
  */
 public function delete_object_from_relationships($id, $object, $name = null)
 {
     /**
      * @var $pods_init \PodsInit
      */
     global $pods_init;
     $pod = false;
     // Run any bidirectional delete operations
     if (is_array($object)) {
         $pod = $object;
     } elseif (is_object($pods_init)) {
         $pod = PodsInit::$meta->get_object($object, $name);
     }
     if (!empty($pod)) {
         $object = $pod['type'];
         $name = $pod['name'];
         foreach ($pod['fields'] as $field) {
             PodsForm::delete($field['type'], $id, $field['name'], array_merge($field, $field['options']), $pod);
         }
     }
     // Lookup related fields (non-bidirectional)
     $params = array('where' => array(array('key' => 'type', 'value' => 'pick'), array('key' => 'pick_object', 'value' => $object)));
     if (!empty($name) && $name != $object) {
         $params['where'][] = array('key' => 'pick_val', 'value' => $name);
     }
     $fields = $this->load_fields($params, false);
     if (!empty($pod) && 'media' == $pod['type']) {
         $params['where'] = array(array('key' => 'type', 'value' => 'file'));
         $fields = array_merge($fields, $this->load_fields($params, false));
     }
     if (is_array($fields) && !empty($fields)) {
         foreach ($fields as $related_field) {
             $related_pod = $this->load_pod(array('id' => $related_field['pod_id'], 'fields' => false), false);
             if (empty($related_pod)) {
                 continue;
             }
             $related_from = $this->lookup_related_items_from($related_field['id'], $related_pod['id'], $id, $related_field, $related_pod);
             $this->delete_relationships($related_from, $id, $related_pod, $related_field);
         }
     }
     if (!empty($pod) && !pods_tableless()) {
         pods_query("\n                DELETE FROM `@wp_podsrel`\n                WHERE\n                (\n                    `pod_id` = %d\n                    AND `item_id` = %d\n                )\n                OR (\n                    `related_pod_id` = %d\n                    AND `related_item_id` = %d\n                )\n            ", array($pod['id'], $id, $pod['id'], $id));
     }
     return true;
 }