WICOM
 All Data Structures Namespaces Files Functions Variables Pages
Public Member Functions | Protected Attributes
DbConn Class Reference

Public Member Functions

 __construct ()
 
 create_database ()
 
 close ()
 
 query ($sql, $params=[])
 

Protected Attributes

 $conn = null
 
 $last_results = null
 

Last Query's Results Retrieving Functions

Functions to retrieve the last query results functions.

 res_field ($field)
 
 res_nth_row ($num)
 
 get_last_results ()
 
 field_exists ($fieldname)
 

Detailed Description

A DB connection.

We obtain DB information from the config.php file.

Constructor & Destructor Documentation

__construct ( )

Create a new DbConn instance. Create database and tables if needed.

We don't ask for parameters because it cames from globals parameters.

Yes, I know, is not the best way, but life's short!

Member Function Documentation

close ( )

Close connection.

create_database ( )

Create all tables if they don't exists. Also select the database.

field_exists (   $fieldname)
protected

This field name exists in the last results?

Returns
true if it does, false otherwise.
get_last_results ( )

Retrieve the mysqli_result instance of the last query.

Returns
a mysqli_result instance.
See also
http://php.net/manual/en/class.mysqli-result.php
query (   $sql,
  $params = [] 
)

Send a query to the DB.

Parameters
$sqla String.
Returns
A mysqli_result instance. You can use the res_field() and other res_* messages implemented in this class.
See also
http://php.net/manual/en/class.mysqli-result.php
res_field (   $field)

Retrieve all the field values.

Returns
a Array with mixed elements (depends on the query).
false if the field doesn't exists.
res_nth_row (   $num)

Retrieve the n-th row from the last results.

Parameters
numA positive integer from cero (inclusive) and the amount of rows minus one inclusive.
Returns
An associative Array where its keys are the field names and its values are the field value. False if the row number is out of boundaries.
See also
http://php.net/manual/en/mysqli-result.fetch-assoc.php

Field Documentation

$conn = null
protected

The DB connection. Needed by the mysql_connect() PHP function.

$last_results = null
protected

Last query's results.


The documentation for this class was generated from the following file: