Data is not saving to the database

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,

            ));

        }




I know that call is a key word in mysql, but I would have thought a framework would use call when doing its inserts. Could this be the case?

Yii validates the model but does not echo or stop the program automatically… it’s up to you to process it…

in your case you can use something like




if($call->validate())

   $call->save()

else

   ... // process $call->getErrors()