fields::find_sql()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2015 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\content\model\mapper;
11
12
use blitze\sitemaker\model\base_mapper;
0 ignored issues
show
Bug introduced by
The type blitze\sitemaker\model\base_mapper was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
class fields extends base_mapper
15
{
16
	/** @var string */
17
	protected $entity_class = 'blitze\content\model\entity\field';
18
19
	/** @var string */
20
	protected $entity_pkey = 'field_id';
21
22
	/**
23
	 * @param array $sql_where
24
	 * @return string
25
	 */
26
	protected function find_sql(array $sql_where)
27
	{
28
		return 'SELECT * FROM ' . $this->entity_table .
29
			((sizeof($sql_where)) ? ' WHERE ' . join(' AND ', $sql_where) : '') . '
30
			ORDER BY field_order ASC';
31
	}
32
33
	/**
34
	 * @return int
35
	 */
36 3
	public function get_max_field_id()
37
	{
38 3
		$result = $this->db->sql_query('SELECT MAX(' . $this->entity_pkey . ') AS max_id FROM ' . $this->entity_table);
39 3
		$max_id = $this->db->sql_fetchfield('max_id');
40 3
		$this->db->sql_freeresult($result);
41
42 3
		return (int) $max_id;
43
	}
44
45
	/**
46
	 * @param array $fields
47
	 * @return void
48
	 */
49 3
	public function multi_insert(array $fields)
50
	{
51 3
		$this->db->sql_multi_insert($this->entity_table, array_values($fields));
52 3
	}
53
}
54