function upload() { if (empty($_FILES)) { return; } if (strlen(trim($_FILES['report']['tmp_name'])) == 0) { alert("Nom de fichier est vide"); return; } $file_report = tempnam('tmp', 'file_report'); if (move_uploaded_file($_FILES['report']['tmp_name'], $file_report)) { // File is uploaded now we can try to parse it $file = fopen($file_report, 'r'); $data = fgetcsv($file); if (empty($data)) { return; } $this->name = $data[0]; $array = array(); while ($data = fgetcsv($file)) { $obj = new Acc_Report_Row(); $obj->set_parameter("name", $data[0]); $obj->set_parameter("id", 0); $obj->set_parameter("position", $data[1]); $obj->set_parameter("formula", $data[2]); $obj->set_parameter('database', $this->db); $obj->set_parameter('form_id', 0); $array[] = clone $obj; } $this->aAcc_Report_row = $array; $this->insert(); } }
static function test_me() { $cn = new Database(dossier::id()); $a = new Acc_Report_Row(); $array = array("text0" => "test1", "form0" => "7%", "text1" => "test2", "form1" => "6%"); $a->db = $cn; $b = $a->from_array($array); print_r($b); echo $a->get_info(); }