Passed
Push — master ( c1fd3c...a83360 )
by Joe
02:50
created

Db::queryOne()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 3
dl 0
loc 7
ccs 6
cts 6
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
* MDB2 Wrapper Made To Handle Like Our Other Classes Related Functionality
4
* @author Joe Huss <[email protected]>
5
* @copyright 2018
6
* @package MyAdmin
7
* @category SQL
8
*/
9
10
namespace MyDb\Mdb2;
11
12
use \MyDb\Generic;
13
use \MyDb\Mysqli\Db as MysqliDb;
14
use \MyDb\Db_Interface;
15
16
/**
17
 * Db
18
 *
19
 * @access public
20
 */
21
class Db extends MysqliDb implements Db_Interface {
22
	public $host = 'localhost';
23
	public $user = 'pdns';
24
	public $password = '';
25
	public $database = 'pdns';
26
	public $type = 'mdb2';
27
	public $error = false;
28
	public $message = '';
29
30
	/**
31
	 * Db::quote()
32
	 * @param string $text
33
	 * @param string $type
34
	 * @return string
35
	 */
36 1
	public function quote($text = '', $type = 'text') {
37
		switch ($type) {
38 1
			case 'text':
39 1
				return "'".$this->escape($text)."'";
40
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
41 1
			case 'integer':
42 1
				return (int) $text;
43
				break;
44
			default:
45 1
				return $text;
46
				break;
47
		}
48
	}
49
50
	/**
51
	 * Db::queryOne()
52
	 *
53
	 * @param mixed $query
54
	 * @param string $line
55
	 * @param string $file
56
	 * @return bool
57
	 */
58 1
	public function queryOne($query, $line = '', $file = '') {
59 1
		$this->query($query, $line, $file);
60 1
		if ($this->num_rows() > 0) {
61 1
			$this->next_record();
62 1
			return $this->f(0);
63
		} else
64 1
			return 0;
65
	}
66
67
	/**
68
	 * Db::queryRow()
69
	 *
70
	 * @param mixed $query
71
	 * @param string $line
72
	 * @param string $file
73
	 * @return array|bool
74
	 */
75 1
	public function queryRow($query, $line = '', $file = '') {
76 1
		$this->query($query, $line, $file);
77 1
		if ($this->num_rows() > 0) {
78 1
			$this->next_record();
79 1
			return $this->Record;
80
		} else
81 1
			return 0;
82
	}
83
84
	/**
85
	 * Db::lastInsertId()
86
	 * @param mixed $table
87
	 * @param mixed $field
88
	 * @return int
89
	 */
90 1
	public function lastInsertId($table, $field) {
91 1
		return $this->getLastInsertId($table, $field);
92
	}
93
}
94