Created
January 29, 2020 00:10
-
-
Save mkeneqa/aec9a2805b67f6022fcb7758a6715ff2 to your computer and use it in GitHub Desktop.
place in `app/src/Commmand/console_app.php` . Run App with this command: `php bin\console app:add-cols`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// place in app/src/Commmand/console_app.php | |
namespace App\Command; | |
use RedBeanPHP\RedException\SQL; | |
use Symfony\Component\Console\Command\Command; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Output\OutputInterface; | |
use App\Helper\Database; | |
use RedBeanPHP\R as R; | |
class AddColDataCommand extends command | |
{ | |
private $_HeadCalCols = array('el 01','el 02','el 03','el 04'); | |
// the name of the command (the part after "bin/console") | |
protected static $defaultName = 'app:add-cols'; | |
// protected configure() | |
// { | |
// | |
// } | |
private function InsertHeadCalColoumns(OutputInterface $output) | |
{ | |
Database::InitConn(); | |
foreach ($this->_HeadCalCols as $col) | |
{ | |
$record = R::xdispense('sv_headcal_col_def'); | |
$record->short_name = $col; | |
$record->field_name = $col; | |
$record->loader = 'HeadCal'; | |
$record->database = 'SV_Head_Calibration'; | |
$record->db_table = 'head_cal'; | |
$record->json_element = 'cal_matrix_json'; | |
try { | |
$id = R::store($record); | |
$output->writeln('Inserted Record @ ' . $id); | |
} catch (SQL $e) { | |
} | |
//break; | |
} | |
Database::Disconnect(); | |
} | |
protected function execute(InputInterface $input, OutputInterface $output) | |
{ | |
//parent::execute($input, $output); // TODO: Change the autogenerated stub | |
// outputs multiple lines to the console (adding "\n" at the end of each line) | |
$output->writeln([ | |
'Adding Coloumns', | |
'============', | |
'', | |
]); | |
$this->InsertHeadCalColoumns($output); | |
$output->writeln('Cols Insert Complete!'); | |
$output->writeln('BYE!'); | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
place in:
app/src/Commmand/console_app.php
.Run App with this command:
php bin\console app:add-cols