Open lbcd opened 7 years ago
I find a solution studying source code. I had connection in my 'phpmig.sets'
foreach($dbParams as $dbParam => $friendlyName) {
$parametersSet[$friendlyName] = array(
'adapter' =>
new Adapter\PDO\Sql(
new PDO(
'mysql:host=' . $ini_array[$dbParam . '.params.host'] . ';dbname=' . $ini_array[$dbParam . '.params.dbname'], $ini_array[$dbParam . '.params.username'], $ini_array[$dbParam . '.params.password'])
, 'migrations'
),
new Adapter\File\Flat(__DIR__ . DIRECTORY_SEPARATOR . 'migrations/log/' . $friendlyName . '_migrations.log'),
'migrations_path' => 'migrations/' . $friendlyName,
'connection' => new PDO('mysql:host=' . $ini_array[$dbParam . '.params.host'] . ';dbname=' . $ini_array[$dbParam . '.params.dbname'], $ini_array[$dbParam . '.params.username'], $ini_array[$dbParam . '.params.password'])
);
}
Then, I can use it in up method like this
$sql = "CREATE TABLE `test` (id INT,data VARCHAR(100));";
if (!$this->getContainer()['phpmig.connection']->query($sql)) {
die('error');
}
Hello,
Is it possible to have an exemple of
up ()
migration method when using Module Migrations ?