Completed
Push — mysql_improvements ( 2e95ce...dedbef )
by Michael
03:52
created

MysqlDriver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 39
ccs 0
cts 8
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A yieldAssocList() 0 19 3
1
<?php
2
/**
3
 * Joomla! Statistics Server
4
 *
5
 * @copyright  Copyright (C) 2013 - 2017 Open Source Matters, Inc. All rights reserved.
6
 * @license    http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
7
 */
8
9
namespace Joomla\StatsServer\Database\Mysql;
10
11
use Joomla\Database\Mysql\MysqlDriver as BaseMysqlDriver;
12
13
/**
14
 * Extended MySQL driver
15
 */
16
class MysqlDriver extends BaseMysqlDriver
17
{
18
	/**
19
	 * Method to get an array of the result set rows from the database query as a Generator where each row is an associative array
20
	 * of ['field_name' => 'row_value'].  The array of rows can optionally be keyed by a field name, but defaults to
21
	 * a sequential numeric array.
22
	 *
23
	 * NOTE: Chosing to key the result array by a non-unique field name can result in unwanted
24
	 * behavior and should be avoided.
25
	 *
26
	 * @param   string  $key     The name of a field on which to key the result array.
27
	 * @param   string  $column  An optional column name. Instead of the whole row, only this column value will be in
28
	 *                           the result array.
29
	 *
30
	 * @return  \Generator|null  A Generator with the result set or null if the query failed.
31
	 *
32
	 * @since   1.0
33
	 * @throws  \RuntimeException
34
	 */
35
	public function yieldAssocList($key = null, $column = null)
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $column is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
	{
37
		$this->connect();
38
39
		// Execute the query and get the result set cursor.
40
		if (!($cursor = $this->execute()))
41
		{
42
			return null;
43
		}
44
45
		// Get all of the rows from the result set.
46
		while ($row = $this->fetchAssoc($cursor))
47
		{
48
			yield $row;
49
		}
50
51
		// Free up system resources and return.
52
		$this->freeResult($cursor);
53
	}
54
}
55