本文整理匯總了PHP中Model_Config::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Config::delete方法的具體用法?PHP Model_Config::delete怎麽用?PHP Model_Config::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model_Config
的用法示例。
在下文中一共展示了Model_Config::delete方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: delete
/**
* delete current widget data from the DB config
* @return boolean
*/
public function delete()
{
if ($this->loaded) {
// save widget to DB
$confw = new Model_Config();
$confw->where('group_name', '=', 'widget')->where('config_key', '=', $this->widget_name)->limit(1)->find();
if ($confw->loaded()) {
try {
$confw->delete();
//remove from previous placeholder, only if they are different
$confp = new Model_Config();
$confp->where('group_name', '=', 'placeholder')->where('config_key', '=', $this->placeholder)->limit(1)->find();
if ($confp->loaded()) {
//remove the key
$wid = json_decode($confp->config_value);
if (is_array($wid)) {
$wid = array_diff($wid, array($this->widget_name));
$confp->config_value = json_encode(array_values($wid));
$confp->save();
}
}
$this->data = array();
$this->loaded = FALSE;
return TRUE;
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
}
}
return FALSE;
}
示例2: delete
/**
* delete current widget data from the DB config
* @return boolean
*/
public function delete()
{
if ($this->loaded) {
// save widget to DB
$confw = new Model_Config();
$confw->where('group_name', '=', 'widget')->where('config_key', '=', $this->widget_name)->limit(1)->find();
if ($confw->loaded()) {
try {
$confw->delete();
//remove from previous placeholder, only if they are different
$confp = new Model_Config();
$confp->where('group_name', '=', 'placeholder')->where('config_key', '=', $this->placeholder)->limit(1)->find();
if ($confp->loaded()) {
//remove the key
$wid = json_decode($confp->config_value);
if (is_array($wid)) {
$key = array_search($this->widget_name, $wid);
if ($key !== FALSE) {
unset($wid[$key]);
}
$confp->config_value = json_encode($wid);
$confp->save();
}
}
$this->data = array();
$this->loaded = FALSE;
return TRUE;
} catch (Exception $e) {
throw new HTTP_Exception_500($e);
}
}
}
return FALSE;
}