Completed
Push — master ( 3662e6...2c1d81 )
by Chris
02:54
created

Result::setInfo()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 9

Duplication

Lines 13
Ratio 100 %
Metric Value
dl 13
loc 13
rs 9.4286
cc 3
eloc 9
nc 3
nop 1
1
<?php
2
namespace Darya\Database;
3
4
use Darya\Storage\AbstractResult;
5
use Darya\Database\Error;
6
use Darya\Database\Query;
7
8
/**
9
 * Darya's database result representation.
10
 * 
11
 * @property array $data       Result data
12
 * @property Query $query      Query that produced this result
13
 * @property int   $count      Result count
14
 * @property Error $error      Result error
15
 * @property array $fields     Field names for each result data row
16
 * @property int   $insertId   Insert ID
17
 * @property int   $affected   Rows affected
18
 * 
19
 * @author Chris Andrew <[email protected]>
20
 */
21
class Result extends AbstractResult {
22
	
23
	/**
24
	 * The database query that produced this result.
25
	 * 
26
	 * @var Query
27
	 */
28
	protected $query;
29
	
30
	/**
31
	 * The error that occurred when executing the query, if any.
32
	 * 
33
	 * @var Error|null
34
	 */
35
	protected $error;
36
	
37
	/**
38
	 * Instantiate a new database result.
39
	 * 
40
	 * $info accepts the keys 'affected', 'count', 'insert_id' and 'fields'.
41
	 * 
42
	 * @param Query $query
43
	 * @param array $data  [optional]
44
	 * @param array $info  [optional]
45
	 * @param Error $error [optional]
46
	 */
47
	public function __construct(Query $query, array $data = array(), array $info = array(), Error $error = null) {
48
		$this->data  = $data;
49
		$this->error = $error;
50
		$this->query = $query;
51
		
52
		$this->setInfo($info);
53
	}
54
	
55
}
56