mirror of
https://github.com/Oreolek/kangana.git
synced 2024-06-17 07:21:07 +03:00
Syntax fix, so queries run against database
Fixed the migration syntax so that queries would actually run.
This commit is contained in:
parent
72c016272f
commit
1d92baadfb
|
@ -22,7 +22,11 @@ class Migration_Kangana_20161016123906 extends Minion_Migration_Base {
|
||||||
$db->query(NULL, "alter table `letters` add column `is_draft` int(1) not null default '0'");
|
$db->query(NULL, "alter table `letters` add column `is_draft` int(1) not null default '0'");
|
||||||
$db->query(NULL, "alter table `courses` add column `type` int(2) not null default '0'");
|
$db->query(NULL, "alter table `courses` add column `type` int(2) not null default '0'");
|
||||||
echo "Copying Subscription model to Courses.".PHP_EOL;
|
echo "Copying Subscription model to Courses.".PHP_EOL;
|
||||||
$subscriptions = DB::select()->from('subscriptions')->as_object()->execute();
|
|
||||||
|
$subscriptions = DB::select()->from('subscriptions')->as_object()->execute($db);
|
||||||
|
|
||||||
|
if (!empty($subscriptions))
|
||||||
|
{
|
||||||
foreach ($subscriptions as $subscription)
|
foreach ($subscriptions as $subscription)
|
||||||
{
|
{
|
||||||
$query = DB::query(
|
$query = DB::query(
|
||||||
|
@ -36,7 +40,7 @@ class Migration_Kangana_20161016123906 extends Minion_Migration_Base {
|
||||||
':description' => $subscription->description,
|
':description' => $subscription->description,
|
||||||
':price' => $subscription->price
|
':price' => $subscription->price
|
||||||
));
|
));
|
||||||
$query->execute();
|
$query->execute($db);
|
||||||
echo 'Migrating subscription "'.$subscription->title.'"'.PHP_EOL;
|
echo 'Migrating subscription "'.$subscription->title.'"'.PHP_EOL;
|
||||||
|
|
||||||
$course_id = DB::select('id')
|
$course_id = DB::select('id')
|
||||||
|
@ -44,14 +48,14 @@ class Migration_Kangana_20161016123906 extends Minion_Migration_Base {
|
||||||
->where('title', '=', $subscription->title)
|
->where('title', '=', $subscription->title)
|
||||||
->and_where('description', '=', $subscription->description)
|
->and_where('description', '=', $subscription->description)
|
||||||
->and_where('type', '=', Model_Course::TYPE_IRREGULAR)
|
->and_where('type', '=', Model_Course::TYPE_IRREGULAR)
|
||||||
->execute()
|
->execute($db)
|
||||||
->get('id');
|
->get('id');
|
||||||
|
|
||||||
echo 'Migrating links between subscriptions and clients.';
|
echo 'Migrating links between subscriptions and clients.';
|
||||||
$clients = DB::select('client_id')
|
$clients = DB::select('client_id')
|
||||||
->from('clients_subscriptions')
|
->from('clients_subscriptions')
|
||||||
->where('subscription_id', '=', $subscription->id)
|
->where('subscription_id', '=', $subscription->id)
|
||||||
->execute()
|
->execute($db)
|
||||||
->as_array(NULL, 'client_id');
|
->as_array(NULL, 'client_id');
|
||||||
|
|
||||||
foreach ($clients as $client)
|
foreach ($clients as $client)
|
||||||
|
@ -64,7 +68,7 @@ class Migration_Kangana_20161016123906 extends Minion_Migration_Base {
|
||||||
$groups = DB::select('group_id')
|
$groups = DB::select('group_id')
|
||||||
->from('subscriptions_groups')
|
->from('subscriptions_groups')
|
||||||
->where('subscription_id', '=', $subscription->id)
|
->where('subscription_id', '=', $subscription->id)
|
||||||
->execute()
|
->execute($db)
|
||||||
->as_array(NULL, 'group_id');
|
->as_array(NULL, 'group_id');
|
||||||
|
|
||||||
foreach ($groups as $group)
|
foreach ($groups as $group)
|
||||||
|
@ -79,7 +83,7 @@ class Migration_Kangana_20161016123906 extends Minion_Migration_Base {
|
||||||
->from('instants')
|
->from('instants')
|
||||||
->where('subscription_id', '=', $subscription->id)
|
->where('subscription_id', '=', $subscription->id)
|
||||||
->as_object()
|
->as_object()
|
||||||
->execute();
|
->execute($db);
|
||||||
foreach ($instants as $instant)
|
foreach ($instants as $instant)
|
||||||
{
|
{
|
||||||
echo 'Migrating letter "'.$instant->subject.'"'.PHP_EOL;
|
echo 'Migrating letter "'.$instant->subject.'"'.PHP_EOL;
|
||||||
|
@ -96,13 +100,16 @@ class Migration_Kangana_20161016123906 extends Minion_Migration_Base {
|
||||||
':timestamp' => $instant->timestamp,
|
':timestamp' => $instant->timestamp,
|
||||||
':sent' => $instant->sent,
|
':sent' => $instant->sent,
|
||||||
));
|
));
|
||||||
$query->execute();
|
$query->execute($db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$db->query(NULL, "DROP TABLE instants");
|
$db->query(NULL, "DROP TABLE instants");
|
||||||
$db->query(NULL, "DROP TABLE subscriptions");
|
$db->query(NULL, "DROP TABLE subscriptions");
|
||||||
$db->query(NULL, "DROP TABLE subscriptions_groups");
|
$db->query(NULL, "DROP TABLE subscriptions_groups");
|
||||||
$db->query(NULL, "DROP TABLE clients_subscriptions");
|
$db->query(NULL, "DROP TABLE clients_subscriptions");
|
||||||
|
|
||||||
$db->commit();
|
$db->commit();
|
||||||
echo 'All done.'.PHP_EOL;
|
echo 'All done.'.PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue