コード例 #1
0
ファイル: Jobs.php プロジェクト: huongluu/DarshanVis
 public static function execSQLQuery($query)
 {
     $connection = Yii::app()->db;
     // assuming you have configured a "db" connection
     // If not, you may explicitly create a connection:
     // $connection=new CDbConnection($dsn,$username,$password);
     // $query_str = "";
     // if ((isset($query["select"])) && strlen($query["select"]) != 0) {
     //     $query_str .= "select " . $query["select"] . " ";
     //     if ((isset($query["from"])) && strlen($query["from"]) != 0) {
     //         $query_str .= " from " . $query["from"] . " ";
     //     }
     //     if ((isset($query["where"])) && strlen($query["where"]) != 0) {
     //         $query_str .= " where " . $query["where"] . " ";
     //     }
     //     if ((isset($query["group"])) && strlen($query["group"]) != 0) {
     //         $query_str .= " group by " . $query["group"] . " ";
     //     }
     //     if ((isset($query["order"])) && strlen($query["order"]) != 0) {
     //         $query_str .= " order by " . $query["order"] . " ";
     //     }
     //     if ((isset($query["limit"])) && strlen($query["limit"]) != 0) {
     //         $query_str .= " limit " . $query["limit"] . " ";
     //     }
     // } else {
     //     $query_str = $query;
     // }
     $query_str = Jobs::query_formater($query);
     // echo "QQQ:" . $query_str . "";
     $command = $connection->createCommand($query_str);
     // if needed, the SQL statement may be updated as follows:
     // $command->text=$newSQL;
     $rows = $command->queryAll();
     return $rows;
 }