Database ✅

It is too hard to rewrite all db functions, but we want to rid the efiction config file.

This:

require_once(_BASEDIR."includes/dbfunctions.php");
if(!empty($sitekey)) $dbconnect = dbconnect($dbhost, $dbuser,$dbpass, $dbname);
  • deleted mysql option (e107 uses PDO, if available)

  • replaced db functions with e107 alternatives.

in e_module.php replaced

@ include_once(_BASEDIR."config.php");

with:

$sitekey = defset(SITEKEY, "settings"); 
require_once(_BASEDIR."includes/dbfunctions.php");

and content of this file replaced with used db functions (from mysqli_functions.php file):

<?php
 
function dbquery($query) {
	 
}

function dbnumrows($query) {
 
}

function dbassoc($query) {
 
}

function dbinsertid($tablename = 0) {
 
}

function dbrow($query) {
 
}

function dbclose() {
 
}

// Used to escape text being put into the database.
function escapestring($str) {
 
}
 

Attempt to replace them with e107 db methods:

Clear replacement:

function dbquery($query) {
	return e107::getDb()->gen($query); 
}
function dbclose() {
 /* it is done by db handler automatically, just not have this fails */
 e107::getDb()->close();
}
function dbnumrows($query) {
 return e107::getDb()->rowCount($query);
}
function dbassoc($sql) {
  return e107::getDb()->fetch("assoc");
}
function dbrow($sql) {
  return e107::getDb()->fetch('num') ; 
}
// Used to escape text being put into the database.
function escapestring($str) {
   if (!is_array($str)) return e107::getDb()->escape($str);
   return array_map('escapestring', $str);
}
function dbinsertid($tablename = 0) {
 return e107::getDb()->lastInsertId();
}

Last updated