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


PHP DbConnect::qry_insert方法代码示例

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


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

示例1: save_db_sitemap

 public function save_db_sitemap($data = "")
 {
     $db = new DbConnect();
     $country_long_name = $administrative_area_level_1_long_name = $country_long_name = $administrative_area_level_1_long_name = $country_long_name = $country_short_name = $administrative_area_level_1_long_name = $administrative_area_level_1_short_name = $postal_code = '';
     foreach ($data['results'][0]['address_components'] as $address) {
         if ($address['types']['0'] == 'administrative_area_level_1') {
             $administrative_area_level_1_long_name = Commonfuns::sanitize($address['long_name']);
             $administrative_area_level_1_short_name = Commonfuns::sanitize($address['short_name']);
         }
         if ($address['types']['0'] == 'country') {
             $country_long_name = Commonfuns::sanitize($address['long_name']);
             $country_short_name = Commonfuns::sanitize($address['short_name']);
         }
         if ($address['types']['0'] == 'postal_code') {
             $postal_code = Commonfuns::sanitize($address['long_name']);
         }
     }
     $address = $data['results'][0]['formatted_address'];
     $url_add = str_replace(" ", "", $address);
     $url_add = str_replace(",", "-", $url_add);
     $sanitizeAddress = Commonfuns::sanitize($url_add);
     $url = str_replace(",", "", $sanitizeAddress . ".html");
     $serverName = Commonfuns::constants('serverName');
     $country = Commonfuns::sanitize(strtolower($country_long_name . ".xml"));
     $countryData = array(array('fileName' => 'sitemap.xml', 'sitemap' => array(array('loc' => $serverName . "sitemaps/{$country}"))));
     $state = Commonfuns::sanitize(strtolower($administrative_area_level_1_long_name . ".xml"));
     $stateData = array(array('fileName' => $country, 'sitemap' => array(array('loc' => $serverName . "sitemaps/{$state}"))));
     $locationsData = array(array('fileName' => $state, 'url' => array(array('loc' => "{$serverName}" . "latlong/{$url}"))));
     $country_id_qry = "SELECT id from countries where title like '%{$country_long_name}%' ";
     $state_id_qry = "SELECT id from states where title like '%{$administrative_area_level_1_long_name}%' ";
     $country_id_res = $db->qry_select($country_id_qry);
     $country_id = $country_id_res['id'];
     $state_id_res = $db->qry_select($state_id_qry);
     $state_id = $state_id_res['id'];
     $country_qry = "INSERT INTO countries (title,short_code) VALUES ('{$country_long_name}','{$country_short_name}');  ";
     $states_qry = "INSERT INTO states(title,short_code) VALUES ('{$administrative_area_level_1_long_name}','{$administrative_area_level_1_short_name}');  ";
     if ($country_id == '') {
         $country_res = $db->qry_insert($country_qry);
         $country_id = $country_res->insert_id;
         $this->multiLevelSitemap($countryData);
     }
     if ($state_id == '') {
         $state_res = $db->qry_insert($states_qry);
         $state_id = $state_res->insert_id;
         $this->multiLevelSitemap($stateData);
     }
     $sitemap_qry = "INSERT INTO sitemap (country_id,state_id,url) VALUES ({$country_id},{$state_id},'{$url}');  ";
     $zipcodes_qry = "INSERT INTO zipcodes (country_id,state_id,zipcode) VALUES ({$country_id},{$state_id},'{$postal_code}')";
     $url_qry = "SELECT id from sitemap where url like '%{$url}%' ";
     $url_res = $db->qry_select($url_qry);
     if ($country_id != '' && $state_id != '' && $url_res == '') {
         $db->qry_insert($sitemap_qry);
         $this->singleLevelSitemap($locationsData);
     }
     $zipcode_qry = "SELECT id from zipcodes where zipcode like '%{$postal_code}%' ";
     $zipcode_res = $db->qry_select($zipcode_qry);
     $db_zipcode_id = $url_res['id'];
     if ($country_id != '' && $state_id != '' && $db_zipcode_id == '') {
         $db->qry_insert($zipcodes_qry);
     }
 }
开发者ID:passionybr2003,项目名称:ifsnew,代码行数:61,代码来源:sitemapgenerator.php


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