Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
19 / 19 |
| MySQLUpdateStoredProcedure | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
6 | |
100.00% |
19 / 19 |
| __construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
6 / 6 |
|||
| buildElements | |
100.00% |
1 / 1 |
3 | |
100.00% |
10 / 10 |
|||
| getCreateProcedureStatement | |
100.00% |
1 / 1 |
2 | |
100.00% |
3 / 3 |
|||
| <?php | |
| declare(strict_types=1); | |
| namespace Siesta\Driver\MySQL\StoredProcedure; | |
| use Siesta\Database\StoredProcedureNaming; | |
| use Siesta\Model\DataModel; | |
| use Siesta\Model\Entity; | |
| /** | |
| * @author Gregor Müller | |
| */ | |
| class MySQLUpdateStoredProcedure extends MySQLStoredProcedureBase | |
| { | |
| /** | |
| * @var UpdateStatement | |
| */ | |
| protected $updateStatement; | |
| /** | |
| * @var InsertStatement | |
| */ | |
| protected $insertStatement; | |
| /** | |
| * MySQLUpdateStoredProcedure constructor. | |
| * | |
| * @param DataModel $dataModel | |
| * @param Entity $entity | |
| */ | |
| public function __construct(DataModel $dataModel, Entity $entity) | |
| { | |
| parent::__construct($dataModel, $entity); | |
| $this->determineTableNames(); | |
| $this->updateStatement = new UpdateStatement($entity); | |
| $this->insertStatement = new InsertStatement($entity); | |
| $this->buildElements(); | |
| } | |
| protected function buildElements() | |
| { | |
| $this->modifies = true; | |
| $this->name = StoredProcedureNaming::getUpdateName($this->entity); | |
| $this->signature = $this->updateStatement->buildSignature(); | |
| $this->statement = $this->updateStatement->buildUpdate($this->tableName); | |
| if ($this->entity->getIsDelimit()) { | |
| $this->statement .= $this->updateStatement->buildDelimitUpdate(); | |
| $this->statement .= $this->insertStatement->buildDelimitInsert(); | |
| } | |
| if ($this->isReplication) { | |
| $this->statement .= $this->updateStatement->buildUpdate($this->replicationTableName); | |
| } | |
| } | |
| /** | |
| * @return string | |
| */ | |
| public function getCreateProcedureStatement() | |
| { | |
| if (!$this->entity->hasPrimaryKey()) { | |
| return null; | |
| } | |
| return parent::getCreateProcedureStatement(); | |
| } | |
| } |