Knowledgebase



 Categories





 Dimofinf Mobile


Subscribe now to Dimofinf Mobile and enjoy a wide range of premium services. You will receive our SMS text messages wherever you are for a very low cost! More


 Currency Converter


  • Currency
  • US$ Amount

Dealing with databases



Dimofinf puts forward several functions that depends on MySQLi library to meet all your needs when it comes to dealing with MySQL databases where the main object which includes the database is '$dimofinf->db'. We will mention these functions and state their jobs:

  • TABLE_PREFIX

This prefix defines the beginning of the table in the database.

  • $dimofinf->db->query($sql)

This function executes a query in the database where '$sql' is the query.

Example:

PHP :
{* php buffer start *} $dimofinf->db->query("SELECT * FROM " . TABLE_PREFIX . "table"); 
{* php buffer end *}

  • $dimofinf->db->fetch_array($query)

This functions returns the query results in the form of a matrix for every row of the query results where '$query' is the query execution function line.

Example:

PHP :
{* php buffer start *} $query $dimofinf->db->query("SELECT * FROM " . TABLE_PREFIX . "table");
while(
$row = $dimofinf->db->fetch_array($query)({
// code

{* php buffer end *}

  • $dimofinf->db->query_first($sql)

This function executes queries in the database where '$sql' is the query and it returns the first line only of the results in the form of a matrix.

Example:

PHP :
{* php buffer start *} $row $dimofinf->db->query_first("SELECT * FROM " . TABLE_PREFIX . "table");
$name = $row['column']; 
{* php buffer end *}

  • $dimofinf->db->free_result($query)

This functions cleans the temporary memory of the query results and this helps relief the load off the server resources where '$query' is the query execution function line.

Example:

PHP :
{* php buffer start *} $query $dimofinf->db->query("SELECT * FROM " . TABLE_PREFIX . "table");
// code
$dimofinf->db->free_result($query); 
{* php buffer end *}

  • $dimofinf->db->insert_id()

This function is used directly after executing the 'INSERT' query to the database where the added content ID number is returned to the database.

Example:

PHP :
{* php buffer start *} $insertID $dimofinf->db->insert_id(); 
{* php buffer end *}

  • $dimofinf->db->escape_string($value)

This is one of the most important functions to be executed on inserted values to the sent queries to the database where '$value' is the inserted value. This function filters values from harmful special characters which can be used in (SQL injection) attacks.

Example:

PHP :
{* php buffer start *} $dimofinf->db->query("SELECT * FROM " . TABLE_PREFIX . "table 
WHERE column ='". 
$dimofinf->db->escape_string($dimofinf->GPC['column']) ."'"); 
{* php buffer end *}


Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article


Online