Completed
Push — develop ( d28428...d28428 )
by Simon
02:20
created

Replace   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
c 2
b 0
f 1
lcom 0
cbo 2
dl 0
loc 21
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A ignore() 0 3 1
A execute() 0 3 1
A compile() 0 9 1
1
<?php
2
/*
3
 * This file is part of Yolk - Gamer Network's PHP Framework.
4
 *
5
 * Copyright (c) 2015 Gamer Network Ltd.
6
 *
7
 * Distributed under the MIT License, a copy of which is available in the
8
 * LICENSE file that was bundled with this package, or online at:
9
 * https://github.com/gamernetwork/yolk-database
10
 */
11
12
namespace yolk\database\query;
13
14
use yolk\database\exceptions\QueryException;
15
16
/**
17
 * Generic replace query.
18
 */
19
class Replace extends Insert {
20
21
	public function ignore( $ignore = true ) {
22
		throw new QueryException('IGNORE flag not valid for REPLACE queries.');
23
	}
24
25
	public function execute( $return_insert_id = false ) {
26
		return parent::execute(false);
27
	}
28
29
	protected function compile() {
30
31
		$sql = parent::compile();
32
		
33
		$sql[0] = preg_replace('/^INSERT( IGNORE)?/', 'REPLACE', $sql[0]);
34
		
35
		return $sql;
36
37
	}
38
39
}
40
41
// EOF