> For the complete documentation index, see [llms.txt](https://playground.e107sk.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://playground.e107sk.com/e107-efiction-integration-update/e107-integration-ii./database.md).

# Database ✅

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

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.&#x20;

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();
}
```
