Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 915 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

/*

        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
    Copyright (C) 2015~2024 Min-Jhin,Chen

    This file is part of QBPWCF.

    QBPWCF is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QBPWCF is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.

*/
namespace qbpwcf;

/*
類別說明:
提供apache hive相關應用的類別.
備註:
無.
*/
class hive{
        
        /*
        #函式說明:
        #當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$reuslt["error"],執行不正常結束的錯訊息陣列.
        #$result["function"],當前執行的函式名稱.
        #必填參數:
        #$method,物件,為物件實體或類別名稱,會自動置入該參數.
        #$arguments,陣列,為呼叫方法時所用的參數.
        #參考資料:
        #__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
        */
        public function __call($method,$arguments){
                
                #取得當前執行的函式
                $result["function"]=__FUNCTION__;
                
                #設置執行不正常
                $result["status"]="false";
                
                #設置執行錯誤
                $result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
                
                #設置所丟入的參數
                $result["error"][]=$arguments;
                
                #回傳結果
                return $result;
                
                }#function __call end
                
        /*
        #函式說明:
        #當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$reuslt["error"],執行不正常結束的錯訊息陣列.
        #$result["function"],當前執行的函式名稱.
        #必填參數:
        #$method,物件,為物件實體或類別名稱,會自動置入該參數.
        #$arguments,陣列,為呼叫方法時所用的參數.
        #參考資料:
        #__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
        */
        public static function __callStatic($method,$arguments){
                
                #取得當前執行的函式
                $result["function"]=__FUNCTION__;
                
                #設置執行不正常
                $result["status"]="false";
                
                #設置執行錯誤
                $result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
                
                #設置所丟入的參數
                $result["error"][]=$arguments;
                
                #回傳結果
                return $result;
                
                }#function __callStatic end
        
        /*
        #函數說明:
        #apache hive官方提供的PHP API
        #回傳結果:
        #$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
        #$result["functin"],字串,當前函數的名稱.
        #$result["error"],陣列,錯訊訊息.
        #$result["content"],執行完query的回傳內容.
        #$result["qStr"],查詢的語句.
        #必填參數:
        #$conf["thrift_root"],字串,存有 hive 散布的 php THRIFT_ROOT 路徑.
        $conf["thrift_root"]="";
        #可省略參數:
        #$conf["fileArgu"],字串,__FILE__的內容,預設為__FILE__.
        #$conf["fileArgu"]=__FILE__;
        #備註:
        #建構中...,套件THRIFT有問題
        */
        /*
        function nativeQuery(&$conf=array()){
                
                #初始化要回傳的結果
                $result=array();

                #取得當前執行的函數名稱
                $result["function"]=__FUNCTION__;

                #如果沒有參數
                if(func_num_args()==0){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"]="函數".$result["function"]."需要參數";
                        
                        #回傳結果
                        return $result;
                        
                        }#if end

                #取得參數
                $result["argu"]=$conf;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";
                        
                        #如果傳入的參數為 null
                        if($conf==null){
                                
                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
                                
                                }#if end

                        #回傳結果
                        return $result;
                        
                        }#if end
        
                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("thrift_root");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
                #$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
                #$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
                #$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
                #$conf["skipableVariableCanNotBeEmpty"]=array();
                #$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu");
                #$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__);
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
                #$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);  
                        
                #如果檢查參數失敗
                if($checkArguments["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #如果檢查參數不通過
                if($checkArguments["passed"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                
                #轉換 $conf["thrift_root"] 路徑為伺服器上的絕對路徑
                #函數說明:
                #將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
                #回傳結果:
                #$result["status"],"true"爲建立成功,"false"爲建立失敗.
                #$result["error"],錯誤訊息陣列.
                #$result["function"],函數名稱. 
                #$result["content"],網址,若是在命令列執行,則為"null".
                #$result["webPathFromRoot"],相對於網頁根目錄的路徑.
                #$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
                #$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
                #必填參數:
                #$conf["address"],字串,檔案的相對位置,若為絕對位置則會自動轉換成相對位置.
                $conf["fileAccess::getInternetAddress"]["address"]=$conf["thrift_root"];
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
                $conf["fileAccess::getInternetAddress"]["fileArgu"]=$conf["fileArgu"];
                #可省略參數:
                #$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
                $conf["fileAccess::getInternetAddress"]["userDir"]="true";
                #備註:
                #在命令列執行,所得的路徑是錯誤的。
                $getInternetAddress=fileAccess::getInternetAddress($conf["fileAccess::getInternetAddress"]);                    
                unset($conf["fileAccess::getInternetAddress"]);

                #如果轉換路徑失敗
                if($getInternetAddress["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$getInternetAddress;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                
                // set THRIFT_ROOT to php directory of the hive distribution
                $GLOBALS['THRIFT_ROOT'] = $getInternetAddress["fileSystemAbsoulutePosition"];
                                        
                #檢查檔案是否存在
                #涵式說明:檢查多個檔案與資料夾是否存在.
                #回傳的結果:
                #$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
                #$result["error"],錯誤訊息陣列.
                #$resutl["function"],當前執行的涵式名稱.
                #$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
                #$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
                #$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱。
                #$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址
                #$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
                #必填參數:
                #$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
                $conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($GLOBALS['THRIFT_ROOT'] . '/packages/hive_service/ThriftHive.php',$GLOBALS['THRIFT_ROOT'] . '/transport/TSocket.php',$GLOBALS['THRIFT_ROOT'] . '/protocol/TBinaryProtocol.php',$GLOBALS['THRIFT_ROOT'] . '/packages/hive_metastore/metastore/ThriftHiveMetastore.php');
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
                $conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
                #可省略參數
                #$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
                #$conf["disableWebSearch"]="false";
                #$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
                #$conf["userDir"]="true";
                #參考資料來源:
                #http://php.net/manual/en/function.file-exists.php
                #http://php.net/manual/en/control-structures.foreach.php
                #備註:
                #函數file_exists檢查的路徑為檔案系統的路徑
                $checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
                unset($conf["fileAccess::checkMultiFileExist"]);                        
                
                #如果檢查檔案是否存在失敗
                if($checkMultiFileExist["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$checkMultiFileExist;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #如果檔案不存在
                if($checkMultiFileExist["allExist"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$checkMultiFileExist;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                
                // load the required files for connecting to Hive
                require_once $GLOBALS['THRIFT_ROOT'] . '/packages/hive_metastore/metastore/ThriftHiveMetastore.php';
                require_once $GLOBALS['THRIFT_ROOT'] . '/packages/hive_service/ThriftHive.php';
                require_once $GLOBALS['THRIFT_ROOT'] . '/transport/TSocket.php';
                require_once $GLOBALS['THRIFT_ROOT'] . '/protocol/TBinaryProtocol.php';
                
                // Set up the transport/protocol/client
                $transport = new TSocket('localhost', 10000);
                $protocol = new TBinaryProtocol($transport);
                $client = new ThriftHiveClient($protocol);
                $transport->open();
                 
                // run queries, metadata calls etc
                $client->execute('SELECT * from pokes;');
                $result["content"]=($client->fetchAll());
                $transport->close();
                
                #設置執行正常
                $result["status"]="true";
                
                #回傳結果
                return $result;
                
                }#function nativeQuery end
        */
        
