Код: Выделить всё
array(3) {
[0]=> string(5) "23000"
[1]=> int(1062)
[2]=> string(47) "Duplicate entry '1' for key 'UC_cdata_ont_info'"
}
и ниже показан cmd, который я запускаю: «если я просто отправлю первые 2 cmds.. show_pon0 и show_pon1, он читает из show_pon1 cmd.. данные с 2 устройств, начинающихся с 0/0xxxxxxxxx.. и они корректно обновляют их внутри таблицы mysql..
Но если я включаю show_pon2 cmd вместе, он считывает данные 3 разных устройств, как показано ниже..
Код: Выделить всё
interface epon 0/0
OLT(config-interface-epon-0/0)# show ont info 1 all
-----------------------------------------------------------------------------
F/S P ONT MAC Control Run Config Match Desc
ID flag state state state
----------------------------------------------------------------------------
0/0 1 1 AC:4E:91:A6:CF:F5 active online success match Test1-.
0/0 1 2 E0:67:B3:35:EF:76 active powerdown initial initial Test2.
-----------------------------------------------------------------------------
Total: 2, online 1
OLT(config-interface-epon-0/0)# show ont info 2 all
-----------------------------------------------------------------------------
F/S P ONT MAC Control Run Config Match Desc
ID flag state state state
----------------------------------------------------------------------------
0/0 2 1 E0:E8:E6:4E:62:58 active online success match Test3.
-----------------------------------------------------------------------------
Total: 1, online 1
OLT(config-interface-epon-0/0)#
OLT(config-interface-epon-0/0)#
Код: Выделить всё
0/0 1 1 AC:4E:91:A6:CF:F5 active online success match Test1.
0/0 1 2 E0:67:B3:35:EF:76 active powerdown initial initial Test2.
0/0 2 1 E0:E8:E6:4E:62:58 active online success match Test3.
ниже кода
Код: Выделить всё
$show_pon[0] = "interface epon 0/0";
$show_pon[1] = "show ont info 1 all";
$show_pon[2] = "show ont info 2 all";
// $show_pon[2] = "show ont info 3 all";
// $show_pon[3] = "show ont info 4 all";
// $show_pon[4] = "show ont info 5 all";
// $show_pon[5] = "show ont info 6 all";
// $show_pon[6] = "show ont info 7 all";
// $show_pon[7] = "show ont info 8 all";
// $show_pon[8] = "show ont info 9 all";
// $show_pon[9] = "show ont info 10 all";
// $show_pon[10] = "show ont info 11 all";
// $show_pon[11] = "show ont info 12 all";
// $show_pon[12] = "show ont info 13 all";
// $show_pon[13] = "show ont info 14 all";
// $show_pon[14] = "show ont info 15 all";
// $show_pon[15] = "show ont info 16 all";
$debug = true;
if ($debug) {
$cache = '/tmp/cdata_ont_info.log';
$contents = @file_get_contents($cache);
if ($contents == false)
{
$telnet->DoCommand($show_pon, $poninfo_resposta);// estatisticas resposta.. coloca no array o dump resposta
file_put_contents($cache, $poninfo_resposta);
} else
{
$poninfo_resposta = $contents;
}
} else
{
$telnet->DoCommand($show_pon, $poninfo_resposta);// estatisticas resposta.. coloca no array o dump resposta
}
$filtro_resposta = $poninfo_resposta;
preg_match_all('~^\h*(\d+/\d+)\h+(\d+)\h+(\d+)\h+([A-F\d]{2}(?::[A-F\d]{2}){5})\h+(\S+)\h+(\S+)\h+(\S+)\h+(\S+)(?:\h+(\S+))?~m',$filtro_resposta,$m);
$InputArray = array($m[0]);
foreach ($InputArray as $str)
{
$query_chunks = [];
$query_data = [];
foreach( $str as $row )
{
$query_chunks[] = "(?,?,?,?,?,?,?,?,?,$id)";
$query_data = array_merge($query_data, preg_split("/\s+/", trim($row)));
}
$query = "INSERT INTO cdata_ont_info (frame_slot, pon, ont_id, mac_address, run_state, control_flag, match_state, config_state, description, olt_id) VALUES " . implode( ', ', $query_chunks );
$pdo_dbh = new PDO('mysql:host=localhost;dbname=testdb', 'mydbtestusr', 'mydbtestpasswd');
$sth = $pdo_dbh->prepare( $query );
if (!$sth) {
var_dump($sth->errorInfo());
die('ERRO!!! Falha na query!!!!');
}
if (!$sth->execute( $query_data ))
{
var_dump($sth->errorInfo());
die('ERRO!!! Falha executando a query_data!!!!!!');
}
die(print_r($query_data, true));
}
Код: Выделить всё
Array (
[0] => 0/0
[1] => 1
[2] => 1
[3] => AC:4E:91:A6:CF:F5
[4] => active
[5] => online
[6] => success
[7] => match
[8] => VILERMINA-.
[9] => 0/0
[10] => 1
[11] => 2
[12] => E0:67:B3:35:EF:76
[13] => active
[14] => powerdown
[15] => initial
[16] => initial
[17] => Rosiley-Si.
[18] => 0/0
[19] => 2
[20] => 1
[21] => E0:E8:E6:4E:62:58
[22] => active
[23] => online
[24] => success
[25] => match
[26] => CLOVES-NAV.
)
[img]https://i.sstatic.net /YpICz.png[/img]

