本文整理汇总了PHP中PodsForm::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP PodsForm::delete方法的具体用法?PHP PodsForm::delete怎么用?PHP PodsForm::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PodsForm
的用法示例。
在下文中一共展示了PodsForm::delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete_object_from_relationships
/**
* 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;
}