| Conditions | 7 |
| Paths | 32 |
| Total Lines | 24 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | public function execute(array $data = []) : ResultInterface |
||
| 21 | { |
||
| 22 | if (!is_array($data)) { |
||
| 23 | $data = array(); |
||
| 24 | } |
||
| 25 | $temp = (is_array($data) && count($data)) ? |
||
| 26 | \pg_query_params($this->driver, $this->statement, $data) : |
||
| 27 | \pg_query_params($this->driver, $this->statement, array()); |
||
| 28 | if (!$temp) { |
||
| 29 | throw new DBException('Could not execute query : '.\pg_last_error($this->driver).' <'.$this->statement.'>'); |
||
| 30 | } |
||
| 31 | $iid = null; |
||
| 32 | $aff = 0; |
||
| 33 | if (preg_match('@^\s*(INSERT|REPLACE)\s+INTO@i', $this->statement)) { |
||
| 34 | $iid = \pg_query($this->driver, 'SELECT lastval()'); |
||
| 35 | if ($iid) { |
||
| 36 | $res = \pg_fetch_row($iid); |
||
| 37 | $iid = $res[0]; |
||
| 38 | } |
||
| 39 | $aff = \pg_affected_rows($temp); |
||
| 40 | } |
||
| 41 | |||
| 42 | return new Result($temp, $iid, $aff); |
||
| 43 | } |
||
| 44 | } |