ОБНОВЛЕНИЕ
ниже полной ошибки вывода отладочного сообщения
Код: Выделить всё
> Warning: PDOStatement::execute(): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'UC_cdata_ont_info' in /var/www/html/isp/olt/olt_cdata.php on line 263
SQL: [213] INSERT INTO cdata_ont_info (frame_slot, pon, ont_id, mac_address, run_state, control_flag, match_state, config_state, description, olt_id) VALUES (?,?,?,?,?,?,?,?,?,4), (?,?,?,?,?,?,?,?,?,4), (?,?,?,?,?,?,?,?,?,4) Sent SQL: [416] INSERT INTO cdata_ont_info (frame_slot, pon, ont_id, mac_address, run_state, control_flag, match_state, config_state, description, olt_id) VALUES ('0/0','1','1','AC:4E:91:A6:CF:F5','active','online','success','match','VILERMINA-.',4), ('0/0','1','2','E0:67:B3:35:EF:76','active','powerdown','initial','initial','Rosiley-Si.',4), ('0/0','2','1','E0:E8:E6:4E:62:58','active','online','success','match','CLOVES-NAV.',4) Params: 27 Key: Position #0: paramno=0 name=[0] "" is_param=1 param_type=2 Key: Position #1: paramno=1 name=[0] "" is_param=1 param_type=2 Key: Position #2: paramno=2 name=[0] "" is_param=1 param_type=2 Key: Position #3: paramno=3 name=[0] "" is_param=1 param_type=2 Key: Position #4: paramno=4 name=[0] "" is_param=1 param_type=2 Key: Position #5: paramno=5 name=[0] "" is_param=1 param_type=2 Key: Position #6: paramno=6 name=[0] "" is_param=1 param_type=2 Key: Position #7: paramno=7 name=[0] "" is_param=1 param_type=2 Key: Position #8: paramno=8 name=[0] "" is_param=1 param_type=2 Key: Position #9: paramno=9 name=[0] "" is_param=1 param_type=2 Key: Position #10: paramno=10 name=[0] "" is_param=1 param_type=2 Key: Position #11: paramno=11 name=[0] "" is_param=1 param_type=2 Key: Position #12: paramno=12 name=[0] "" is_param=1 param_type=2 Key: Position #13: paramno=13 name=[0] "" is_param=1 param_type=2 Key: Position #14: paramno=14 name=[0] "" is_param=1 param_type=2 Key: Position #15: paramno=15 name=[0] "" is_param=1 param_type=2 Key: Position #16: paramno=16 name=[0] "" is_param=1 param_type=2 Key: Position #17: paramno=17 name=[0] "" is_param=1 param_type=2 Key: Position #18: paramno=18 name=[0] "" is_param=1 param_type=2 Key: Position #19: paramno=19 name=[0] "" is_param=1 param_type=2 Key: Position #20: paramno=20 name=[0] "" is_param=1 param_type=2 Key: Position #21: paramno=21 name=[0] "" is_param=1 param_type=2 Key: Position #22: paramno=22 name=[0] "" is_param=1 param_type=2 Key: Position #23: paramno=23 name=[0] "" is_param=1 param_type=2 Key: Position #24: paramno=24 name=[0] "" is_param=1 param_type=2 Key: Position #25: paramno=25 name=[0] "" is_param=1 param_type=2 Key: Position #26: paramno=26 name=[0] "" is_param=1 param_type=2 NULL ERRO!!! Falha executando a query_data!!!!!!
ниже изображения SHOW CREATE TABLE

Подробнее здесь: https://stackoverflow.com/questions/742 ... updated-de