I have the following records, as I need to save it in a record, I need to save all of them. The results of the data to be saved are the following:
13043:406090343,roam,56963757723,56963800030,324750007307002,0,0,0,0,1,0,0,4,2018/11/11 03:02:09,140,0,0,0,0,2018/11/11 03:02:20,,1,0,0,,WSMS,Gateway_G,0,roam,56963757723,0,,,,,,,,3,,,,,,,,,,,,,,,,,,,,,,,,,0,0,,0,730080100000015,,,,,,,56,0,,,,,,1,2,1,,,,0,0,,2018/11/11 03:02:09,,,,
13049:406090343,roam,56963757723,56963800030,324750007307002,0,0,0,0,1,0,0,4,2018/11/11 03:02:24,37,1,24,8,0,2018/11/11 03:02:26,,2,0,0,,WSMS,Gateway_G,0,roam,56963757723,0,,,,,,,,3,,,,,,,,,,,,,,,,,,,,,,,,,0,0,,7,730080100000015,,,,,,,56,0,,,,,,1,2,2,,,,0,0,,2018/11/11 03:02:09,,,,
13054:406090356,roam,56963888138,56963800030,33191346560030,0,0,0,0,1,0,0,4,2018/11/11 03:02:26,140,0,0,0,0,2018/11/11 03:02:32,,1,0,0,,WSMS,Gateway_G,0,roam,56963888138,0,,,,,,,,3,,,,,,,,,,,,,,,,,,,,,,,,,0,0,,0,730080100973190,,,,,,,56,0,,,,,,2,2,1,,,,0,0,,2018/11/11 03:02:26,,,,
What I have done is the following, but it does not save the data in the BD:
<?php
require_once("controllers/WelcomeController.php");
$sms = new WelcomeController();
$connection = ssh2_connect('dominio', 22);
ssh2_auth_password($connection, 'usuario', 'password');
$fecha_actual = date("d-m-Y");
$fecha = date("Ymd",strtotime($fecha_actual."- 1 days"));
$sftp = ssh2_sftp($connection);
$stream = fopen('ssh2.sftp://' . intval($sftp) . '/u02/data/prueba/Welcome/WELCOME_CDR_'.$fecha.'.txt', 'r');
if($stream == TRUE)
{
$a = array(readdir($stream));
for ($i=0; $i < count($a) ; $i++)
{
$aa = $a[$i];
$maximo = $sms->insertarSMS($aa);
}
fclose($stream);
}
?>
Controller
<?php
require_once($_SERVER['DOCUMENT_ROOT']."/_class/DB.class.php");
class WelcomeController extends DB
{
public function insertarSMS($aa)
{
$sql = "INSERT INTO tabla(COLUM1, COLUM2, COLUM3, COLUM4) VALUES ('".$aa."','".$aa."','".$aa."','".$aa."')";
$param = parent::upsert( $sql);
return $param;
}
}
? >
I have tried at the moment with the first 4 registers to see if it saves them in the BD, but it does not do anything.