| Total Complexity | 5 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class Insert extends Query |
||
| 12 | { |
||
| 13 | /** @var mixed[] */ |
||
| 14 | protected $values; |
||
| 15 | |||
| 16 | public function __construct(Orm $orm) |
||
| 17 | { |
||
| 18 | parent::__construct($orm); |
||
| 19 | $this->values = $orm->getRowValues(); |
||
| 20 | } |
||
| 21 | |||
| 22 | /** @return string */ |
||
| 23 | public function toString() |
||
| 24 | { |
||
| 25 | $columns = array_keys($this->values); |
||
| 26 | $params = $this->getParams(); |
||
| 27 | |||
| 28 | return 'INSERT INTO ' . |
||
| 29 | $this->table . |
||
| 30 | ' (' . implode(',', $columns) . ')' . |
||
| 31 | ' VALUES (' . implode(', ', $params) . ')'; |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @return string[] |
||
| 36 | * @example return ['?','?','?'] |
||
| 37 | */ |
||
| 38 | protected function getParams() |
||
| 39 | { |
||
| 40 | return str_split(str_repeat('?', count($this->values))); |
||
| 41 | } |
||
| 42 | |||
| 43 | /** @return mixed[] */ |
||
| 44 | public function getValues() |
||
| 47 | } |
||
| 48 | |||
| 49 | /** @return bool */ |
||
| 50 | public function execute() |
||
| 53 | } |
||
| 54 | } |
||
| 55 |