Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
15 / 15 |
| MySQLCopyToReplicationStoredProcedure | |
100.00% |
1 / 1 |
|
100.00% |
4 / 4 |
5 | |
100.00% |
15 / 15 |
| __construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
3 / 3 |
|||
| buildElements | |
100.00% |
1 / 1 |
1 | |
100.00% |
6 / 6 |
|||
| getCreateProcedureStatement | |
100.00% |
1 / 1 |
2 | |
100.00% |
3 / 3 |
|||
| buildStatement | |
100.00% |
1 / 1 |
1 | |
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; | |
| class MySQLCopyToReplicationStoredProcedure extends MySQLStoredProcedureBase | |
| { | |
| const DELETE_FROM_MEMORY_TABLE = "DELETE FROM %s;"; | |
| const INSERT_INTO_MEMORY_TABLE = "INSERT INTO %s SELECT * FROM %s;"; | |
| /** | |
| * MySQLDeleteStoredProcedure constructor. | |
| * | |
| * @param DataModel $dataModel | |
| * @param Entity $entity | |
| */ | |
| public function __construct(DataModel $dataModel, Entity $entity) | |
| { | |
| parent::__construct($dataModel, $entity); | |
| $this->buildElements(); | |
| } | |
| /** | |
| * | |
| */ | |
| protected function buildElements() | |
| { | |
| $this->modifies = true; | |
| $this->name = StoredProcedureNaming::getCopyToMemoryTable($this->entity); | |
| $this->determineTableNames(); | |
| $this->signature = "()"; | |
| $this->buildStatement(); | |
| } | |
| /** | |
| * @return string | |
| */ | |
| public function getCreateProcedureStatement() | |
| { | |
| if (!$this->isReplication) { | |
| return null; | |
| } | |
| return parent::getCreateProcedureStatement(); | |
| } | |
| /** | |
| * | |
| */ | |
| protected function buildStatement() | |
| { | |
| $this->statement = sprintf(self::DELETE_FROM_MEMORY_TABLE, $this->replicationTableName); | |
| $this->statement .= sprintf(self::INSERT_INTO_MEMORY_TABLE, $this->replicationTableName, $this->tableName); | |
| } | |
| } |