| @@ 104-124 (lines=21) @@ | ||
| 101 | * |
|
| 102 | * @return string[][] |
|
| 103 | */ |
|
| 104 | public function loadSectionData($id) |
|
| 105 | { |
|
| 106 | $query = $this->dbHandler->createSelectQuery(); |
|
| 107 | $query->select( |
|
| 108 | $this->dbHandler->quoteColumn('id'), |
|
| 109 | $this->dbHandler->quoteColumn('identifier'), |
|
| 110 | $this->dbHandler->quoteColumn('name') |
|
| 111 | )->from( |
|
| 112 | $this->dbHandler->quoteTable('ezsection') |
|
| 113 | )->where( |
|
| 114 | $query->expr->eq( |
|
| 115 | $this->dbHandler->quoteColumn('id'), |
|
| 116 | $query->bindValue($id, null, \PDO::PARAM_INT) |
|
| 117 | ) |
|
| 118 | ); |
|
| 119 | ||
| 120 | $statement = $query->prepare(); |
|
| 121 | $statement->execute(); |
|
| 122 | ||
| 123 | return $statement->fetchAll(\PDO::FETCH_ASSOC); |
|
| 124 | } |
|
| 125 | ||
| 126 | /** |
|
| 127 | * Loads data for all sections. |
|
| @@ 155-175 (lines=21) @@ | ||
| 152 | * |
|
| 153 | * @return string[][] |
|
| 154 | */ |
|
| 155 | public function loadSectionDataByIdentifier($identifier) |
|
| 156 | { |
|
| 157 | $query = $this->dbHandler->createSelectQuery(); |
|
| 158 | $query->select( |
|
| 159 | $this->dbHandler->quoteColumn('id'), |
|
| 160 | $this->dbHandler->quoteColumn('identifier'), |
|
| 161 | $this->dbHandler->quoteColumn('name') |
|
| 162 | )->from( |
|
| 163 | $this->dbHandler->quoteTable('ezsection') |
|
| 164 | )->where( |
|
| 165 | $query->expr->eq( |
|
| 166 | $this->dbHandler->quoteColumn('identifier'), |
|
| 167 | $query->bindValue($identifier, null, \PDO::PARAM_STR) |
|
| 168 | ) |
|
| 169 | ); |
|
| 170 | ||
| 171 | $statement = $query->prepare(); |
|
| 172 | $statement->execute(); |
|
| 173 | ||
| 174 | return $statement->fetchAll(\PDO::FETCH_ASSOC); |
|
| 175 | } |
|
| 176 | ||
| 177 | /** |
|
| 178 | * Counts the number of content objects assigned to section with $id. |
|
| @@ 661-689 (lines=29) @@ | ||
| 658 | * |
|
| 659 | * @return mixed |
|
| 660 | */ |
|
| 661 | public function getNextId() |
|
| 662 | { |
|
| 663 | $sequence = $this->dbHandler->getSequenceName('ezurlalias_ml_incr', 'id'); |
|
| 664 | /** @var $query \eZ\Publish\Core\Persistence\Database\InsertQuery */ |
|
| 665 | $query = $this->dbHandler->createInsertQuery(); |
|
| 666 | $query->insertInto( |
|
| 667 | $this->dbHandler->quoteTable('ezurlalias_ml_incr') |
|
| 668 | ); |
|
| 669 | // ezcDatabase does not abstract the "auto increment id" |
|
| 670 | // INSERT INTO ezurlalias_ml_incr VALUES(DEFAULT) is not an option due |
|
| 671 | // to this mysql bug: http://bugs.mysql.com/bug.php?id=42270 |
|
| 672 | // as a result we are forced to check which database is currently used |
|
| 673 | // to generate the correct SQL query |
|
| 674 | // see https://jira.ez.no/browse/EZP-20652 |
|
| 675 | if ($this->dbHandler->useSequences()) { |
|
| 676 | $query->set( |
|
| 677 | $this->dbHandler->quoteColumn('id'), |
|
| 678 | "nextval('{$sequence}')" |
|
| 679 | ); |
|
| 680 | } else { |
|
| 681 | $query->set( |
|
| 682 | $this->dbHandler->quoteColumn('id'), |
|
| 683 | $query->bindValue(null, null, \PDO::PARAM_NULL) |
|
| 684 | ); |
|
| 685 | } |
|
| 686 | $query->prepare()->execute(); |
|
| 687 | ||
| 688 | return $this->dbHandler->lastInsertId($sequence); |
|
| 689 | } |
|
| 690 | ||
| 691 | /** |
|
| 692 | * Loads single row data matched by composite primary key. |
|