本文整理汇总了PHP中EEM_Base::get_one_by_ID方法的典型用法代码示例。如果您正苦于以下问题:PHP EEM_Base::get_one_by_ID方法的具体用法?PHP EEM_Base::get_one_by_ID怎么用?PHP EEM_Base::get_one_by_ID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EEM_Base
的用法示例。
在下文中一共展示了EEM_Base::get_one_by_ID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: receive_form_submission
/**
* After the form section is initially created, call this to sanitize the data in the submission
* which relates to this form section, validate it, and set it as properties on the form.
* @param array $req_data should usually be $_REQUEST (the default). However, you CAN
* supply a different array. Consider using set_defaults() instead however. (If you rendered
* the form in the page using echo $form_x->get_html() the inputs will have the correct name
* in the request data for this function to find them and populate the form with them.
* If you have a flat form (with only input subsections), you can supply a flat array where keys
* are the form input names and values are their values)
* @param boolean $validate whether or not to perform validation on this data. Default is,
* of course, to validate that data, and set errors on the invalid values. But if the data
* has already been validated (eg you validated the data then stored it in the DB) you may want
* to skip this step.
* @return void
*/
public function receive_form_submission($req_data = NULL, $validate = TRUE)
{
parent::receive_form_submission($req_data, $validate);
//create or set the model object, if it isn't already
if (!$this->_model_object) {
//check to see if the form indicates a PK, in which case we want to only retrieve it and update it
$pk_name = $this->_model->primary_key_name();
$model_obj = $this->_model->get_one_by_ID($this->get_input_value($pk_name));
if ($model_obj) {
$this->_model_object = $model_obj;
} else {
$this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name());
}
}
//ok so the model object is set. Just set it with the submitted form data (don't save yet though)
foreach ($this->inputs_values_corresponding_to_model_fields() as $field_name => $field_value) {
//only set the non-primary key
if ($field_name != $this->_model->primary_key_name()) {
$this->_model_object->set($field_name, $field_value);
}
}
}
示例2: get_one_by_ID_but_ignore_deleted
/**
* Gets the item indicated by its ID. But if it's soft-deleted, pretends it doesn't exist.
* @param int|string $id
* @return EE_Soft_Delete_Base_Class
*/
public function get_one_by_ID_but_ignore_deleted($id)
{
return parent::get_one_by_ID($id);
}