示例#1
0
 public function addStatement()
 {
     $argsCount = func_num_args();
     $par = array();
     // array with parameters; will be used later for prepare/exec
     // no query as parameter given
     if ($argsCount < 1) {
         throw new Exception("No Sql-Query given");
     }
     // insert table prefix
     $query = func_get_arg(0);
     $query = str_replace(":prefix:", dbConn::getTablePrefix(), $query);
     // if there are parameters, insert in
     if ($argsCount > 1) {
         // create array with parameters for pdo usage
         for ($i = 1; $i < $argsCount; $i++) {
             $key = ":" . ($i - 1);
             $par[$key] = func_get_arg($i);
         }
     }
     try {
         // prepare statement
         $statement = $this->connection->prepare($query);
         $statement->execute($par);
     } catch (Exception $ex) {
         throw new Exception($ex->getMessage());
     }
     // return current object for reusage
     return $this;
 }