本文整理汇总了PHP中Region::findByPrimaryKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Region::findByPrimaryKey方法的具体用法?PHP Region::findByPrimaryKey怎么用?PHP Region::findByPrimaryKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Region
的用法示例。
在下文中一共展示了Region::findByPrimaryKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doModel
//.........这里部分代码省略.........
}
$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);
$exists = $mRegions->findByName($regionName, $countryCode);
if (!isset($exists['s_name'])) {
$data = array('fk_c_country_code' => $countryCode, 's_name' => $regionName);
$mRegions->insert($data);
$id = $mRegions->dao->insertedId();
RegionStats::newInstance()->setNumItems($id, 0);
osc_add_flash_ok_message(sprintf(_m('%s has been added as a new region'), $regionName), 'admin');
} else {
osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $regionName), 'admin');
}
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations&country_code=' . @$countryCode . "&country=" . @$country['s_name']);
break;
case 'edit_region':
// edit region
$mRegions = new Region();
$newRegion = Params::getParam('e_region');
$regionId = Params::getParam('region_id');
$exists = $mRegions->findByName($newRegion);
if (!isset($exists['pk_i_id']) || $exists['pk_i_id'] == $regionId) {
if ($regionId != '') {
$aRegion = $mRegions->findByPrimaryKey($regionId);
$country = Country::newInstance()->findByCode($aRegion['fk_c_country_code']);
$mRegions->update(array('s_name' => $newRegion), array('pk_i_id' => $regionId));
ItemLocation::newInstance()->update(array('s_region' => $newRegion), array('fk_i_region_id' => $regionId));
osc_add_flash_ok_message(sprintf(_m('%s has been edited'), $newRegion), 'admin');
}
} else {
osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $newRegion), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations&country_code=' . @$country['pk_c_code'] . "&country=" . @$country['s_name']);
break;
case 'delete_region':
// delete region
$mRegion = new Region();
$mCities = new City();
$regionId = Params::getParam('id');
if ($regionId != '') {
Item::newInstance()->deleteByRegion($regionId);
$aRegion = $mRegion->findByPrimaryKey($regionId);
$country = Country::newInstance()->findByCode($aRegion['fk_c_country_code']);
// remove city_stats
CityStats::newInstance()->deleteByRegion($regionId);
$mCities->delete(array('fk_i_region_id' => $regionId));
// remove region_stats
RegionStats::newInstance()->delete(array('fk_i_region_id' => $regionId));
$mRegion->delete(array('pk_i_id' => $regionId));
osc_add_flash_ok_message(sprintf(_m('%s has been deleted'), $aRegion['s_name']), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations&country_code=' . @$country['pk_c_code'] . "&country=" . @$country['s_name']);
break;
case 'add_city':
// add city
$mRegion = new Region();
示例2: doModel
//.........这里部分代码省略.........
$exists = $mRegions->findByNameAndCode($regionName, $countryCode);
if (!isset($exists['s_name'])) {
$data = array('fk_c_country_code' => $countryCode, 's_name' => $regionName);
$mRegions->insert($data);
osc_add_flash_ok_message(sprintf(_m('%s has been added as a new region'), $regionName), 'admin');
} else {
osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $regionName), 'admin');
}
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'edit_region':
// edit region
$mRegions = new Region();
$newRegion = Params::getParam('e_region');
$regionId = Params::getParam('region_id');
$exists = $mRegions->findByName($newRegion);
if (!$exists['pk_i_id'] || $exists['pk_i_id'] == $regionId) {
if ($regionId != '') {
$mRegions->update(array('s_name' => $newRegion), array('pk_i_id' => $regionId));
osc_add_flash_ok_message(sprintf(_m('%s has been edited'), $newRegion), 'admin');
}
} else {
osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $newRegion), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'delete_region':
// delete region
$mRegion = new Region();
$mCities = new City();
$regionId = Params::getParam('id');
if ($regionId != '') {
$aRegion = $mRegion->findByPrimaryKey($regionId);
$mCities->delete(array('fk_i_region_id' => $regionId));
$mRegion->delete(array('pk_i_id' => $regionId));
osc_add_flash_ok_message(sprintf(_m('%s has been deleted'), $aRegion['s_name']), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'add_city':
// add city
$mCities = new City();
$regionId = Params::getParam('region_parent');
$countryCode = Params::getParam('country_c_parent');
$newCity = Params::getParam('city');
$exists = $mCities->findByNameAndRegion($newCity, $regionId);
if (!isset($exists['s_name'])) {
$mCities->insert(array('fk_i_region_id' => $regionId, 's_name' => $newCity, 'fk_c_country_code' => $countryCode));
osc_add_flash_ok_message(sprintf(_m('%s has been added as a new city'), $newCity), 'admin');
} else {
osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $newCity), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'edit_city':
// edit city
$mCities = new City();
$newCity = Params::getParam('e_city');
$cityId = Params::getParam('city_id');
$exists = $mCities->findByName($newCity);
if (!isset($exists['pk_i_id']) || $exists['pk_i_id'] == $cityId) {
$mCities->update(array('s_name' => $newCity), array('pk_i_id' => $cityId));
osc_add_flash_ok_message(sprintf(_m('%s has been edited'), $newCity), 'admin');
} else {
osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $newCity), 'admin');
示例3: doModel
//.........这里部分代码省略.........
$exists = $mRegions->findByName($regionName, $countryCode);
if(!isset($exists['s_name'])) {
$data = array('fk_c_country_code' => $countryCode
,'s_name' => $regionName);
$mRegions->insert($data);
$id = $mRegions->dao->insertedId();
RegionStats::newInstance()->setNumItems($id, 0);
osc_add_flash_ok_message(sprintf(_m('%s has been added as a new region'), $regionName), 'admin');
} else {
osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $regionName), 'admin');
}
}
}
osc_calculate_location_slug(osc_subdomain_type());
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations&country_code='.@$countryCode."&country=".@$country['s_name']);
break;
case('edit_region'): // edit region
if( defined('DEMO') ) {
osc_add_flash_warning_message( _m("This action can't be done because it's a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
}
osc_csrf_check();
$mRegions = new Region();
$newRegion = Params::getParam('e_region');
$regionId = Params::getParam('region_id');
if(!osc_validate_min($newRegion, 1)) {
osc_add_flash_error_message(_m('Region name cannot be blank'), 'admin');
} else {
$exists = $mRegions->findByName($newRegion);
if(!isset($exists['pk_i_id']) || $exists['pk_i_id']==$regionId) {
if($regionId != '') {
$aRegion = $mRegions->findByPrimaryKey($regionId);
$country = Country::newInstance()->findByCode($aRegion['fk_c_country_code']);
$name = $newRegion;
$slug = Params::getParam('e_region_slug');
if($slug=='') {
$slug_tmp = $slug = osc_sanitizeString($name);
} else {
$exists = $mRegions->findBySlug($slug);
if(isset($exists['s_slug']) && $exists['pk_i_id']!=$regionId) {
$slug_tmp = $slug = osc_sanitizeString($name);
} else {
$slug_tmp = $slug = osc_sanitizeString($slug);
}
}
$slug_unique = 1;
while(true) {
$location_slug = $mRegions->findBySlug($slug);
if(isset($location_slug['s_slug']) && $location_slug['pk_i_id']!=$regionId) {
$slug = $slug_tmp . '-' . $slug_unique;
$slug_unique++;
} else {
break;
}
}
$mRegions->update(array('s_name' => $newRegion, 's_slug' => $slug)
,array('pk_i_id' => $regionId));
ItemLocation::newInstance()->update(
array('s_region' => $newRegion),
array('fk_i_region_id' => $regionId)
);
osc_add_flash_ok_message(sprintf(_m('%s has been edited'), $newRegion), 'admin');
示例4: doModel
//.........这里部分代码省略.........
$exists = $mRegions->findByNameAndCode($regionName, $countryCode);
if (!isset($exists['s_name'])) {
$data = array('fk_c_country_code' => $countryCode, 's_name' => $regionName);
$mRegions->insert($data);
osc_add_flash_message(sprintf(__('%s has been added as a new region'), $regionName), 'admin');
} else {
osc_add_flash_message(sprintf(__('%s already was in the database'), $regionName), 'admin');
}
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'edit_region':
// edit region
$mRegions = new Region();
$newRegion = Params::getParam('e_region');
$regionId = Params::getParam('region_id');
$exists = $mRegions->findByName($newRegion);
if (!$exists['pk_i_id'] || $exists['pk_i_id'] == $regionId) {
if ($regionId != '') {
$mRegions->update(array('s_name' => $newRegion), array('pk_i_id' => $regionId));
osc_add_flash_message(sprintf(__('%s has been edited'), $newRegion), 'admin');
}
} else {
osc_add_flash_message(sprintf(__('%s already was in the database'), $newRegion), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'delete_region':
// delete region
$mRegion = new Region();
$mCities = new City();
$regionId = Params::getParam('id');
if ($regionId != '') {
$aRegion = $mRegion->findByPrimaryKey($regionId);
$mCities->delete(array('fk_i_region_id' => $regionId));
$mRegion->delete(array('pk_i_id' => $regionId));
osc_add_flash_message(sprintf(__('%s has been deleted'), $aRegion['s_name']), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'add_city':
// add city
$mCities = new City();
$regionId = Params::getParam('region_parent');
$countryCode = Params::getParam('country_c_parent');
$newCity = Params::getParam('city');
$exists = $mCities->findByNameAndRegion($newCity, $regionId);
if (!isset($exists['s_name'])) {
$mCities->insert(array('fk_i_region_id' => $regionId, 's_name' => $newCity, 'fk_c_country_code' => $countryCode));
osc_add_flash_message(sprintf(__('%s has been added as a new city'), $newCity), 'admin');
} else {
osc_add_flash_message(sprintf(__('%s already was in the database'), $newCity), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
break;
case 'edit_city':
// edit city
$mCities = new City();
$newCity = Params::getParam('e_city');
$cityId = Params::getParam('city_id');
$exists = $mCities->findByName($newCity);
if (!isset($exists['pk_i_id']) || $exists['pk_i_id'] == $cityId) {
$mCities->update(array('s_name' => $newCity), array('pk_i_id' => $cityId));
osc_add_flash_message(sprintf(__('%s has been edited'), $newCity), 'admin');
} else {
osc_add_flash_message(sprintf(__('%s already was in the database'), $newCity), 'admin');