Hi,
Having some problems where my data is not getting written to the database.
It is getting past the ->save() call. But it is not throwing any errors or anything. And the data is not in the database.
Basically this is a form in which i upload the file, and I insert selected pieces of data into the database.
Code is below. I think it could be a problem to do with validation, but i would rather Yii threw and error rather than silently failing. Any ideas?
public function actionImport()
{
if($_POST)
{
if($_FILES)
{
$fileName = $_FILES['Call']['name']['cdrfile'];
$filePath = $_SERVER['DOCUMENT_ROOT']."/cdrcache/";
if(move_uploaded_file($_FILES['Call']['tmp_name']['cdrfile'], $filePath.$fileName))
{
$fp = fopen($filePath.$fileName, 'r');
$count=0;
while($cdrFileLine = fgetcsv($fp))
{
//if(!isset($cdrFileLine[13])) continue;
if( $cdrFileLine[13] == "originate") continue;
$call = new Call();
$call->call_connect = Time::NTPtoUnixtime($cdrFileLine[9]);
$call->call_disconnect = Time::NTPtoUnixtime($cdrFileLine[10]);
$call->call_origin = $cdrFileLine[13];
$call->call_callingnumber = $cdrFileLine[21];
$call->call_callednumber = $cdrFileLine[22];
$call->call_type = $cdrFileLine[88];
$call->call_typetime = strtotime($cdrFileLine[89]);
$call->call_xferto = $cdrFileLine[97];
$call->call_holdfor = $cdrFileLine[95];
$call->save();
die(print_r($cdrFileLine,1));
$count++;
}
}
}
}
$model=new Call();
$this->render('import', array(
'model'=>$model,
));
}