當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sql_query::prepare_sql_addgroupby方法代碼示例

本文整理匯總了PHP中sql_query::prepare_sql_addgroupby方法的典型用法代碼示例。如果您正苦於以下問題:PHP sql_query::prepare_sql_addgroupby方法的具體用法?PHP sql_query::prepare_sql_addgroupby怎麽用?PHP sql_query::prepare_sql_addgroupby使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sql_query的用法示例。


在下文中一共展示了sql_query::prepare_sql_addgroupby方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 function execute()
 {
     /*
     	Date selection form
     */
     // fetch existing dates
     $this->date_start = @security_script_input("/^[0-9]*-[0-9]*-[0-9]*\$/", $_GET["date_start_yyyy"] . "-" . $_GET["date_start_mm"] . "-" . $_GET["date_start_dd"]);
     $this->date_end = @security_script_input("/^[0-9]*-[0-9]*-[0-9]*\$/", $_GET["date_end_yyyy"] . "-" . $_GET["date_end_mm"] . "-" . $_GET["date_end_dd"]);
     if (!$this->date_start || $this->date_start == "--") {
         if ($_SESSION["account_reports"]["date_start"]) {
             $this->date_start = $_SESSION["account_reports"]["date_start"];
         } else {
             $this->date_start = NULL;
         }
     }
     if (!$this->date_end || $this->date_end == "--") {
         if ($_SESSION["account_reports"]["date_end"]) {
             $this->date_end = $_SESSION["account_reports"]["date_end"];
         } else {
             $this->date_end = NULL;
         }
     }
     // save to session vars
     $_SESSION["account_reports"]["date_start"] = $this->date_start;
     $_SESSION["account_reports"]["date_end"] = $this->date_end;
     // define form
     $this->obj_form = new form_input();
     $this->obj_form->method = "get";
     $this->obj_form->action = "index.php";
     $this->obj_form->formname = "accounts_report_trialbalance";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     // hidden values
     $structure = NULL;
     $structure["fieldname"] = "page";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $_GET["page"];
     $this->obj_form->add_input($structure);
     // date selection
     $structure = NULL;
     $structure["fieldname"] = "date_start";
     $structure["type"] = "date";
     $structure["defaultvalue"] = $this->date_start;
     $this->obj_form->add_input($structure);
     $structure = NULL;
     $structure["fieldname"] = "date_end";
     $structure["type"] = "date";
     $structure["defaultvalue"] = $this->date_end;
     $this->obj_form->add_input($structure);
     // submit
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "Apply Filter Options";
     $this->obj_form->add_input($structure);
     // establish a new table object
     $this->obj_table = new table();
     $this->obj_table->language = $_SESSION["user"]["lang"];
     $this->obj_table->tablename = "accounts_reports_trialbalance";
     // define all the columns and structure
     $this->obj_table->add_column("standard", "code_chart", "account_charts.code_chart");
     $this->obj_table->add_column("standard", "description", "account_charts.description");
     $this->obj_table->add_column("standard", "chart_type", "account_chart_type.value");
     // the debit and credit columns need to be calculated by a seporate query
     $this->obj_table->add_column("price", "debit", "NONE");
     $this->obj_table->add_column("price", "credit", "NONE");
     // defaults
     $this->obj_table->columns = array("code_chart", "description", "chart_type", "debit", "credit");
     $this->obj_table->columns_order = array("code_chart");
     // totals
     $this->obj_table->total_columns = array("debit", "credit");
     $this->obj_table->total_rows = array("debit", "credit");
     $this->obj_table->total_rows_mode = "subtotal_nofinal";
     // this is actually re-calculated based on chart type
     // define SQL structure
     $this->obj_table->sql_obj->prepare_sql_settable("account_charts");
     $this->obj_table->sql_obj->prepare_sql_addfield("id", "account_charts.id");
     $this->obj_table->sql_obj->prepare_sql_addfield("chart_total_mode", "account_chart_type.total_mode");
     $this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN account_chart_type ON account_chart_type.id = account_charts.chart_type");
     $this->obj_table->sql_obj->prepare_sql_addwhere("account_charts.chart_type != '1'");
     // fetch all the chart information
     $this->obj_table->generate_sql();
     $this->obj_table->load_data_sql();
     // fetch debit and credit summaries for all charts in advance - this
     // is better than running a query per chart just to get all the totals
     $sql_amount_obj = new sql_query();
     $sql_amount_obj->prepare_sql_settable("account_trans");
     $sql_amount_obj->prepare_sql_addfield("chartid");
     $sql_amount_obj->prepare_sql_addfield("credit", "SUM(amount_credit)");
     $sql_amount_obj->prepare_sql_addfield("debit", "SUM(amount_debit)");
     if ($this->date_start) {
         $sql_amount_obj->prepare_sql_addwhere("date_trans >= '" . $this->date_start . "'");
     }
     if ($this->date_end) {
         $sql_amount_obj->prepare_sql_addwhere("date_trans <= '" . $this->date_end . "'");
     }
     $sql_amount_obj->prepare_sql_addgroupby("chartid");
     $sql_amount_obj->generate_sql();
     $sql_amount_obj->execute();
     if ($sql_amount_obj->num_rows()) {
         $sql_amount_obj->fetch_array();
//.........這裏部分代碼省略.........
開發者ID:carriercomm,項目名稱:amberdms-bs,代碼行數:101,代碼來源:trialbalance.php


注:本文中的sql_query::prepare_sql_addgroupby方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。