本文整理汇总了PHP中Region::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Region::delete方法的具体用法?PHP Region::delete怎么用?PHP Region::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Region
的用法示例。
在下文中一共展示了Region::delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doModel
//.........这里部分代码省略.........
$cities = json_decode($cities_json);
if (!isset($cities->error)) {
if (count($cities) > 0) {
foreach ($cities as $ci) {
$manager_city->insert(array("fk_i_region_id" => $region['pk_i_id'], "s_name" => $ci->name, "fk_c_country_code" => $ci->country_code));
$id = $manager_city->dao->insertedId();
CityStats::newInstance()->setNumItems($id, 0);
}
}
}
unset($cities);
unset($cities_json);
}
}
}
}
}
}
}
osc_add_flash_ok_message(sprintf(_m('%s has been added as a new country'), $countryName), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'edit_country':
// edit country
$ok = $mCountries->update(array('s_name' => Params::getParam('e_country')), array('pk_c_code' => Params::getParam('country_code')));
if ($ok) {
osc_add_flash_ok_message(_m('Country has been edited'), 'admin');
} else {
osc_add_flash_error_message(_m('There were some problems editing the country'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'delete_country':
// delete country
$countryId = Params::getParam('id');
Item::newInstance()->deleteByRegion($countryId);
$mRegions = new Region();
$mCities = new City();
$aCountries = $mCountries->findByCode($countryId);
$aRegions = $mRegions->findByCountry($aCountries['pk_c_code']);
foreach ($aRegions as $region) {
// remove city_stats
CityStats::newInstance()->deleteByRegion($region['pk_i_id']);
// remove region_stats
RegionStats::newInstance()->delete(array('fk_i_region_id' => $region['pk_i_id']));
}
//remove country stats
CountryStats::newInstance()->delete(array('fk_c_country_code' => $aCountries['pk_c_code']));
$ok = $mCountries->deleteByPrimaryKey($aCountries['pk_c_code']);
if ($ok) {
osc_add_flash_ok_message(sprintf(_m('%s has been deleted'), $aCountries['s_name']), 'admin');
} else {
osc_add_flash_error_message(sprintf(_m('There was a problem deleting %s'), $aCountries['s_name']), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'add_region':
// add region
if (!Params::getParam('r_manual')) {
$this->install_location_by_region();
} else {
$mRegions = new Region();
$regionName = Params::getParam('region');
$countryCode = Params::getParam('country_c_parent');
$country = Country::newInstance()->findByCode($countryCode);
示例2: doModel
//.........这里部分代码省略.........
}
}
unset($cities);
unset($cities_json);
}
}
}
}
}
}
}
osc_add_flash_ok_message(sprintf(_m('%s has been added as a new country'), $countryName), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'edit_country':
// edit country
$countryCode = Params::getParam('country_code');
$request = Params::getParam('e_country');
$ok = true;
foreach ($request as $k => $v) {
$result = $mCountries->updateLocale($countryCode, $k, $v);
if (!$result) {
$ok = false;
}
}
if ($ok) {
osc_add_flash_ok_message(_m('Country has been edited'), 'admin');
} else {
osc_add_flash_ok_message(_m('There were some problems editing the country'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'delete_country':
// delete country
$countryId = Params::getParam('id');
// HAS ITEMS?
$has_items = Item::newInstance()->listWhere('l.fk_c_country_code = \'%s\' LIMIT 1', $countryId);
if (!$has_items) {
$mRegions = new Region();
$mCities = new City();
$aCountries = $mCountries->findByCode($countryId);
$aRegions = $mRegions->listWhere('fk_c_country_code = \'' . $aCountries['pk_c_code'] . '\'');
foreach ($aRegions as $region) {
$mCities->delete(array('fk_i_region_id' => $region['pk_i_id']));
$mRegions->delete(array('pk_i_id' => $region['pk_i_id']));
}
$mCountries->delete(array('pk_c_code' => $aCountries['pk_c_code']));
osc_add_flash_ok_message(sprintf(_m('%s has been deleted'), $aCountries['s_name']), 'admin');
} else {
osc_add_flash_error_message(sprintf(_m('%s can not be deleted, some items are located in it'), $aCountries['s_name']), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'add_region':
// add region
if (!Params::getParam('r_manual')) {
$this->install_location_by_region();
} else {
$mRegions = new Region();
$regionName = Params::getParam('region');
$countryCode = Params::getParam('country_c_parent');
$exists = $mRegions->findByNameAndCode($regionName, $countryCode);
if (!isset($exists['s_name'])) {
$data = array('fk_c_country_code' => $countryCode, 's_name' => $regionName);
$mRegions->insert($data);
示例3: header
*
* @copyright Copyright (c) Szilard Szabo
* @license GPL v3
* @package Admin
*/
include "./include/common.php";
include "Pager/Pager.php";
if (!User::is_logged_in() || User::get_id() != 1) {
header('Location: index.php');
exit;
}
$parent = isset($_GET['parent']) ? (int) $_GET['parent'] : 0;
if (isset($_GET['d'])) {
$d = (int) $_GET['d'];
if ($d > 0) {
Region::delete($d);
}
}
if (isset($_GET['o'])) {
$o = (int) $_GET['o'];
$r = (int) $_GET['r'];
if ($r != 0) {
$r = 1;
}
Region::set_order($o, $parent, $r);
}
$tct = Region::count(array('parent' => $parent));
//total count
$rpp = 10;
//row per page
$pager_options = array('mode' => 'Sliding', 'perPage' => $rpp, 'delta' => 2, 'totalItems' => $tct, 'urlVar' => "pageID{$parent}", 'excludeVars' => array('o', 'r', 'd', 't', 'e'));
示例4: doModel
//.........这里部分代码省略.........
case 'add_country':
// add country
if (!Params::getParam('c_manual')) {
$this->install_location_by_country();
} else {
$countryCode = Params::getParam('c_country');
$countryName = Params::getParam('country');
$countryLanguage = osc_language();
$exists = $mCountries->findByCode($countryCode);
if (!isset($exists['s_name'])) {
$data = array('pk_c_code' => $countryCode, 'fk_c_locale_code' => $countryLanguage, 's_name' => $countryName);
$mCountries->insert($data);
osc_add_flash_message(sprintf(__('%s has been added as a new country'), $countryName), 'admin');
} else {
osc_add_flash_message(sprintf(__('%s already was in the database'), $countryName), 'admin');
}
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'edit_country':
// edit country
$newCountry = Params::getParam('e_country');
$oldCountry = Params::getParam('country_old');
$exists = $mCountries->findByName($newCountry);
$old_exists = $mCountries->findByName($oldCountry);
if (!isset($exists['pk_c_code']) || $exists['pk_c_code'] == $old_exists['pk_c_code']) {
$mCountries->update(array('s_name' => $newCountry), array('s_name' => $oldCountry));
osc_add_flash_message(sprintf(__('%s has been edited'), $newCountry), 'admin');
} else {
osc_add_flash_message(sprintf(__('%s already was in the database'), $newCountry), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'delete_country':
// delete country
$countryId = Params::getParam('id');
// HAS ITEMS?
$has_items = Item::newInstance()->listWhere('l.fk_c_country_code = \'%s\' LIMIT 1', $countryId);
if (!$has_items) {
$mRegions = new Region();
$mCities = new City();
$aCountries = $mCountries->findByCode($countryId);
$aRegions = $mRegions->listWhere('fk_c_country_code = \'' . $aCountries['pk_c_code'] . '\'');
foreach ($aRegions as $region) {
$mCities->delete(array('fk_i_region_id' => $region['pk_i_id']));
$mRegions->delete(array('pk_i_id' => $region['pk_i_id']));
}
$mCountries->delete(array('pk_c_code' => $aCountries['pk_c_code']));
osc_add_flash_message(sprintf(__('%s has been deleted'), $aCountries['s_name']), 'admin');
} else {
osc_add_flash_message(sprintf(__('%s can not be deleted, some items are located in it'), $aCountries['s_name']), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'add_region':
// add region
if (!Params::getParam('r_manual')) {
$this->install_location_by_region();
} else {
$mRegions = new Region();
$regionName = Params::getParam('region');
$countryCode = Params::getParam('country_c_parent');
$exists = $mRegions->findByNameAndCode($regionName, $countryCode);
if (!isset($exists['s_name'])) {
$data = array('fk_c_country_code' => $countryCode, 's_name' => $regionName);
$mRegions->insert($data);