private $current_result;
/**
- * [__construct description]
- * @param [type] $host [description]
- * @param [type] $username [description]
- * @param [type] $password [description]
- * @param [type] $dbname [description]
+ * __construct class constructor method that permit to initialize
+ * the connection to the RDBMS database
+ * @param string $host RDBMS hostname
+ * @param string $username RDBMS user
+ * @param string $password RDBMS user password
+ * @param string $dbname RDBMS database to use
+ * @return object an object which represents the connection to a RDBMS Server.
*/
public function __construct($host, $username, $password, $dbname)
{
return $this->connection;
}
+ /**
+ * [__destruct description]
+ */
/* public function __destruct()
{
$this->close();
} */
/**
- * [close description]
- * @return [type] [description]
+ * close method to close the opened connection to the RDBMS server
+ * @return void
*/
public function close()
{
}
/**
- * [query description]
- * @param [type] $sql_query [description]
- * @return [type] [description]
+ * query method that permit to execute a SQL query
+ * @param string $sql_query the SQL query to execute
+ * @return object mysqli_result or FALSE on failure and TRUE for queries
+ * without results
*/
public function query($sql_query)
{
}
/**
- * [prepare_query description]
- * @param [type] $prepared_query [description]
- * @return [type] [description]
+ * prepare_query method for parametrized SQL query preparation
+ * @param string $prepared_query parametrized SQL query to prepare
+ * @return object statement object or FALSE if an error occurred
*/
public function prepare_query($prepared_query)
{
}
/**
- * [prepared_query_bind_param description]
- * @param [type] $params [description]
- * @return [type] [description]
+ * prepared_query_bind_param link parameters values to a prepared SQL query
+ * @param string $types parameters types
+ * @param array $params unidimensional array of parameters values
+ * @return boolean TRUE on success or FALSE on failure
*/
public function prepared_query_bind_param($types, $params)
{
}
/**
- * [run_prepared_query description]
- * @return [type] [description]
+ * run_prepared_query method that execute a parametrized SQL query linked
+ * with its parameters values
+ * @return boolean TRUE on success or FALSE on failure
*/
public function run_prepared_query()
{
return $rt_val;
}
+ /**
+ * get_pquery_result method to get the resultset of parametrized SQL query
+ * @return object mysqli_result resultset or FALSE for other DML queries or on failure
+ */
public function get_pquery_result()
{
$rt_val = $this->current_result = $this->current_stmt->get_result();
return $rt_val;
}
+ /**
+ * [get_result_array description]
+ * @return [type] [description]
+ */
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 . "<br>";
+ $rt_val = false;
+ } else {
+ $rows[] = $row;
+ while ($row = $this->current_result->fetch_array()) {
+ $rows[] = $row;
+ }
+ $rt_val = $rows;
}
return $rt_val;
}
return $rt_val;
}
}
+
?>