当前位置: 首页>>代码示例>>PHP>>正文


PHP Country::insert方法代码示例

本文整理汇总了PHP中Country::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Country::insert方法的具体用法?PHP Country::insert怎么用?PHP Country::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Country的用法示例。


在下文中一共展示了Country::insert方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

$GeneralObj->getRequestVars();
$CountryObj->setAllVar();
$iCountryId = $_POST["iCountryId"];
$redirect_file = "index.php?file=t-country_masteradd&mode={$mode}&iCountryId={$iCountryId}";
/*
 $ext='';
if($_REQUEST['keyword'] !='')
{
$ext .="&keyword=".$_REQUEST['keyword'];
}
if($_REQUEST['option'] !='')
{
$ext .="&option=".$_REQUEST['option'];
}  */
$GeneralObj->checkDuplicate('iCountryId', 'country_master', array('vCountry'), $redirect_file, MSG_ALLREADY_EXIST, $iCountryId);
$msg = MSG_ALLREADY_EXIST;
if ($mode == "Add") {
    //$CountryObj->setvCountry($_POST["vCountry"]);
    $lastcountryid = $CountryObj->insert();
    $msg = MSG_ADD;
    header("Location:index.php?file=Country&AX=Yes&var_msg={$msg}" . $ExtraVal);
    //exit;
} else {
    if ($mode == "Update") {
        //	$CountryObj->setvCountry($_POST["vCountry"]);
        $CountryObj->update($iCountryId);
        $msg = MSG_UPDATE;
        header("Location:index.php?file=Country&AX=Yes&var_msg={$msg}" . $ExtraVal);
        exit;
    }
}
开发者ID:redeyes1024,项目名称:medlii_mlm_backend,代码行数:31,代码来源:country_masteradd_a.php

示例2: trim

 function install_location_by_country()
 {
     $country_code = Params::getParam('c_country');
     $aCountryCode[] = trim($country_code);
     $manager_country = new Country();
     $countries_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=country_id&term=' . urlencode(implode(',', $aCountryCode)));
     $countries = json_decode($countries_json);
     if (isset($countries->error)) {
         osc_add_flash_error_message(sprintf(_m("%s can't be added"), $country), 'admin');
         return false;
     }
     foreach ($countries as $c) {
         $exists = $manager_country->findByCode($c->id);
         if (isset($exists['s_name'])) {
             osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $exists['s_name']), 'admin');
             return false;
         }
         $manager_country->insert(array("pk_c_code" => $c->id, "fk_c_locale_code" => $c->locale_code, "s_name" => $c->name));
     }
     $manager_region = new Region();
     $regions_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=region&country_id=' . urlencode(implode(',', $aCountryCode)) . '&term=all');
     $regions = json_decode($regions_json);
     foreach ($regions as $r) {
         $manager_region->insert(array("fk_c_country_code" => $r->country_code, "s_name" => $r->name));
     }
     unset($regions);
     unset($regions_json);
     $manager_city = new City();
     foreach ($countries as $c) {
         $regions = $manager_region->finbByCountry($c->id);
         foreach ($regions as $region) {
             $cities_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=city&country=' . urlencode($c->name) . '&region=' . urlencode($region['s_name']) . '&term=all');
             $cities = json_decode($cities_json);
             if (!isset($cities->error)) {
                 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));
                 }
             }
             unset($cities);
             unset($cities_json);
         }
     }
     osc_add_flash_ok_message(sprintf(_m('%s has been added as a new country'), $country), 'admin');
 }
开发者ID:semul,项目名称:Osclass,代码行数:44,代码来源:settings.php

