php_sqlite3 library routine called out of sequence
- From: peter stickney <peter@xxxxxxxxxxxxxxxxx>
- Date: Fri, 31 Oct 2008 07:40:39 -0700 (PDT)
I am running CentOS 5.2, with all current updates
PHP 5.1.6 -
PHP 5.1.6 (cli) (built: Jul 16 2008 19:53:00)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
And I downloaded and installed with no issue php-sqlite3-0.5
I have a sqlite3 DB that I am trying to populate with data from a
CSV. Because of data manipulation and the fact that the data from the
CSV does not go into the same database, I am using PHP to do this. My
code runs for exactly 2 queries, INSERTs the data properly and then
exits with this error:
library routine called out of sequence
Basically I read each line of CSV, determine which DB to open, open
it, form an INSERT query, run the query, close the DB.
This is run off the command line.
Any help is greatly appreciated.
Thanks.
-peter
Here's the code:
#!/usr/bin/php
<?php
ini_set('memory_limit', '512M');
dl('sqlite3.so');
error_reporting(6143);
function GetDBFile($project) {
switch($project) {
case "projectA":
return "/usr/local/db/cvstrac/projectA.db";
break;
case "projectB":
return "/usr/local/db/cvstrac/projectB.db";
break;
case "projectC":
return "/usr/local/db/cvstrac/projectC.db";
break;
}
}
function ParseDDTSDate($DDTSDate) {
// convert mm/dd/yy to unixtimestamp
$arr_date = explode("/", $DDTSDate);
$CVSTracDate = mktime(0,0,0,$arr_date[0],$arr_date[1],$arr_date[2]);
return $CVSTracDate;
}
$ddts_bugs_file = "/root/DDTS_export/defects.csv";
$ddts_handle = fopen($ddts_bugs_file, "r");
$headers_bool = FALSE;
while($data = fgetcsv($ddts_handle, 0, ",")) {
if ( !$headers_bool ) {
$headers = $data;
$headers_bool = TRUE;
}
else {
$tn = str_replace("ABCqa0", "", $data[0]);
foreach ( $data as $key=>$val ) {
$ddts_bug[$tn][$headers[$key]] = $val;
}
}
}
// for each bug, look and see what DB it belongs in, form the query,
run the query.
$x=0;
foreach ( $ddts_bug as $tn=>$bug ) {
$project = preg_split("/-/", $bug["Project"]);
$db_file = GetDBFile($project[0]);
if ( !$db = sqlite3_open($db_file)) die("cannot open file");
@$subsystem = $project[1].$project[2];
@$Contact = ($bug["Notify_submitter"]=="Y") ?
$bug["Submitter_mail"] : NULL;
$sql_ticket = "INSERT INTO ticket (tn, type, status, origtime,
changetime, derivedfrom, version, assignedto, severity, priority,
subsystem, owner, title, contact, extra1, extra2, extra3, extra4,
extra5, description, remarks)
VALUES ( {$tn},
'{$bug["Problem"]}',
'{$bug["Status"]}',
'".ParseDDTSDate($bug["Submitted_on"])."',
'".ParseDDTSDate($bug["new_on"])."',
NULL,
NULL,
'{$bug["Engineer"]}',
'{$bug["Severity"]}',
3,
'{$subsystem}',
'{$bug["Submitter_id"]}',
'{$bug["Headline"]}',
'{$Contact}',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);";
echo $sql_ticket."\n";
$query = sqlite3_query($db, $sql_ticket);
if ( !$query ) die(sqlite3_error($db));
sqlite3_query_close($query);
sqlite3_close($db);
$ticket_project[$tn]["Project"] = $project[0];
}
?>
.
- Prev by Date: Re: Does PHP do this differently?
- Next by Date: www.phpdoc.org is down
- Previous by thread: Does PHP do this differently?
- Next by thread: www.phpdoc.org is down
- Index(es):
Relevant Pages
|