txtファイルのデータからsqliteデータの方法へ変換
sample.php
“;
//$code = array();
//$company = array();
$dbname = “data.dat";
$dbh=new PDO(“sqlite:".$dbname);
$create_sql = “CREATE TABLE kuaidi(
id INTEGER PRIMARY KEY,
code VARCHAR(20) NOT NULL,
company TEXT NOT NULL
)";
$dbh->exec($create_sql);
for($i=0;$i<$conut;$i++){
$kdinfo = explode(" ",$sp[$i]);
$code = $kdinfo[0];
$company = $kdinfo[1];
//$inserte_sql = "INSERT INTO kuaidi VALUES('','".$code."','".$company."')";
$inserte_sql = "INSERT INTO kuaidi (`code`,`company`) VALUES('".$code."','".strtoupper($company)."')";
//$inserte_sql = "INSERT INTO kuaidi VALUES('',"fdsfds","fdsfdsf")";
echo $inserte_sql."
“;
$dbh->exec($inserte_sql);
}