Update database.php

This commit is contained in:
FusionPBX 2019-05-27 19:56:32 -06:00 committed by GitHub
parent 8574d95b3d
commit 641aa60469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 8 deletions

View File

@ -450,7 +450,7 @@ include "root.php";
}
// Use this function to execute complex queries
public function execute($sql, $parameters = null) {
public function execute($sql, $parameters = null, $return_type = 'all') {
//connect to the database if needed
if (!$this->db) {
@ -476,9 +476,18 @@ include "root.php";
$message["parameters"] = $parameters;
}
$this->message = $message;
//$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
//unset($prep_statement);
return $prep_statement->fetchAll(PDO::FETCH_ASSOC);
//return the results
switch($return_type) {
case 'all':
return $prep_statement->fetchAll(PDO::FETCH_ASSOC);
case 'row':
return $prep_statement->fetch(PDO::FETCH_ASSOC);
case 'column';
return $prep_statement->fetchColumn();
default:
return $prep_statement->fetchAll(PDO::FETCH_ASSOC);
}
}
catch(PDOException $e) {
$message["message"] = "Bad Request";
@ -906,7 +915,7 @@ include "root.php";
} //count
public function select($sql, $parameters = null) {
public function select($sql, $parameters = '', $return_type = 'all') {
//connect to the database if needed
if (!$this->db) {
@ -932,9 +941,18 @@ include "root.php";
$message["parameters"] = $parameters;
}
$this->message = $message;
//$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
//unset($prep_statement);
return $prep_statement->fetchAll(PDO::FETCH_ASSOC);
//return the results
switch($return_type) {
case 'all':
return $prep_statement->fetchAll(PDO::FETCH_ASSOC);
case 'row':
return $prep_statement->fetch(PDO::FETCH_ASSOC);
case 'column';
return $prep_statement->fetchColumn();
default:
return $prep_statement->fetchAll(PDO::FETCH_ASSOC);
}
}
catch(PDOException $e) {
$message["message"] = "Bad Request";