Example #1
0
 /**
  * Object constructor.
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @param                 $helper     Helper for questions.
  * @param string          $spType     Stored procedure type {insert|update|delete|select}.
  * @param string          $spName     Stored procedure name.
  * @param string          $tableName  The table name.
  * @param string          $dataSchema Data schema.
  */
 public function __construct($input, $output, $helper, $spType, $spName, $tableName, $dataSchema)
 {
     $this->io = new StratumStyle($input, $output);
     $this->input = $input;
     $this->output = $output;
     $this->helper = $helper;
     $this->dataSchema = $dataSchema;
     $this->spName = $spName;
     $this->spType = $spType;
     $this->tableName = $tableName;
     $this->storedProcedureCode = new MySqlCompoundSyntaxCodeStore();
     $tableColumns = DataLayer::getTableColumns($this->dataSchema, $this->tableName);
     $params = [];
     if ($spType !== 'INSERT') {
         $params = $this->checkUniqueKeys($tableColumns, $this->spType);
     }
     if (!isset($params)) {
         $params = $tableColumns;
     }
     switch ($spType) {
         case 'INSERT':
         case 'UPDATE':
             $this->generateDocBlock($tableColumns);
             $this->generateMainPart($tableColumns);
             break;
         default:
             $this->generateDocBlock($params);
             $this->generateMainPart($params);
     }
     $this->generateBodyPart($params, $tableColumns);
 }