explode
은 my_sql
및 PDO
과 아무 관련이 없습니다. 나는 어리석은 의심을 품고 누군가가 나에게 이것을 설명 할 수 있는지 궁금해한다.정의되지 않은 색인 오류
<?php
include_once ("db_connection.php");
$xml=simplexml_load_file('info.xml');
foreach($xml->testcase as $var)
{
$var=explode('/',$var->script);
print_r($var);
$module[] =$var[2];
$testName[] = end($var);
}
$modules = array_unique($module);
foreach($modules as $newarr)
{
$newmodules[]=$newarr;
}
?>
에 - 나는 코드를 사용하고이를 분석하려면 지금
scripts/testSuite/UTA/CLI/CommonCli/commonSflow.tcl
scripts/testSuite/UTA/CLI/CommonCli/commonRoutePolicyDisplay.tcl
scripts/testSuite/networkSecurity/802dot1x/802dot1xBasicFunctionality/802dot1xSuppliSuccessAuth.tcl
scripts/testSuite/hostAgentFeatures/debugLogging/debugLoggingFeatureTesting/DebugLogging_F_SshErrorMsg.tcl
scripts/testSuite/sdnSTC/Flare/Backup_Restore/Sprint16_tests/Backup_Restore_RestoreModeOFFRestore.tcl
-
나는 내가 좋아하는 데이터가 특정 태그 (스크립트)에 대한 구문 분석하고 XML 파일이 다른 손으로 나는 XML과 같은 데이터가 포함 된 열 namde 스크립트가 데이터베이스가 있습니다. 이를 위해 나는 코드를 사용하고 - output - 두 경우 모두
<?php
include_once ("db_connection.php");
$conn = testdb_connect();
$testType = 'TCL';
$sth = $conn->prepare('SELECT script FROM testcases2 WHERE testcases2.testType = :testType');
$sth->execute(array(':testType' => $testType));
while($row = $sth->fetch(PDO::FETCH_ASSOC))
{
foreach($row as $key)
{
$var=explode('/', $key);
print_r($var);
$module[] =$var[2];
}
}
$modules = array_unique($module);
foreach($modules as $newarr)
{
$newmodules[]=$newarr;
}
?>
을 print_r($var);
의 출력은 같은 인 동일합니다.
문제점은 my_sql 코드를 실행할 때 오류가 발생하지 않지만 PDO를 사용하면 문제가 발생합니다. undefined index 2 error
.
PDO 코드의 문제점은 무엇입니까? 안내하십시오.
시도의 $ 모듈을 확인하려고 빈 [] = (빈 ($ var에 [2]) $ var에 [2]!? ''); 인덱스 2는 비어 있습니다. –
'$ 모듈 [] = $ var [2];'이'$ var [2] '는 존재하지 않습니다. $ var 안에 무엇이 있는지 확인하십시오. –
print_r ($ var); 출력은 [var] (http://pastebin.com/VVCKfCBa)와 같습니다. – Newbie