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


PHP sql_query::session_terminate方法代码示例

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


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

示例1: header

     }
 }
 /*
 	Test CDR Database
 */
 if ($data["SERVICE_CDR_DB_TYPE"] == "mysql_cdr_daily") {
     $obj_sql = new sql_query();
     if (!$obj_sql->session_init("mysql", $data["SERVICE_CDR_DB_HOST"], $data["SERVICE_CDR_DB_NAME"], $data["SERVICE_CDR_DB_USERNAME"], $data["SERVICE_CDR_DB_PASSWORD"])) {
         log_write("error", "sql_query", "Unable to connect to CDR service usage database!");
         error_flag_field("SERVICE_CDR_DB_HOST");
         error_flag_field("SERVICE_CDR_DB_NAME");
         error_flag_field("SERVICE_CDR_DB_USERNAME");
         error_flag_field("SERVICE_CDR_DB_PASSWORD");
     } else {
         log_write("notification", "sql_query", "Tested successful connection to CDR usage database");
         $obj_sql->session_terminate();
     }
 }
 /*
 	Process Errors
 */
 if (error_check()) {
     $_SESSION["error"]["form"]["config_services"] = "failed";
     header("Location: ../index.php?page=admin/config_services.php");
     exit(0);
 } else {
     $_SESSION["error"] = array();
     /*
     	Start Transaction
     */
     $sql_obj = new sql_query();
开发者ID:carriercomm,项目名称:amberdms-bs,代码行数:31,代码来源:config_services-process.php

示例2: Pricing


//.........这里部分代码省略.........
         	Just a simple query here, however if this is a TOLLFREE service, then we need to reverse
         	the query to charge for inbound calls rather than outbound.
         */
         log_write("debug", "service_usage_cdr", "Fetching usage records FOR {$ddi} FROM {$date_start} TO {$date_end}");
         $obj_cdr_sql = new sql_query();
         if ($this->obj_service->data["typeid_string"] == "phone_tollfree") {
             log_write("debug", "service_usage_cdr", "Billing for tollfree service on {$ddi}");
             // NOTE! for toll-free services, we reverse src and dst for reverse billing calculations
             $obj_cdr_sql->string = "SELECT id, date, price, usage1 as dst, usage2 as src, usage3 as billsec, billgroup FROM service_usage_records WHERE id_service_customer='" . $this->id_service_customer . "' AND date >= '{$date_start}' AND date < '{$date_end}'";
             $obj_cdr_sql->execute();
         } else {
             $obj_cdr_sql->string = "SELECT id, date, price, usage1 as src, usage2 as dst, usage3 as billsec, billgroup FROM service_usage_records WHERE id_service_customer='" . $this->id_service_customer . "' AND date >= '{$date_start}' AND date < '{$date_end}'";
             $obj_cdr_sql->execute();
         }
         /*
         	Calculate costs of calls
         */
         if ($obj_cdr_sql->num_rows()) {
             $obj_cdr_sql->fetch_array();
             foreach ($obj_cdr_sql->data as $data_cdr) {
                 // determine price
                 if ($data_cdr["price"] != "0.00") {
                     // a price has already been set - make use of that
                     $charges = array();
                     $charges["price"] = $data_cdr["price"];
                     $charges["billgroup"] = $data_cdr["billgroup"];
                 } else {
                     $charges = $obj_cdr_rate_table->calculate_charges($data_cdr["billsec"], $data_cdr["src"], $data_cdr["dst"], $this->data_local[$data_cdr["src"]], $this->data_ddi);
                     // update the charges in the records
                     $sql_obj = new sql_query();
                     $sql_obj->string = "UPDATE service_usage_records SET price='" . $charges["price"] . "', billgroup='" . $charges['billgroup'] . "' WHERE id='" . $data_cdr["id"] . "'";
                     $sql_obj->execute();
                 }
                 // add to structure - we use the SRC as the DDI
                 $this->data[$data_cdr["src"]][$charges["billgroup"]]["charges"] += $charges["price"];
                 // TODO: this won't catch issues where the DDIs configured don't match the SRC DDI (although it should always!)
             }
         }
     } else {
         /*
         	Connect to External SQL database
         */
         // fetch all calls for that DDI from the DB for the selected period
         $obj_cdr_db_sql = new sql_query();
         if (!$obj_cdr_db_sql->session_init("mysql", $GLOBALS["config"]["SERVICE_CDR_DB_HOST"], $GLOBALS["config"]["SERVICE_CDR_DB_NAME"], $GLOBALS["config"]["SERVICE_CDR_DB_USERNAME"], $GLOBALS["config"]["SERVICE_CDR_DB_PASSWORD"])) {
             return 0;
         }
         /*
         	We fetch the call records by looping through all the DDIs for this customer, fetching all the records
         	for those DDIs and then calculating the cost for each call
         */
         foreach ($this->data_ddi as $ddi) {
             // calculate end date to be the first date of the next period - failure to do so would mean we would
             // miss the last day of the billing period in the query;
             $date_start = $this->date_start;
             $tmp_date = explode("-", $this->date_end);
             $date_end = date("Y-m-d", mktime(0, 0, 0, $tmp_date[1], $tmp_date[2] + 1, $tmp_date[0]));
             /*
             					Fetch Data
             	Just a simple query here, however if this is a TOLLFREE service, then we need to reverse
             					the query to charge for inbound calls rather than outbound.
             */
             log_write("debug", "service_usage_cdr", "Fetching usage records FOR {$ddi} FROM {$date_start} TO {$date_end}");
             if ($this->obj_service->data["typeid_string"] == "phone_tollfree") {
                 log_write("debug", "service_usage_cdr", "Billing for tollfree service on {$ddi}");
                 // NOTE! for toll-free services, we reverse src and dst for reverse billing calculations
                 $obj_cdr_db_sql->string = "SELECT calldate, billsec, dst as src, src as dst FROM cdr WHERE disposition='ANSWERED' AND dst='{$ddi}' AND calldate >= '{$date_start}' AND calldate < '{$date_end}'";
                 $obj_cdr_db_sql->execute();
             } else {
                 $obj_cdr_db_sql->string = "SELECT calldate, billsec, src, dst FROM cdr WHERE disposition='ANSWERED' AND src='{$ddi}' AND calldate >= '{$date_start}' AND calldate < '{$date_end}'";
                 $obj_cdr_db_sql->execute();
             }
             /*
             	Calculate costs of calls
             */
             if (!isset($this->data[$ddi][$charges["billgroup"]]["charges"])) {
                 $this->data[$ddi][$charges["billgroup"]]["charges"] = 0;
             }
             if ($obj_cdr_db_sql->num_rows()) {
                 $obj_cdr_db_sql->fetch_array();
                 foreach ($obj_cdr_db_sql->data as $data_cdr) {
                     // determine price
                     $charges = $obj_cdr_rate_table->calculate_charges($data_cdr["billsec"], $data_cdr["src"], $data_cdr["dst"], $this->data_local[$ddi], $this->data_ddi);
                     // create local usage record for record keeping purposes
                     $sql_obj = new sql_query();
                     $sql_obj->string = "INSERT INTO service_usage_records (id_service_customer, date, price, usage1, usage2, usage3, billgroup) VALUES ('" . $this->id_service_customer . "', '" . $data_cdr["calldate"] . "', '" . $charges["price"] . "', '" . $data_cdr["src"] . "', '" . $data_cdr["dst"] . "', '" . $data_cdr["billsec"] . "', '" . $charges["billgroup"] . "')";
                     $sql_obj->execute();
                     // add to structure
                     $this->data[$ddi][$charges["billgroup"]]["charges"] += $charges["price"];
                 }
             }
         }
         // end of DDI loop
         /*
         	Disconnect from database
         */
         $obj_cdr_db_sql->session_terminate();
     }
     // end of external data source
 }