示例3: doModel

    function doModel()
    {
        switch ($this->action) {
            case 'comments':
                //calling the comments settings view
                $this->doView('settings/comments.php');
                break;
            case 'comments_post':
                // updating comment
                osc_csrf_check();
                $iUpdated = 0;
                $enabledComments = Params::getParam('enabled_comments');
                $enabledComments = $enabledComments != '' ? true : false;
                $moderateComments = Params::getParam('moderate_comments');
                $moderateComments = $moderateComments != '' ? true : false;
                $numModerateComments = Params::getParam('num_moderate_comments');
                $commentsPerPage = Params::getParam('comments_per_page');
                $notifyNewComment = Params::getParam('notify_new_comment');
                $notifyNewComment = $notifyNewComment != '' ? true : false;
                $notifyNewCommentUser = Params::getParam('notify_new_comment_user');
                $notifyNewCommentUser = $notifyNewCommentUser != '' ? true : false;
                $regUserPostComments = Params::getParam('reg_user_post_comments');
                $regUserPostComments = $regUserPostComments != '' ? true : false;
                $msg = '';
                if (!osc_validate_int(Params::getParam("num_moderate_comments"))) {
                    $msg .= _m("Number of moderate comments must only contain numeric characters") . "<br/>";
                }
                if (!osc_validate_int(Params::getParam("comments_per_page"))) {
                    $msg .= _m("Comments per page must only contain numeric characters") . "<br/>";
                }
                if ($msg != '') {
                    osc_add_flash_error_message($msg, 'admin');
                    $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
                }
                $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledComments), array('s_name' => 'enabled_comments'));
                if ($moderateComments) {
                    $iUpdated += Preference::newInstance()->update(array('s_value' => $numModerateComments), array('s_name' => 'moderate_comments'));
                } else {
                    $iUpdated += Preference::newInstance()->update(array('s_value' => '-1'), array('s_name' => 'moderate_comments'));
                }
                $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewComment), array('s_name' => 'notify_new_comment'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewCommentUser), array('s_name' => 'notify_new_comment_user'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $commentsPerPage), array('s_name' => 'comments_per_page'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $regUserPostComments), array('s_name' => 'reg_user_post_comments'));
                if ($iUpdated > 0) {
                    osc_add_flash_ok_message(_m("Comment settings have been updated"), 'admin');
                }
                $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
                break;
            case 'locations':
                // calling the locations settings view
                $location_action = Params::getParam('type');
                $mCountries = new Country();
                switch ($location_action) {
                    case 'add_country':
                        // add country
                        osc_csrf_check();
                        $countryCode = strtoupper(Params::getParam('c_country'));
                        $countryName = Params::getParam('country');
                        $exists = $mCountries->findByCode($countryCode);
                        if (isset($exists['s_name'])) {
                            osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $countryName), 'admin');
                        } else {
                            if (Params::getParam('c_manual') == 1) {
                                $mCountries->insert(array('pk_c_code' => $countryCode, 's_name' => $countryName));
                                osc_add_flash_ok_message(sprintf(_m('%s has been added as a new country'), $countryName), 'admin');
                            } else {
                                if (!osc_validate_min($countryCode, 1) || !osc_validate_min($countryName, 1)) {
                                    osc_add_flash_error_message(_m('Country code and name should have at least two characters'), 'admin');
                                } else {
                                    $data_sql = osc_file_get_contents('http://geo.osclass.org/newgeo.download.php?action=country&term=' . urlencode($countryCode));
                                    if ($data_sql != '') {
                                        $conn = DBConnectionClass::newInstance();
                                        $c_db = $conn->getOsclassDb();
                                        $comm = new DBCommandClass($c_db);
                                        $comm->query("SET FOREIGN_KEY_CHECKS = 0");
                                        $comm->importSQL($data_sql);
                                        $comm->query("SET FOREIGN_KEY_CHECKS = 1");
                                    } else {
                                        $mCountries->insert(array('pk_c_code' => $countryCode, 's_name' => $countryName));
                                    }
                                    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
                        osc_csrf_check();
                        if (!osc_validate_min(Params::getParam('e_country'), 1)) {
                            osc_add_flash_error_message(_m('Country name cannot be blank'), 'admin');
                        } else {
                            $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');
                            }
                        }
//.........这里部分代码省略.........
开发者ID:jmcclenon,项目名称:Osclass,代码行数:101,代码来源:settings.php

示例4: insert_google_map

 public function insert_google_map($userId)
 {
     $aItem = Item::newInstance()->findByPrimaryKey($userId);
     $address = osc_sanitize_name(strip_tags(trim(Params::getParam('dln_address'))));
     $lat = strip_tags(trim(Params::getParam('dln_lat')));
     $long = strip_tags(trim(Params::getParam('dln_long')));
     // Connect to google geolocation service for get country and city location
     $country = $city = '';
     if ($lat && $long) {
         try {
             $response = file_get_contents(sprintf('https://maps.googleapis.com/maps/api/geocode/json?latlng=%s,%s&language=vi_VN', $lat, $long));
             $json_resp = json_decode($response);
             $country_code = '';
             if (isset($json_resp->results[0]->address_components) && is_array($json_resp->results[0]->address_components)) {
                 foreach ($json_resp->results[0]->address_components as $i => $component) {
                     if (!empty($component->types) && in_array('country', $component->types)) {
                         $country = $component->long_name;
                         $country_code = strtoupper($component->short_name);
                     }
                     if (!empty($component->types) && in_array('administrative_area_level_1', $component->types)) {
                         $city = $component->long_name;
                     }
                 }
                 $country_id = $city_id = $region_id = '';
                 if ($country && $country_code) {
                     // Insert new country if not exists
                     $mCountries = new Country();
                     $exists = $mCountries->findByCode($country_code);
                     if (!isset($exists['s_name'])) {
                         $mCountries->insert(array('pk_c_code' => $country_code, 's_name' => $country));
                         $country_id = $mCountries->dao->insertedId();
                     } else {
                         $country_id = isset($exists['pk_c_code']) ? $exists['pk_c_code'] : '';
                     }
                     // Insert Un-register region
                     $region_name = 'Undefined';
                     $mRegion = new Region();
                     $exists = $mRegion->findByName($region_name, $country_code);
                     if (!isset($exists['s_name'])) {
                         $data = array('fk_c_country_code' => $country_code, 's_name' => $region_name);
                         $mRegion->insert($data);
                         $region_id = $mRegion->dao->insertedId();
                         RegionStats::newInstance()->setNumItems($region_id, 0);
                     } else {
                         $region_id = isset($exists['pk_i_id']) ? $exists['pk_i_id'] : '';
                     }
                     if ($city) {
                         // Insert new city if not exists
                         $mCity = new City();
                         $exists = $mCity->findByName($city, $region_id);
                         if (!isset($exists['s_name'])) {
                             $mCity->insert(array('fk_i_region_id' => $region_id, 's_name' => $city, 'fk_c_country_code' => $country_code));
                             $city_id = $mCity->dao->insertedId();
                             CityStats::newInstance()->setNumItems($city_id, 0);
                         } else {
                             $city_id = isset($exists['pk_i_id']) ? $exists['pk_i_id'] : '';
                         }
                     }
                 }
             }
         } catch (Exception $e) {
             var_dump($e->getMessage());
             die;
         }
     }
     User::newInstance()->update(array('s_address' => $address, 'd_coord_lat' => $lat, 'd_coord_long' => $long, 's_country' => $country, 's_city' => $city, 'fk_i_region_id' => $region_id, 'fk_c_country_code' => $country_id, 'fk_i_city_id' => $city_id), array('pk_i_id' => $userId));
     /*ItemLocation::newInstance()->update(
     			array(
     				's_address'    => $address,
     				'd_coord_lat'  => $lat,
     				'd_coord_long' => $long,
     				's_country'    => $country,
     				's_city'       => $city,
     		), array( 'fk_i_item_id' => $itemId ) );*/
 }
开发者ID:httvncoder,项目名称:151722441,代码行数:75,代码来源:helper-google.php

示例5: doModel

        function doModel()
        {
            // calling the locations settings view
            $location_action = Params::getParam('type');
            $mCountries = new Country();

            switch ($location_action) {
                case('add_country'):    // add country
                                        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();
                                        $countryCode = strtoupper(Params::getParam('c_country'));
                                        $countryName = Params::getParam('country');
                                        $exists = $mCountries->findByCode($countryCode);
                                        if(isset($exists['s_name'])) {
                                            osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $countryName), 'admin');
                                        } else {
                                            if(Params::getParam('c_manual')==1) {
                                                $mCountries->insert(array('pk_c_code' => $countryCode,
                                                                        's_name' => $countryName));
                                                osc_add_flash_ok_message(sprintf(_m('%s has been added as a new country'), $countryName), 'admin');
                                            } else {
                                                if(!osc_validate_min($countryCode, 1) || !osc_validate_min($countryName, 1)) {
                                                    osc_add_flash_error_message(_m('Country code and name should have at least two characters'), 'admin');
                                                } else {
                                                    $data_sql = osc_file_get_contents('http://geo.osclass.org/newgeo.download.php?action=country&term=' . urlencode($countryCode) );

                                                    if($data_sql!='') {
                                                        $conn = DBConnectionClass::newInstance();
                                                        $c_db = $conn->getOsclassDb();
                                                        $comm = new DBCommandClass($c_db);
                                                        $comm->query("SET FOREIGN_KEY_CHECKS = 0");
                                                        $comm->importSQL($data_sql);
                                                        $comm->query("SET FOREIGN_KEY_CHECKS = 1");
                                                    } else {
                                                        $mCountries->insert(array('pk_c_code' => $countryCode,
                                                                                's_name' => $countryName));
                                                    }
                                                    osc_add_flash_ok_message(sprintf(_m('%s has been added as a new country'), $countryName), 'admin');
                                                }
                                            }
                                        }
                                        osc_calculate_location_slug(osc_subdomain_type());
                                        $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=locations');
                break;
                case('edit_country'):   // edit country
                                        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();
                                        if(!osc_validate_min(Params::getParam('e_country'), 1)) {
                                            osc_add_flash_error_message(_m('Country name cannot be blank'), 'admin');
                                        } else {
                                            $name = Params::getParam('e_country');
                                            $slug = Params::getParam('e_country_slug');
                                            if($slug=='') {
                                                $slug_tmp = $slug = osc_sanitizeString($name);
                                            } else {
                                                $exists = $mCountries->findBySlug($slug);
                                                if(isset($exists['s_slug']) && $exists['pk_c_code']!=Params::getParam('country_code')) {
                                                    $slug_tmp = $slug = osc_sanitizeString($name);
                                                } else {
                                                    $slug_tmp = $slug = osc_sanitizeString($slug);
                                                }
                                            }
                                            $slug_unique = 1;
                                            while(true) {
                                                $location_slug = $mCountries->findBySlug($slug);
                                                if(isset($location_slug['s_slug']) && $location_slug['pk_c_code']!=Params::getParam('country_code')) {
                                                    $slug = $slug_tmp . '-' . $slug_unique;
                                                    $slug_unique++;
                                                } else {
                                                    break;
                                                }
                                            }

                                            $ok = $mCountries->update(array('s_name'=> $name, 's_slug' => $slug), 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
                                        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();
                                        $countryIds = Params::getParam('id');

                                        if(is_array($countryIds)) {
                                            $locations = 0;
                                            $del_locations = 0;
//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:101,代码来源:locations.php

示例6: Country

if (!isset($countryObj)) {
    include_once SITE_CLASS_APPLICATION . "class.Country.php";
    $countryObj = new Country();
}
$view = PostVar("view");
$Data = PostVar("Data");
$iCountryId = PostVar("iCountryId");
$actionfile = GetVar("file");
/** This is for Check Duplicate Record-------------------------------------------*/
$generalobj->getRequestVars();
$redirect_file = "index.php?file={$file}&view={$view}&iCountryId={$iCountryId}";
$generalobj->checkDuplicate('iCountryId', PRJ_DB_PREFIX . "_country_master", array('vCountry' => $Data['vCountry']), $redirect_file, COUNTRY_ALREADY_EXISTS, $iCountryId);
if ($view == "add") {
    //prints($Data);exit;
    $countryObj->setAllVar($Data);
    $id = $countryObj->insert();
    if ($id) {
        $var_msg = "Record Added Successfully.";
    } else {
        $var_msg = "Eror-in Add.";
    }
} else {
    if ($view == "edit") {
        $arr = $countryObj->select($iCountryId);
        $countryObj->setAllVar($arr);
        $countryObj->setAllVar($Data);
        $where = " iCountryId = '" . $iCountryId . "'";
        $id = $countryObj->update($where);
        if ($id) {
            $var_msg = "Record Updated Successfully.";
        } else {
开发者ID:nstungxd,项目名称:F2CA5,代码行数:31,代码来源:addcountry_a.php


注:本文中的Country::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。