Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

InsertDoctrineQuery.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\Persistence\Doctrine;
8
9 use eZ\Publish\Core\Persistence\Database\InsertQuery;
10 use eZ\Publish\Core\Persistence\Database\QueryException;
11
18 class InsertDoctrineQuery extends AbstractDoctrineQuery implements InsertQuery
19 {
21 private $table;
22
24 private $values = [];
25
35 public function insertInto($table)
36 {
37 $this->table = $table;
38
39 return $this;
40 }
41
52 public function set($column, $expression)
53 {
54 $this->values[$column] = $expression;
55
56 return $this;
57 }
58
62 public function getQuery()
63 {
64 if (strlen($this->table) === 0) {
65 throw new QueryException('Missing table name');
66 }
67
68 if (count($this->values) === 0) {
69 throw new QueryException('Missing values');
70 }
71
72 return 'INSERT INTO ' . $this->table
73 . ' (' . implode(', ', array_keys($this->values)) . ')'
74 . ' VALUES (' . implode(', ', $this->values) . ')';
75 }
76 }
eZ\Publish\Core\Persistence\Database\QueryException
Class QueryException.
Definition: QueryException.php:18
eZ\Publish\Core\Persistence\Doctrine\AbstractDoctrineQuery
Class AbstractDoctrineQuery.
Definition: AbstractDoctrineQuery.php:21
eZ\Publish\Core\Persistence\Doctrine\InsertDoctrineQuery
Class InsertDoctrineQuery.
Definition: InsertDoctrineQuery.php:19
eZ\Publish\Core\Persistence\Doctrine\InsertDoctrineQuery\insertInto
insertInto($table)
Opens the query and sets the target table to $table.
Definition: InsertDoctrineQuery.php:35
eZ\Publish\Core\Persistence\Doctrine\InsertDoctrineQuery\$values
$values
Definition: InsertDoctrineQuery.php:24
eZ\Publish\Core\Persistence\Doctrine\InsertDoctrineQuery\$table
$table
Definition: InsertDoctrineQuery.php:21
eZ\Publish\Core\Persistence\Doctrine\InsertDoctrineQuery\getQuery
getQuery()
Definition: InsertDoctrineQuery.php:62
eZ\Publish\Core\Persistence\Database\InsertQuery
Definition: InsertQuery.php:16
eZ\Publish\Core\Persistence\Doctrine
Definition: AbstractDoctrineQuery.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.