        /*
        #涵式說明:
        #執行hiveSQL,取得未解析的SQL結果.
        #回傳結果:
        #$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
        #$result["functin"],字串,當前函數的名稱.
        #$result["error"],陣列,錯訊訊息.
        #$result["argu"],字串陣列,呼叫web service所用的參數.
        #$result["content"],執行完query的回傳內容.
        #$result["cmd"],執行的指令.
        #必填參數:
        #$conf["sql"],字串,要執行的sql字串.
        $conf["sql"]="";
        #$conf["beeline"],字串,beeline程式的位置.
        $conf["beeline"]="beeline";             
        #可省略參數:
        #$conf["fileArgu"],字串.__FILE__的內容,若省略,則為伺服器上該檔案的位置.
        #$conf["fileArgu"]=__FILE__;
        #$conf["userName"],字串,執行beeline程式的使用者名稱.
        #$conf["userName"]="liveuser";
        #$conf["userPass"],字串,執行beeline程式的使用者名稱對應的密碼.
        #$conf["userPass"]="password";
        #備註:
        #若使用 $conf["userName"] 跟 $conf["userPass"] 則會因為$conf["sql"]中含有「'或"」而造成指令錯誤.
        */
        function query(&$conf){
                
                #初始化要回傳的結果
                $result=array();

                #取得當前執行的函數名稱
                $result["function"]=__FUNCTION__;

                #如果沒有參數
                if(func_num_args()==0){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"]="函數".$result["function"]."需要參數";
                        
                        #回傳結果
                        return $result;
                        
                        }#if end

                #取得參數
                $result["argu"]=$conf;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";
                        
                        #如果傳入的參數為 null
                        if($conf==null){
                                
                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
                                
                                }#if end

                        #回傳結果
                        return $result;
                        
                        }#if end
        
                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("sql","beeline");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
                #$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
                $conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
                #$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
                #$conf["skipableVariableCanNotBeEmpty"]=array();
                #$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu","userName","userPass");
                #$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__,null,null);
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
                #$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);  
                        
