public function addStudentAction() { $student = new Entity\Student(); $student->setStudentId($_POST["student_id"]); $student->setName($_POST["name"]); $student->setFaculty($_POST["faculty"]); $student->setBatch($_POST["batch"]); $student->setAddress($_POST["address"]); $student->setNic($_POST["nic"]); $telArray = array(); $contact = new Entity\StudentContact(); $contact->setStudentId($_POST["student_id"]); $telNo1 = $_POST["telNo1"]; $telNo2 = $_POST["telNo2"]; //$telArray[]=$contact; if ($telNo1 != "") { $contact = new Entity\StudentContact(); $contact->setStudentId($_POST["student_id"]); $contact->setContactNo($telNo1); $telArray[] = $contact; } if ($telNo2 != "") { $contact2 = new Entity\StudentContact(); $contact2->setStudentId($_POST["student_id"]); $contact2->setContactNo($telNo2); $telArray[] = $contact2; } //$v=$telArray[1]; //echo $telArray.length; cont\StudentDBaccess::addStudent($student, $telArray); return $this->render('applicationMainBundle:Default:index.html.twig'); }
public static function addStudentContact($con, $studentId, StudentContact $contact) { try { //echo "thiss"; $sql = $con->prepare("INSERT INTO studentcontact VALUES (?,?)"); $cont = $contact->getContactNo(); //$cont="222"; //echo $cont; $sql->bind_param("ss", $studentId, $cont); if ($sql->execute() == TRUE) { return true; } else { return false; } } catch (Exception $w) { return false; } }