|
6 | 6 | use DbSync\Hash\Md5Hash;
|
7 | 7 | use DbSync\Table;
|
8 | 8 | use DbSync\Transfer\Transfer;
|
| 9 | +use DbSync\WhereClause; |
9 | 10 | use Symfony\Component\Console\Command\Command;
|
10 | 11 | use Symfony\Component\Console\Helper\QuestionHelper;
|
11 | 12 | use Symfony\Component\Console\Input\InputArgument;
|
@@ -60,7 +61,7 @@ protected function configure()
|
60 | 61 | ->addOption('target.user',null , InputOption::VALUE_REQUIRED, 'The name of the user to connect to the target host with if different to the source.')
|
61 | 62 | ->addOption('target.table',null , InputOption::VALUE_REQUIRED, 'The name of the table on the target host if different to the source.')
|
62 | 63 | ->addOption('target.password',null , InputOption::VALUE_REQUIRED, 'The password for the target host if the target user is specified. Will be solicited on the tty if not given.')
|
63 |
| - //->addOption('where', null , InputOption::VALUE_REQUIRED, 'A where clause to apply to the source table') |
| 64 | + ->addOption('where', null , InputOption::VALUE_REQUIRED, 'A where clause to apply to the tables') |
64 | 65 | ;
|
65 | 66 | }
|
66 | 67 |
|
@@ -153,9 +154,18 @@ private function fire()
|
153 | 154 |
|
154 | 155 | $sync->setLogger($logger);
|
155 | 156 |
|
| 157 | + $sourceTableObj = new Table($source, $sourceDatabase, $sourceTable); |
| 158 | + $destTableObj = new Table($target, $targetDatabase, $targetTable); |
| 159 | + |
| 160 | + if($where = $this->input->getOption('where')) |
| 161 | + { |
| 162 | + $sourceTableObj->setWhereClause(new WhereClause($where)); |
| 163 | + $destTableObj->setWhereClause(new WhereClause($where)); |
| 164 | + } |
| 165 | + |
156 | 166 | $result = $sync->sync(
|
157 |
| - new Table($source, $sourceDatabase, $sourceTable), |
158 |
| - new Table($target, $targetDatabase, $targetTable), |
| 167 | + $sourceTableObj, |
| 168 | + $destTableObj, |
159 | 169 | new ColumnConfiguration($this->input->getOption('columns'), $this->input->getOption('ignore-columns'))
|
160 | 170 | );
|
161 | 171 |
|
|
0 commit comments