X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=lib%2Fdb.php;h=cd9b0825331a60c40b9c9a6d23590c487ffa8cd6;hb=33eb6f2ab954597a257e9eb8f793a9bc52dd9524;hp=6c102c3855852b61e7b1a986843dc4f22e2fd2e4;hpb=a96fefe119b8c91c2f5ae6ad04e11af676e5540b;p=Project_webapp.git diff --git a/lib/db.php b/lib/db.php index 6c102c3..cd9b082 100644 --- a/lib/db.php +++ b/lib/db.php @@ -20,8 +20,7 @@ class CustomDB */ public function __construct($host, $username, $password, $dbname) { - $connection = new mysqli($host, $username, $password, $dbname); - $this->connection = $connection; + $this->connection = new mysqli($host, $username, $password, $dbname); if (!$this->connection->connect_errno) { $this->connected = true; @@ -81,6 +80,7 @@ class CustomDB /** * [prepared_query_bind_param description] + * @param [type] $types [description] * @param [type] $params [description] * @return [type] [description] */ @@ -117,9 +117,18 @@ class CustomDB public function get_result_array() { - $rt_val = $this->current_result->fetch_array(); - if (!$rt_val) { + $row = $this->current_result->fetch_array(); + if (is_null($row)) { + $rt_val = []; + } elseif (!isset($row)) { echo "Fail to build SQL query result array : (" . $this->current_stmt->errno . ") " . $this->current_stmt->error . " - " . $this->current_pquery . "
"; + $rt_val = false; + } else { + $rows[] = $row; + while ($row = $this->current_result->fetch_array()) { + $rows[] = $row; + } + $rt_val = $rows; } return $rt_val; } @@ -137,4 +146,5 @@ class CustomDB return $rt_val; } } + ?>