54 lines
2.1 KiB
PHP
54 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\CLI\DBMigration;
|
|
|
|
use CodeIgniter\Database\BaseConnection;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class SourceDB extends DBMigration
|
|
{
|
|
private $_sourceDB = null;
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
}
|
|
final protected function getSourceDB(): BaseConnection
|
|
{
|
|
if ($this->_sourceDB === null) {
|
|
$primeidc = [
|
|
'DSN' => '',
|
|
'hostname' => env('database.source.hostname', 'localhost'),
|
|
'username' => env('database.source.username', 'root'),
|
|
'password' => env('database.source.password', ''),
|
|
'database' => env('database.source.database', 'primeidc'),
|
|
'DBDriver' => 'MySQLi',
|
|
'DBPrefix' => '',
|
|
'pConnect' => false,
|
|
'DBDebug' => (ENVIRONMENT !== 'production'),
|
|
'cacheOn' => false,
|
|
'cacheDir' => '',
|
|
'charset' => 'utf8mb4',
|
|
'DBCollat' => 'utf8mb4_general_ci',
|
|
'swapPre' => '',
|
|
'encrypt' => false,
|
|
'compress' => false,
|
|
'strictOn' => false,
|
|
'failover' => [],
|
|
'port' => 3306,
|
|
];
|
|
$this->_sourceDB = \Config\Database::connect($primeidc);
|
|
}
|
|
return $this->_sourceDB;
|
|
}
|
|
protected function getClient(): array
|
|
{
|
|
return $this->getSourceDB()->query('SELECT * FROM clientdb')->getResultArray();
|
|
}
|
|
protected function getLine(): array
|
|
{
|
|
return $this->getSourceDB()->query('select Line_code,line_case,Line_ip,line_client_name,line_gateway,line_id,line_pass,line_name,line_haveip,line_phone,line_mainip from linedb;select Line_code,line_case,Line_ip,line_client_name,line_gateway,line_id,line_pass,line_name,line_haveip,line_phone,line_mainip from linedb')->getResultArray();
|
|
}
|
|
}
|