开发者ID:carriercomm,项目名称:amberdms-bs,代码行数:101,代码来源:inc_services_cdr.php

示例3: SUM


//.........这里部分代码省略.........
                     */
                     log_write("debug", "service_usage_traffic", "Fetching usage records FOR address {$ipv4} FOR date " . $this->date_start . " to " . $this->date_end . "");
                     // run through the dates
                     foreach ($date_range as $date) {
                         // check that the table exists
                         $obj_traffic_db_sql->string = "SHOW TABLES LIKE 'traffic_{$date}'";
                         $obj_traffic_db_sql->execute();
                         if ($obj_traffic_db_sql->num_rows()) {
                             // query the current date for the current IP
                             $obj_traffic_db_sql->string = "SELECT SUM(bytes) as total FROM traffic_{$date} WHERE ip_src='{$ipv4}' OR ip_dst='{$ipv4}'";
                             $obj_traffic_db_sql->execute();
                             $obj_traffic_db_sql->fetch_array();
                             if (!empty($obj_traffic_db_sql->data[0]["total"])) {
                                 // add to running total
                                 $sql_obj = new sql_query();
                                 $sql_obj->string = "SELECT '" . $this->data["total"]["total"] . "' + '" . $obj_traffic_db_sql->data[0]["total"] . "' as totalusage";
                                 $sql_obj->execute();
                                 $sql_obj->fetch_array();
                                 $this->data["total"]["total"] = $sql_obj->data[0]["totalusage"];
                             }
                             // end if traffic exists
                         } else {
                             log_write("warning", "service_usage_traffic", "SQL database table traffic_{$date} does not exist");
                         }
                     }
                     // end foreach date
                     log_write("debug", "service_usage_traffic", "Completed usage query for address {$ipv4}.");
                 }
                 // end foreach ipv4
                 log_write("debug", "service_usage_traffic", "Total usage for all addresses in the date range is " . $this->data["total"]["total"] . " bytes");
                 /*
                 	Disconnect from database
                 */
                 $obj_traffic_db_sql->session_terminate();
                 unset($obj_traffic_db_sql);
                 break;
             case "mysql_traffic_summary":
                 /*
                 	MODE: mysql_traffic_summary
                 
                 	In this mode, the database contains a single table "traffic_summary" which includes the following key fields:
                 	* ip_address			IPv4 Address
                 	* traffic_datetime		Date/Time Field
                 	* traffic_type			Type of traffic
                 	* total				Total Bytes transfered
                 
                 	Ideally this table should contain one row per IP address, per day, to enable billing to occur.
                 
                 	TODO: update to support traffic types
                 */
                 log_write("debug", "service_usage_traffic", "Processing external database mysql_traffic_summary");
                 /*
                 	Connect to external database
                 */
                 $obj_traffic_db_sql = new sql_query();
                 if (!$obj_traffic_db_sql->session_init("mysql", $GLOBALS["config"]["SERVICE_TRAFFIC_DB_HOST"], $GLOBALS["config"]["SERVICE_TRAFFIC_DB_NAME"], $GLOBALS["config"]["SERVICE_TRAFFIC_DB_USERNAME"], $GLOBALS["config"]["SERVICE_TRAFFIC_DB_PASSWORD"])) {
                     log_write("error", "service_usage_traffic", "Unable to establish a connection to the external traffic DB, unable to run data usage processing.");
                     return 0;
                 }
                 /*
                 	Loop through each IP and fetch usage for that IP.
                 */
                 // make sure we have the array of IPv4 addresses
                 if (!$this->data_ipv4) {
                     $this->load_data_ipv4();
                 }
开发者ID:carriercomm,项目名称:amberdms-bs,代码行数:67,代码来源:inc_services_traffic.php


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