                #如果檢查參數失敗
                if($checkArguments["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #如果檢查參數不通過
                if($checkArguments["passed"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                                
                #產生暫存的檔案名稱
                #函數說明:
                #回傳西元的目前時間,格式為2010年07月24日15時30分33秒
                #回傳結果:
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["content"],西元的目前時間,格式為2010年07月24日15時30分33秒
                #必填參數:
                #$conf["timeZone"],字串,時區代號,可以設定的時區列表:http://www.php.net/manual/en/timezones.php, ex:"Asia/Taipei".
                $conf["time::getFullDateAndTime"]["timeZone"]="Asia/Taipei";
                #可省略參數:
                #$conf["showSecond"],字串,若爲"true"則會顯示秒數,預設為"true".     
                $conf["time::getFullDateAndTime"]["showSecond"]="true";
                #參考資料:
                #date函數用法=>http://php.net/manual/en/function.date.php.
                $getFullDateAndTime=time::getFullDateAndTime($conf["time::getFullDateAndTime"]);
                unset($conf["time::getFullDateAndTime"]);
                
                #如果取得時間失敗
                if($getFullDateAndTime["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$getFullDateAndTime;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #取得暫存的檔案名稱    
                $tempCsvFile=$getFullDateAndTime["content"];
                
                #暫存的目錄
                $tempPath=".hive";
                
                #轉換暫存的目錄為絕對路徑
                #函數說明:
                #將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
                #回傳結果:
                #$result["status"],"true"爲建立成功,"false"爲建立失敗.
                #$result["error"],錯誤訊息陣列.
                #$result["function"],函數名稱. 
                #$result["content"],網址,若是在命令列執行,則為"null".
                #$result["webPathFromRoot"],相對於網頁根目錄的路徑.
                #$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
                #$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
                #必填參數:
                #$conf["address"],字串,檔案的相對位置,若為絕對位置則會自動轉換成相對位置.
                $conf["fileAccess::getInternetAddress"]["address"]=$tempPath;
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
                $conf["fileAccess::getInternetAddress"]["fileArgu"]=$conf["fileArgu"];
                #可省略參數:
                #$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
                #$conf["fileAccess::getInternetAddress"]["userDir"]="false";
                #備註:
                #在命令列執行,所得的路徑是錯誤的。
                $getInternetAddress=fileAccess::getInternetAddress($conf["fileAccess::getInternetAddress"]);
                unset($conf["fileAccess::getInternetAddress"]);
                
                #如果取得網路位置失敗
                if($getInternetAddress["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$getInternetAddress;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #取得轉換好的絕對位置
                $tempPath=$getInternetAddress["fileSystemAbsoulutePosition"];
                
                #函式說明:
                #檢查要建立的檔案路徑是否存在,若不存在則建立新檔案,若檔案已存在則會在原檔名後面加上從(1)開始的編號,再度嘗試建立檔案,以避免資料異常.
                #回傳的結果:
                #$result["status"],執行狀態,"true"代表執行正常,"false"代表執行失敗.
                #$result["error"],錯誤訊息陣列.
                #$result["function"],當前執行的函數名稱.
                #$result["createdFileName"],建立好的檔案名稱.
                #$result["createdFilePath"],檔案建立的路徑.
                #$result["createdFilePathAndName"].建立好的檔案名稱與路徑.
                #必填的參數:
                #$conf["checkedFileAndPath"],字串陣列,要建立的檔案路徑
                $conf["fileAccess::createFileAfterCheck"]["checkedFileAndPath"]=$tempPath."/".$tempCsvFile.".csv";
                #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
                $conf["fileAccess::createFileAfterCheck"]["fileArgu"]=$conf["fileArgu"];
                $createFileAfterCheck=fileAccess::createFileAfterCheck($conf["fileAccess::createFileAfterCheck"]);
                unset($conf["fileAccess::createFileAfterCheck"]);
                                
                #如果建立檔案失敗
                if($createFileAfterCheck["status"]=="false"){

                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$createFileAfterCheck;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #取得暫存的csv檔案路徑 
                $tempCsvFile=$createFileAfterCheck["createdFilePathAndName"];
                        
                #初始化要執行的指令
                $cmd="";
                
                #如果有設定 $conf["userName"] 跟 $conf["userPass"]
                if(isset($conf["userName"]) && isset($conf["userPass"])){
                        
                        $cmd="echo ".$conf["userPass"]." | su ".$conf["userName"]." -c '".$conf["beeline"]." --silent=true --outputformat=csv2 -u jdbc:hive2://localhost:10000 -e \"".$conf["sql"]."\" > \"".$tempCsvFile."\"' ";
                        
                        }#if end        

                #反之
                else{
                        
                        $cmd=$conf["beeline"]." --silent=true --outputformat=csv2 -u jdbc:hive2://localhost:10000 -e \"".$conf["sql"]."\" > \"".$tempCsvFile."\"";
                        
                        }#else end
                                
                #運行beeline執行hiveSQL
                #涵式說明:
                #呼叫shell執行系統命令,並取得回傳的內容.
                #回傳的結果:
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$result["error"],錯誤訊息陣列.
                #$result["function"],當前執行的函數名稱.
                #$result["cmd"],執行的指令內容.
                #$result["output"],爲執行完二元碼後的輸出陣列.
                #必填的參數
                #$conf["command"],字串,要執行的指令與.
                $conf["external::callShell"]["command"]=$cmd;
                #可省略參數:
                #$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
                #$conf["argu"]=array("");
                #$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
                #$conf["enablePrintDescription"]="true";
                #$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
                #$conf["printDescription"]="";
                #$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
                #$conf["escapeshellarg"]="false";
                #備註:
                #不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行.
                #參考資料:
                #exec=>http://php.net/manual/en/function.exec.php
                #escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
                #escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
                $callShell=external::callShell($conf["external::callShell"]);
                unset($conf["external::callShell"]);
                
                #如果執行beeline失敗
                if($callShell["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$callShell;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #取得執行的指令
                $result["cmd"]=$callShell["cmd"];
                        
                #取得暫存檔案裡面的內容
                $result["content"]=file($tempCsvFile);
                
                #移除暫存的檔案
                unlink($tempCsvFile);
                
                #設置執行正常
                $result["status"]="true";
                
                #回傳結果
                return $result;
                
                }#function query end
                
        /*
        #涵式說明:
        #執行hiveSQL,取得資料庫列表.
        #回傳結果:
        #$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
        #$result["functin"],字串,當前函數的名稱.
        #$result["error"],陣列,錯訊訊息.
        #$result["content"],執行完query的回傳內容.
        #$result["cmd"],執行的指令.
        #必填參數:
        #$conf["beeline"],字串,beeline程式的位置.
        $conf["beeline"]="beeline";             
        #可省略參數:
        #$conf["fileArgu"],字串.__FILE__的內容,若省略,則為伺服器上該檔案的位置.
        #$conf["fileArgu"]=__FILE__
        #$conf["userName"],字串,執行beeline程式的使用者名稱.
        #$conf["userName"]="liveuser";
        #$conf["userPass"],字串,執行beeline程式的使用者名稱對應的密碼.
        #$conf["userPass"]="password";
        */
        function getDbList(&$conf){
                
                #初始化要回傳的結果
                $result=array();

                #取得當前執行的函數名稱
                $result["function"]=__FUNCTION__;

                #如果沒有參數
                if(func_num_args()==0){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"]="函數".$result["function"]."需要參數";
                        
                        #回傳結果
                        return $result;
                        
                        }#if end

                #取得參數
                $result["argu"]=$conf;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";
                        
                        #如果傳入的參數為 null
                        if($conf==null){
                                
                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
                                
                                }#if end

                        #回傳結果
                        return $result;
                        
                        }#if end
        
                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("beeline");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
                #$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
                $conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
                #$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
                #$conf["skipableVariableCanNotBeEmpty"]=array();
                #$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu","userName","userPass");
                #$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__,null,null);
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
                #$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);  
                        
                #如果檢查參數失敗
                if($checkArguments["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #如果檢查參數不通過
                if($checkArguments["passed"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #涵式說明:
                #執行hiveSQL,取得未解析的SQL結果.
                #回傳結果:
                #$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
                #$result["functin"],字串,當前函數的名稱.
                #$result["error"],陣列,錯訊訊息.
                #$result["content"],執行完query的回傳內容.
                #$result["cmd"],執行的指令.
                #必填參數:
                #$conf["sql"],字串,要執行的sql字串.
                $conf["hive::query"]["sql"]="show databases;";
                #$conf["beeline"],字串,beeline程式的位置.
                $conf["hive::query"]["beeline"]=$conf["beeline"];               
                #可省略參數:
                #$conf["fileArgu"],字串.__FILE__的內容,若省略,則為伺服器上該檔案的位置.
                $conf["hive::query"]["fileArgu"]=$conf["fileArgu"];
                
                #如果有設置 $conf["userName"] 與 $conf["userPass"]
                if(isset($conf["userName"]) && isset($conf["userPass"])){
                        
                        #$conf["userName"],字串,執行beeline程式的使用者名稱.
                        $conf["hive::query"]["userName"]=$conf["userName"];
                        #$conf["userPass"],字串,執行beeline程式的使用者名稱對應的密碼.                 
                        $conf["hive::query"]["userPass"]=$conf["userPass"];
                        
                        }#if end
                
                #備註:
                #若使用 $conf["userName"] 跟 $conf["userPass"] 則會因為$conf["sql"]中含有「'或"」而造成指令錯誤.
                $query=hive::query($conf["hive::query"]);
                unset($conf["hive::query"]);
                
                #如果查詢失敗
                if($query["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$query;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #解析回傳的內容          
                #涵式說明:
                #處理多個字串避免網頁出錯
                #回傳的結果:
                #$result["status"],"true"代表執行成功,"false"代表執行失敗。
                #$result["function"],當前執行的函數.
                #$result["error"],錯誤訊息
                #$result["processedStrArray"],處理好的字串陣列
                #必填的參數:
                $conf["stringProcess::correctMutiStrCharacter"]["stringIn"]=$query["content"];#爲要處理的字串陣列
                #可省略的參數:
                $conf["stringProcess::correctMutiStrCharacter"]["selectedCharacter"]=array("\n");#爲被選擇要處理的字串/字元,須爲陣列值。
                        #若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
                        #特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
                #$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
                $correctMutiStrCharacter=stringProcess::correctMutiStrCharacter($conf["stringProcess::correctMutiStrCharacter"]);
                unset($conf["stringProcess::correctMutiStrCharacter"]);
                
                #如果過濾字串失敗
                if($correctMutiStrCharacter["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$correctMutiStrCharacter;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #移除資料庫的名稱的標題
                #涵式說明:
                #將陣列中特定元素剔除,並重新按照順序排序
                #回傳的結果:
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$result["error"],錯誤訊息
                #$result["function"],當前執行的函數
                #$result["empty"],移除完元素後是否為空陣列,"true"為是,"false"為否.
                #$result["content"]["byName"],剔除掉特定元素的陣列,使用原來陣列的key來儲存.
                #$result["content"]["byNumber"],剔除掉特定元素的陣列,使用從0開始的整數key來儲存.
                #必填的參數:
                $conf["arrays::eraseElement"]["rawInputArray"]=$correctMutiStrCharacter["processedStrArray"];#要處理的原始數字陣列
                $conf["arrays::eraseElement"]["eraseElementKey"]="0";#要移除的元素key值  
                $eraseElement=arrays::eraseElement($conf["arrays::eraseElement"]);
                unset($conf["arrays::eraseElement"]);
                
                #如果移除元素失敗
                if($eraseElement["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$eraseElement;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                
                #取得解析好的內容
                $result["content"]=$eraseElement["content"]["byNumber"];
                
                #設置執行正常
                $result["status"]="true";
                
                #回傳結果
                return $result;                 
                
                }#function getDbList end
        
        /*
        #涵式說明:
        #執行hiveSQL,取得資料表列表.
        #回傳結果:
        #$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
        #$result["functin"],字串,當前函數的名稱.
        #$result["error"],陣列,錯訊訊息.
        #$result["content"],執行完query的回傳內容.
        #$result["cmd"],執行的指令.
        #必填參數:
        #$conf["beeline"],字串,beeline程式的位置.
        $conf["beeline"]="beeline";             
        #$conf["dbName"],字串,要取得資料表列表的目標資料庫名稱.
        $conf["dbName"]="";     
        #可省略參數:
        #$conf["fileArgu"],字串.__FILE__的內容,若省略,則為伺服器上該檔案的位置.
        #$conf["fileArgu"]=__FILE__
        #$conf["userName"],字串,執行beeline程式的使用者名稱.
        #$conf["userName"]="liveuser";
        #$conf["userPass"],字串,執行beeline程式的使用者名稱對應的密碼.
        #$conf["userPass"]="password";
        */
        function getDtList(&$conf){
                
                #初始化要回傳的結果
                $result=array();

                #取得當前執行的函數名稱
                $result["function"]=__FUNCTION__;

                #如果沒有參數
                if(func_num_args()==0){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"]="函數".$result["function"]."需要參數";
                        
                        #回傳結果
                        return $result;
                        
                        }#if end

                #取得參數
                $result["argu"]=$conf;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";
                        
                        #如果傳入的參數為 null
                        if($conf==null){
                                
                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
                                
                                }#if end

                        #回傳結果
                        return $result;
                        
                        }#if end
        
                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("beeline","dbName");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
                #$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
                $conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
                #$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
                #$conf["skipableVariableCanNotBeEmpty"]=array();
                #$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu","userName","userPass");
                #$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__,null,null);
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
                #$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);  
                        
                #如果檢查參數失敗
                if($checkArguments["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #如果檢查參數不通過
                if($checkArguments["passed"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #涵式說明:
                #執行hiveSQL,取得未解析的SQL結果.
                #回傳結果:
                #$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
                #$result["functin"],字串,當前函數的名稱.
                #$result["error"],陣列,錯訊訊息.
                #$result["content"],執行完query的回傳內容.
                #$result["cmd"],執行的指令.
                #必填參數:
                #$conf["sql"],字串,要執行的sql字串.
                $conf["hive::query"]["sql"]="use ".$conf["dbName"]."; show tables;";
                #$conf["beeline"],字串,beeline程式的位置.
                $conf["hive::query"]["beeline"]=$conf["beeline"];               
                #可省略參數:
                #$conf["fileArgu"],字串.__FILE__的內容,若省略,則為伺服器上該檔案的位置.
                $conf["hive::query"]["fileArgu"]=$conf["fileArgu"];
                
                #如果有設置 $conf["userName"] 與 $conf["userPass"]
                if(isset($conf["userName"]) && isset($conf["userPass"])){
                        
                        #$conf["userName"],字串,執行beeline程式的使用者名稱.
                        $conf["hive::query"]["userName"]=$conf["userName"];
                        #$conf["userPass"],字串,執行beeline程式的使用者名稱對應的密碼.                 
                        $conf["hive::query"]["userPass"]=$conf["userPass"];
                        
                        }#if end
                
                #備註:
                #若使用 $conf["userName"] 跟 $conf["userPass"] 則會因為$conf["sql"]中含有「'或"」而造成指令錯誤.
                $query=hive::query($conf["hive::query"]);
                unset($conf["hive::query"]);
                
                #如果查詢失敗
                if($query["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$query;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #解析回傳的內容          
                #涵式說明:
                #處理多個字串避免網頁出錯
                #回傳的結果:
                #$result["status"],"true"代表執行成功,"false"代表執行失敗。
                #$result["function"],當前執行的函數.
                #$result["error"],錯誤訊息
                #$result["processedStrArray"],處理好的字串陣列
                #必填的參數:
                $conf["stringProcess::correctMutiStrCharacter"]["stringIn"]=$query["content"];#爲要處理的字串陣列
                #可省略的參數:
                $conf["stringProcess::correctMutiStrCharacter"]["selectedCharacter"]=array("\n");#爲被選擇要處理的字串/字元,須爲陣列值。
                        #若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
                        #特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
                #$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
                $correctMutiStrCharacter=stringProcess::correctMutiStrCharacter($conf["stringProcess::correctMutiStrCharacter"]);
                unset($conf["stringProcess::correctMutiStrCharacter"]);
                
                #如果過濾字串失敗
                if($correctMutiStrCharacter["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$correctMutiStrCharacter;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #移除資料庫的名稱的標題
                #涵式說明:
                #將陣列中特定元素剔除,並重新按照順序排序
                #回傳的結果:
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$result["error"],錯誤訊息
                #$result["function"],當前執行的函數
                #$result["empty"],移除完元素後是否為空陣列,"true"為是,"false"為否.
                #$result["content"]["byName"],剔除掉特定元素的陣列,使用原來陣列的key來儲存.
                #$result["content"]["byNumber"],剔除掉特定元素的陣列,使用從0開始的整數key來儲存.
                #必填的參數:
                $conf["arrays::eraseElement"]["rawInputArray"]=$correctMutiStrCharacter["processedStrArray"];#要處理的原始數字陣列
                $conf["arrays::eraseElement"]["eraseElementKey"]="0";#要移除的元素key值  
                $eraseElement=arrays::eraseElement($conf["arrays::eraseElement"]);
                unset($conf["arrays::eraseElement"]);
                
                #如果移除元素失敗
                if($eraseElement["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$eraseElement;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                
                #取得解析好的內容
                $result["content"]=$eraseElement["content"]["byNumber"];
                
                #設置執行正常
                $result["status"]="true";
                
                #回傳結果
                return $result;                 
                
                }#function getDtList end
        
        /*
        #涵式說明:
        #執行hiveSQL,取得資料表結構.
        #回傳結果:
        #$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
        #$result["functin"],字串,當前函數的名稱.
        #$result["error"],陣列,錯訊訊息.
        #$result["content"],執行完query的回傳內容.
        #$result["cmd"],執行的指令.
        #必填參數:
        #$conf["beeline"],字串,beeline程式的位置.
        $conf["beeline"]="beeline";             
        #$conf["dbName"],字串,要取得資料表結構的目標資料庫名稱.
        $conf["dbName"]="";     
        #$conf["dtName"],字串,要取得結構的目標資料表名稱.
        $conf["dtName"]="";     
        #可省略參數:
        #$conf["fileArgu"],字串.__FILE__的內容,若省略,則為伺服器上該檔案的位置.
        #$conf["fileArgu"]=__FILE__
        #$conf["userName"],字串,執行beeline程式的使用者名稱.
        #$conf["userName"]="liveuser";
        #$conf["userPass"],字串,執行beeline程式的使用者名稱對應的密碼.
        #$conf["userPass"]="password";
        */
        function getDtStruc(&$conf){
                
                #初始化要回傳的結果
                $result=array();

                #取得當前執行的函數名稱
                $result["function"]=__FUNCTION__;

                #如果沒有參數
                if(func_num_args()==0){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"]="函數".$result["function"]."需要參數";
                        
                        #回傳結果
                        return $result;
                        
                        }#if end

                #取得參數
                $result["argu"]=$conf;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";
                        
                        #如果傳入的參數為 null
                        if($conf==null){
                                
                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
                                
                                }#if end

                        #回傳結果
                        return $result;
                        
                        }#if end
        
                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("beeline","dbName","dtName");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string");
                #$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
                $conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
                #$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
                #$conf["skipableVariableCanNotBeEmpty"]=array();
                #$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu","userName","userPass");
                #$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__,null,null);
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
                #$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);  
                        
                #如果檢查參數失敗
                if($checkArguments["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #如果檢查參數不通過
                if($checkArguments["passed"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #涵式說明:
                #執行hiveSQL,取得未解析的SQL結果.
                #回傳結果:
                #$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
                #$result["functin"],字串,當前函數的名稱.
                #$result["error"],陣列,錯訊訊息.
                #$result["content"],執行完query的回傳內容.
                #$result["cmd"],執行的指令.
                #必填參數:
                #$conf["sql"],字串,要執行的sql字串.
                $conf["hive::query"]["sql"]="use ".$conf["dbName"]."; DESCRIBE ".$conf["dtName"].";";
                #$conf["beeline"],字串,beeline程式的位置.
                $conf["hive::query"]["beeline"]=$conf["beeline"];               
                #可省略參數:
                #$conf["fileArgu"],字串.__FILE__的內容,若省略,則為伺服器上該檔案的位置.
                $conf["hive::query"]["fileArgu"]=$conf["fileArgu"];
                
                #如果有設置 $conf["userName"] 與 $conf["userPass"]
                if(isset($conf["userName"]) && isset($conf["userPass"])){
                        
                        #$conf["userName"],字串,執行beeline程式的使用者名稱.
                        $conf["hive::query"]["userName"]=$conf["userName"];
                        #$conf["userPass"],字串,執行beeline程式的使用者名稱對應的密碼.                 
                        $conf["hive::query"]["userPass"]=$conf["userPass"];
                        
                        }#if end
                
                #備註:
                #若使用 $conf["userName"] 跟 $conf["userPass"] 則會因為$conf["sql"]中含有「'或"」而造成指令錯誤.
                $query=hive::query($conf["hive::query"]);
                unset($conf["hive::query"]);
                
                #如果查詢失敗
                if($query["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$query;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #解析回傳的內容          
                #涵式說明:
                #處理多個字串避免網頁出錯
                #回傳的結果:
                #$result["status"],"true"代表執行成功,"false"代表執行失敗。
                #$result["function"],當前執行的函數.
                #$result["error"],錯誤訊息
                #$result["processedStrArray"],處理好的字串陣列
                #必填的參數:
                $conf["stringProcess::correctMutiStrCharacter"]["stringIn"]=$query["content"];#爲要處理的字串陣列
                #可省略的參數:
                $conf["stringProcess::correctMutiStrCharacter"]["selectedCharacter"]=array("\n");#爲被選擇要處理的字串/字元,須爲陣列值。
                        #若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
                        #特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
                #$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
                $correctMutiStrCharacter=stringProcess::correctMutiStrCharacter($conf["stringProcess::correctMutiStrCharacter"]);
                unset($conf["stringProcess::correctMutiStrCharacter"]);
                
                #如果過濾字串失敗
                if($correctMutiStrCharacter["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$correctMutiStrCharacter;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #移除資料庫的名稱的標題
                #涵式說明:
                #將陣列中特定元素剔除,並重新按照順序排序
                #回傳的結果:
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$result["error"],錯誤訊息
                #$result["function"],當前執行的函數
                #$result["empty"],移除完元素後是否為空陣列,"true"為是,"false"為否.
                #$result["content"]["byName"],剔除掉特定元素的陣列,使用原來陣列的key來儲存.
                #$result["content"]["byNumber"],剔除掉特定元素的陣列,使用從0開始的整數key來儲存.
                #必填的參數:
                $conf["arrays::eraseElement"]["rawInputArray"]=$correctMutiStrCharacter["processedStrArray"];#要處理的原始數字陣列
                $conf["arrays::eraseElement"]["eraseElementKey"]="0";#要移除的元素key值  
                $eraseElement=arrays::eraseElement($conf["arrays::eraseElement"]);
                unset($conf["arrays::eraseElement"]);
                
                #如果移除元素失敗
                if($eraseElement["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$eraseElement;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                
                #取得欄位的名稱、類型、註解
                #涵式說明:
                #將多個固定格式的字串分開,並回傳分開的結果
                #回傳的參數:
                #$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
                #$result["error"],錯誤訊息陣列.
                #$result["function"],當前執行的函數名稱.
                #$result["spiltString"][$i]["oriStr"],爲第i個字串的原始內容
                #$result["spiltString"][$i]["dataArray"],爲第($i+1)個字串分割後的字串陣列
                #$result["spiltString"][$i]["dataArray"][$j],爲第($i+1)的分割好的字串的第($j+1)段內容
                #$result["spiltString"][$i]["dataCounts"],爲第($i+1)個字串分割後總共分成幾段
                #必填的參數:
                #$conf["stringIn"],字串陣列,要處理的字串陣列.
                $conf["stringProcess::spiltMutiString"]["stringIn"]=$eraseElement["content"]["byName"];
                #$conf["spiltSymbol"],字串,爲要以哪個符號作爲分割.
                $conf["stringProcess::spiltMutiString"]["spiltSymbol"]=",";
                $spiltMutiString=stringProcess::spiltMutiString($conf["stringProcess::spiltMutiString"]);
                unset($conf["stringProcess::spiltMutiString"]);
                
                #如果分割欄位資訊失敗
                if($spiltMutiString["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$spiltMutiString;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                
                #針對每個欄位
                foreach($spiltMutiString["spiltString"] as $num=>$col){
                        
                        #如果欄位資訊沒有大於等於2個
                        if($col["dataCounts"]<2){
                                
                                #設置執行不正常
                                $result["status"]="false";
                                
                                #設置執行錯誤
                                $result["error"][]="欄位資訊解析錯誤";
                                
                                #回傳結果
                                return $result;
                                
                                }#if end
                        
                        #取得欄位的名稱  
                        $result["content"][$num]["name"]=$col["dataArray"][0];
                        
                        #取得欄位的類型
                        $result["content"][$num]["type"]=$col["dataArray"][1];
                        
                        #如果存在註解
                        if(isset($col["dataArray"][2])){
                                
                                #取得註解
                                $result["content"][$num]["comment"]=$col["dataArray"][2];
                                
                                }#if end
                        
                        }#foreach end
                                        
                #設置執行正常
                $result["status"]="true";
                
                #回傳結果
                return $result;                 
                
                }#function getDtStruc end
                
        /*
        #涵式說明:
        #執行hiveSQL,取得資料表資料.
        #回傳結果:
        #$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
        #$result["functin"],字串,當前函數的名稱.
        #$result["error"],陣列,錯訊訊息.
        #$result["content"],執行完query的回傳內容.
        #$result["colName"],陣列,欄位的名稱.
        #$result["cmd"],執行的指令.
        #必填參數:
        #$conf["beeline"],字串,beeline程式的位置.
        $conf["beeline"]="beeline";             
        #$conf["dbName"],字串,要取得資料表資料的目標資料庫名稱.
        $conf["dbName"]="";     
        #$conf["dtName"],字串,要取得資料的目標資料表名稱.
        $conf["dtName"]="";     
        #可省略參數:
        #$conf["fileArgu"],字串.__FILE__的內容,若省略,則為伺服器上該檔案的位置.
        #$conf["fileArgu"]=__FILE__
        #$conf["userName"],字串,執行beeline程式的使用者名稱.
        #$conf["userName"]="liveuser";
        #$conf["userPass"],字串,執行beeline程式的使用者名稱對應的密碼.
        #$conf["userPass"]="password";
        */
        function getDtData(&$conf){
                
                #初始化要回傳的結果
                $result=array();

                #取得當前執行的函數名稱
                $result["function"]=__FUNCTION__;

                #如果沒有參數
                if(func_num_args()==0){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"]="函數".$result["function"]."需要參數";
                        
                        #回傳結果
                        return $result;
                        
                        }#if end

                #取得參數
                $result["argu"]=$conf;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";
                        
                        #如果傳入的參數為 null
                        if($conf==null){
                                
                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
                                
                                }#if end

                        #回傳結果
                        return $result;
                        
                        }#if end
        
                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("beeline","dbName","dtName");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string");
                #$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
                $conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
                #$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
                #$conf["skipableVariableCanNotBeEmpty"]=array();
                #$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu","userName","userPass");
                #$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__,null,null);
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
                #$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);  
                        
                #如果檢查參數失敗
                if($checkArguments["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #如果檢查參數不通過
                if($checkArguments["passed"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                
                #涵式說明:
                #執行hiveSQL,取得未解析的SQL結果.
                #回傳結果:
                #$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
                #$result["functin"],字串,當前函數的名稱.
                #$result["error"],陣列,錯訊訊息.
                #$result["argu"],字串陣列,呼叫web service所用的參數.
                #$result["content"],執行完query的回傳內容.
                #$result["cmd"],執行的指令.
                #必填參數:
                #$conf["sql"],字串,要執行的sql字串.
                $conf["hive::query"]["sql"]="use ".$conf["dbName"]."; select * from pokes;";
                #$conf["beeline"],字串,beeline程式的位置.
                $conf["hive::query"]["beeline"]=$conf["beeline"];               
                #可省略參數:
                #$conf["fileArgu"],字串.__FILE__的內容,若省略,則為伺服器上該檔案的位置.
                #$conf["fileArgu"]=__FILE__;
                #$conf["userName"],字串,執行beeline程式的使用者名稱.
                #$conf["userName"]="liveuser";
                #$conf["userPass"],字串,執行beeline程式的使用者名稱對應的密碼.
                #$conf["userPass"]="password";
                #備註:
                #若使用 $conf["userName"] 跟 $conf["userPass"] 則會因為$conf["sql"]中含有「'或"」而造成指令錯誤.
                $query=hive::query($conf["hive::query"]);
                unset($conf["hive::query"]);
                
                #如果 query 失敗
                if($query["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$query;
                        
                        #回傳結果
                        return $result; 
                        
                        }#if end
                
                #初始化儲存標題欄位名稱的變數
                $colName=array();
                
                #依據 $query["content"] 的數量
                for($i=0;$i<count($query["content"]);$i++){
                        
                        #用逗號分割欄位
                        #涵式說明:
                        #將固定格式的字串分開,並回傳分開的結果。
                        #回傳結果:
                        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                        #$result["error"],錯誤訊息陣列
                        #$result["function"],當前執行的函數名稱.
                        #$result["oriStr"],要分割的原始字串內容
                        #$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
                        #$result["dataCounts"],爲總共分成幾段
                        #必填的參數:
                        $conf["stringProcess::spiltString"]["stringIn"]=$query["content"][$i];#要處理的字串。
                        $conf["stringProcess::spiltString"]["spiltSymbol"]=",";#爲以哪個符號作爲分割
                        #可省略參數:
                        #$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
                        $conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
                        $spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
                        unset($conf["stringProcess::spiltString"]);
                        
                        #如果分割字串失敗
                        if($spiltString["status"]=="false"){
                                
                                #設置執行不正常
                                $result["status"]="false";
                                
                                #設置執行錯誤
                                $result["error"]=$spiltString;
                                
                                #回傳結果
                                return $result;
                                
                                }#if end
                                
                        #如果是標題欄位
                        if($i==0){
                                        
                                #針對每個欄位
                                for($j=0;$j<$spiltString["dataCounts"];$j++){
                                        
                                        #將標題欄位的資料庫名稱剃除
                                        #涵式說明:
                                        #將固定格式的字串分開,並回傳分開的結果。
                                        #回傳結果:
                                        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                                        #$result["error"],錯誤訊息陣列
                                        #$result["function"],當前執行的函數名稱.
                                        #$result["oriStr"],要分割的原始字串內容
                                        #$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
                                        #$result["dataCounts"],爲總共分成幾段
                                        #必填的參數:
                                        $conf["stringProcess::spiltString"]["stringIn"]=$spiltString["dataArray"][$j];#要處理的字串。
                                        $conf["stringProcess::spiltString"]["spiltSymbol"]=".";#爲以哪個符號作爲分割
                                        #可省略參數:
                                        #$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
                                        $conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
                                        $spiltColStr=stringProcess::spiltString($conf["stringProcess::spiltString"]);
                                        unset($conf["stringProcess::spiltString"]);
                                        
                                        #如果分割字串失敗
                                        if($spiltColStr["status"]=="false"){
                                                
                                                #設置執行不正常
                                                $result["status"]="false";
                                                
                                                #設置執行錯誤
                                                $result["error"]=$spiltColStr;
                                                
                                                #回傳結果
                                                return $result;
                                                
                                                }#if end
                                                
                                        #過濾欄位的換行符號
                                        #涵式說明:
                                        #處理字串避免網頁出錯
                                        #回傳的結果:
                                        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                                        #$result["function"],當前執行的函數.
                                        #$result["content"],爲處理好的字串.
                                        #$result["error"],錯誤訊息陣列.
                                        #必填的參數:
                                        $conf["stringProcess::correctCharacter"]["stringIn"]=$spiltColStr["dataArray"][1];#爲要處理的字串
                                        #可省略的參數:
                                        $conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("\n");#爲被選擇要處理的字串/字元,須爲陣列值。
                                                #若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
                                                #特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
                                        #$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
                                        $correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
                                        unset($conf["stringProcess::correctCharacter"]);
                                                
                                        #如果過濾字串失敗
                                        if($correctCharacter["status"]=="false"){
                                                
                                                #設置執行不正常
                                                $result["status"]="false";
                                                
                                                #設置執行錯誤
                                                $result["error"]=$correctCharacter;
                                                
                                                #回傳結果
                                                return $result;
                                                
                                                }#if end        
                                                
                                        #取得欄位名稱
                                        $colName[]=$correctCharacter["content"];
                                        
                                        }#for end
                                                                        
                                }#if end
                        
                        #反之是資料欄位  
                        else{
                                
                                #針對每個資料欄位
                                for($j=0;$j<$spiltString["dataCounts"];$j++){
                                        
                                        #取得欄位資料
                                        #$result["content"][$colName[$j]][]=$spiltString["dataArray"][$j];
                                        $result["content"][$i-1][][$colName[$j]]=$spiltString["dataArray"][$j];
                                        
                                        }#for end
                                
                                }#else end
                        
                        }#for end
                        
                #儲存欄位的名稱
                $result["colName"]=$colName;    
                        
                #設置執行正常
                $result["status"]="true";
                
                #回傳結果
                return $result;
                
                }#function getDtData end
                
        /*
         
        */
        function updateData(&$conf=array()){
                
                }#function updateDate end
                
        /*
          
        */
        function delData(&$conf=array()){
                
                }#function delData
                
        /*

        */      
        function createTable(&$conf=array()){
                
                }#function create table end
                
        /*
         
        */
        function modifyTable(&$conf=array()){
                
                }#function modifyTable end
                
        /*
         
        */
        function delTable(&$conf=array()){
                
                }#function delTable end
                
        /*
        #函數說明:
        #建立資料庫,並回傳資料庫列表.
        #回傳結果:
        #$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
        #$result["functin"],字串,當前函數的名稱.
        #$result["error"],陣列,錯訊訊息.
        #$result["content"],資料庫列表.
        #$result["cmd"],執行的指令.
        #必填參數:
        #$conf["beeline"],字串,beeline程式的位置.
        $conf["beeline"]="beeline";             
        #$conf["dbName"],字串,要建立的資料庫名稱.
        $conf["dbName"]="";     
        #可省略參數:
        #$conf["fileArgu"],字串.__FILE__的內容,若省略,則為伺服器上該檔案的位置.
        #$conf["fileArgu"]=__FILE__
        #$conf["userName"],字串,執行beeline程式的使用者名稱.
        #$conf["userName"]="liveuser";
        #$conf["userPass"],字串,執行beeline程式的使用者名稱對應的密碼.
        #$conf["userPass"]="password"; 
        */
        function createDb(&$conf=array()){
                
                #初始化要回傳的結果
                $result=array();

                #取得當前執行的函數名稱
                $result["function"]=__FUNCTION__;

                #如果沒有參數
                if(func_num_args()==0){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"]="函數".$result["function"]."需要參數";
                        
                        #回傳結果
                        return $result;
                        
                        }#if end

                #取得參數
                $result["argu"]=$conf;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";
                        
                        #如果傳入的參數為 null
                        if($conf==null){
                                
                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
                                
                                }#if end

                        #回傳結果
                        return $result;
                        
                        }#if end
        
                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("beeline","dbName");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
                #$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
                $conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
                #$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
                #$conf["skipableVariableCanNotBeEmpty"]=array();
                #$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileArgu","userName","userPass");
                #$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(__FILE__,null,null);
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("conName","conVal");
                #$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("target","styleAttr","styleVal");
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);  
                        
                #如果檢查參數失敗
                if($checkArguments["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #如果檢查參數不通過
                if($checkArguments["passed"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #涵式說明:
                #執行hiveSQL,取得未解析的SQL結果.
                #回傳結果:
                #$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
                #$result["functin"],字串,當前函數的名稱.
                #$result["error"],陣列,錯訊訊息.
                #$result["content"],執行完query的回傳內容.
                #$result["cmd"],執行的指令.
                #必填參數:
                #$conf["sql"],字串,要執行的sql字串.
                $conf["hive::query"]["sql"]="create ".$conf["dbName"]."; show databases;";
                #$conf["beeline"],字串,beeline程式的位置.
                $conf["hive::query"]["beeline"]=$conf["beeline"];               
                #可省略參數:
                #$conf["fileArgu"],字串.__FILE__的內容,若省略,則為伺服器上該檔案的位置.
                $conf["hive::query"]["fileArgu"]=$conf["fileArgu"];
                
                #如果有設置 $conf["userName"] 與 $conf["userPass"]
                if(isset($conf["userName"]) && isset($conf["userPass"])){
                        
                        #$conf["userName"],字串,執行beeline程式的使用者名稱.
                        $conf["hive::query"]["userName"]=$conf["userName"];
                        #$conf["userPass"],字串,執行beeline程式的使用者名稱對應的密碼.                 
                        $conf["hive::query"]["userPass"]=$conf["userPass"];
                        
                        }#if end
                
                #備註:
                #若使用 $conf["userName"] 跟 $conf["userPass"] 則會因為$conf["sql"]中含有「'或"」而造成指令錯誤.
                $query=hive::query($conf["hive::query"]);
                unset($conf["hive::query"]);
                
                #取得建立資料庫執行的cmd
                $result["cmd"][]=$query["cmd"];                 
                
                #如果查詢失敗
                if($query["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$query;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #涵式說明:
                #執行hiveSQL,取得資料庫列表.
                #回傳結果:
                #$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.
                #$result["functin"],字串,當前函數的名稱.
                #$result["error"],陣列,錯訊訊息.
                #$result["content"],執行完query的回傳內容.
                #$result["cmd"],執行的指令.
                #必填參數:
                #$conf["beeline"],字串,beeline程式的位置.
                $conf["hive::getDbList"]["beeline"]=$conf["beeline"];           
                #可省略參數:
                #$conf["fileArgu"],字串.__FILE__的內容,若省略,則為伺服器上該檔案的位置.
                $conf["hive::getDbList"]["fileArgu"]=$conf["fileArgu"];
                
                #如果有設定 $conf["userName"]
                if(isset($conf["userName"])){
                        
                        #$conf["userName"],字串,執行beeline程式的使用者名稱.
                        $conf["hive::getDbList"]["userName"]="liveuser";
                        
                        }#if end
                
                #如果有設定 $conf["userPass"]
                if(isset($conf["userPass"])){
                        
                        #$conf["userPass"],字串,執行beeline程式的使用者名稱對應的密碼.
                        $conf["hive::getDbList"]["userPass"]="password";
                        
                        }#if end
                
                $getDbList=hive::getDbList($conf["hive::getDbList"]);
                unset($conf["hive::getDbList"]);
                
                #如果取得資料庫列表失敗
                if($getDbList["status"]=="false"){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置執行錯誤
                        $result["error"]=$query;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #取得資料庫列表執行的cmd
                $result["cmd"][]=$getDbList["cmd"];     
                
                #取得資料庫列表
                $result["content"]=$getDbList["content"];
                
                #設置執行正常
                $result["status"]="true";
                
                #回傳結果
                return $result;
                
                }#function createDb end
                
        /*
          
        */
        function dropDb(&$conf=array()){
                
                }#function dropDb end
        
        }#class hive end

?>