Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
$config['default_controller'] = 'main'; // Default controller to load
$config['error_controller'] = 'error'; // Controller used for errors (e.g. 404, 500 etc)

$config['charset'] = 'utf8';

$config['db_host'] = ''; // Database host (e.g. localhost)
$config['db_name'] = ''; // Database name
$config['db_username'] = ''; // Database username
Expand Down
27 changes: 13 additions & 14 deletions system/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ class Model {
public function __construct()
{
global $config;

$this->connection = mysql_pconnect($config['db_host'], $config['db_username'], $config['db_password']) or die('MySQL Error: '. mysql_error());
mysql_select_db($config['db_name'], $this->connection);
$this->connection = mysqli_connect($config['db_host'], $config['db_username'], $config['db_password']) or die('MySQL Error: '. mysql_error());
mysqli_set_charset($this->connection, $config['charset']);
mysqli_select_db($this->connection, $config['db_name']);
}

public function escapeString($string)
{
return mysql_real_escape_string($string);
return mysqli_real_escape_string($this->connection, $string);
}

public function escapeArray($array)
{
array_walk_recursive($array, create_function('&$v', '$v = mysql_real_escape_string($v);'));
array_walk_recursive($array, create_function('&$v', '$v = mysqli_real_escape_string($this->connection, $v);'));
return $array;
}

Expand All @@ -43,21 +43,20 @@ public function to_datetime($val)
return date('Y-m-d H:i:s', $val);
}

public function execute($qry)
{
return mysqli_query($this->connection, $qry) or die('MySQL Error: '. mysqli_error($this->connection));
}

public function query($qry)
{
$result = mysql_query($qry) or die('MySQL Error: '. mysql_error());
$result = mysqli_query($this->connection, $qry) or die('MySQL Error: '. mysqli_error($this->connection));
$resultObjects = array();

while($row = mysql_fetch_object($result)) $resultObjects[] = $row;
while($row = mysqli_fetch_object($result)) $resultObjects[] = $row;

return $resultObjects;
}

public function execute($qry)
{
$exec = mysql_query($qry) or die('MySQL Error: '. mysql_error());
return $exec;
}

}
?>