| @@ 12-30 (lines=19) @@ | ||
| 9 | { |
|
| 10 | protected $fieldList = 'migration, context, insertion_date'; |
|
| 11 | ||
| 12 | public function loadMigrationContext($migrationName) |
|
| 13 | { |
|
| 14 | $this->createTableIfNeeded(); |
|
| 15 | ||
| 16 | /** @var \eZ\Publish\Core\Persistence\Database\SelectQuery $q */ |
|
| 17 | $q = $this->dbHandler->createSelectQuery(); |
|
| 18 | $q->select($this->fieldList) |
|
| 19 | ->from($this->tableName) |
|
| 20 | ->where($q->expr->eq('migration', $q->bindValue($migrationName))); |
|
| 21 | $stmt = $q->prepare(); |
|
| 22 | $stmt->execute(); |
|
| 23 | $result = $stmt->fetch(\PDO::FETCH_ASSOC); |
|
| 24 | ||
| 25 | if (is_array($result) && !empty($result)) { |
|
| 26 | return $this->stringToContext($result['context']); |
|
| 27 | } |
|
| 28 | ||
| 29 | return null; |
|
| 30 | } |
|
| 31 | ||
| 32 | /** |
|
| 33 | * Stores a migration context |
|
| @@ 96-114 (lines=19) @@ | ||
| 93 | * @param string $migrationName |
|
| 94 | * @return APIMigration|null |
|
| 95 | */ |
|
| 96 | public function loadMigration($migrationName) |
|
| 97 | { |
|
| 98 | $this->createTableIfNeeded(); |
|
| 99 | ||
| 100 | /** @var \eZ\Publish\Core\Persistence\Database\SelectQuery $q */ |
|
| 101 | $q = $this->dbHandler->createSelectQuery(); |
|
| 102 | $q->select($this->fieldList) |
|
| 103 | ->from($this->tableName) |
|
| 104 | ->where($q->expr->eq('migration', $q->bindValue($migrationName))); |
|
| 105 | $stmt = $q->prepare(); |
|
| 106 | $stmt->execute(); |
|
| 107 | $result = $stmt->fetch(\PDO::FETCH_ASSOC); |
|
| 108 | ||
| 109 | if (is_array($result) && !empty($result)) { |
|
| 110 | return $this->arrayToMigration($result); |
|
| 111 | } |
|
| 112 | ||
| 113 | return null; |
|
| 114 | } |
|
| 115 | ||
| 116 | /** |
|
| 117 | * Creates and stores a new migration (leaving it in TODO status) |
|