Hi, I am beginner I want to save information into database table using phalcon. I am reading csv file and saving information into database but not able to save gettting errors.
Code:
//echo '<pre>'; print_r($_FILES); echo '</pre>';//exit;
$lines = new CsvReader($_FILES['file']['tmp_name']);
echo "<table>\n";
$csv_data = array();
foreach ($lines as $line_number => $values) {
echo '<tr>';
echo '<td>'.$line_number.'</td>';
foreach ($values as $value) {
echo '<td>'.$value."</td>";
$csv_data = $value;
echo '<br/>';
}
echo "</tr>\n";
}
echo '</table>';
$data = preg_split('/\s+/', $csv_data);
$company = new Company();
$company->company_name = $data[0];
$company->url = $data[1];
$company->visits_per_month = $data[2];
$company->alexa = $data[3];
$company->quantcast = $data[4];
$company->country = $data[5];
$company->email = $data[6];
if ($company->save() == false) {
echo "OOPS ERROR.....??????: ";
foreach ($company->getMessages() as $message) {
echo $message;
}
} else {
echo "Great!!!";
}
return $this->dispatcher->forward(array(
"controller" => "company",
"action" => "uplad_csv"
));
not working