Database::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
namespace Kineo\Component;
3
4
class Database extends \PDO
5
{	
0 ignored issues
show
Coding Style introduced by
The opening class brace should be on a newline by itself.
Loading history...
6
	public function __construct($emulatePrepares = false) 
7
	{
8
		parent::__construct('mysql:host=' . MYSQL_HOST . ';dbname=' . MYSQL_DATABASE . ';charset=utf8', MYSQL_USER, MYSQL_PASSWORD);
9
		
10
		$this->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
11
		$this->setAttribute(\PDO::ATTR_EMULATE_PREPARES, $emulatePrepares);
12
	}
13
	
14
	public static function bindParamArray($prefix, $values, &$bindArray)
15
	{
16
		$str = '';
17
		foreach($values as $index => $value){
18
			$str .= ':' . $prefix . $index . ',';
19
			$bindArray[$prefix . $index] = $value; 
20
		}
21
		
22
		return rtrim($str, ',');
23
	}
24
}