PHP code example of mattmilesi / pt-osc-command-generator
1. Go to this page and download the library: Download mattmilesi/pt-osc-command-generator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mattmilesi / pt-osc-command-generator example snippets
$query = "ALTER TABLE customers ADD COLUMN middle_name VARCHAR(255) NOT NULL AFTER first_name;";
$parser = new \PtOscCommandGenerator\StatementParser($query);
$command = $parser->getCommands()[0]
->setDsnOption(\PtOscCommandGenerator\DsnOption::HOST, '<host>')
->setDsnOption(\PtOscCommandGenerator\DsnOption::DATABASE, '<database>')
->setDsnOption(\PtOscCommandGenerator\DsnOption::USER, '<user>')
->setDsnOption(\PtOscCommandGenerator\DsnOption::PASSWORD, '<password>')
->setExecuteMode();
$cliCommand = (string)$command;
# getCommands returns an array of Command, each one representing a command to be executed
# $cliCommand: pt-online-schema-change --execute --alter "ADD COLUMN middle_name VARCHAR(255) NOT NULL AFTER first_name" h=<host>,D=<database>,t=customers,u=<user>,p=<password>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.