I have a table with a name concept-relationand I want to insert into it.
PHP code
for ($i = 0; $i < count($sources); $i++) {
$sourceID = $this->getConcpeptID($sources[$i]);
$desID = $this->getConcpeptID($distinations[$i]);
$query2 = "INSERT INTO concept-relation (relationID, firstConceptID, secondConceptID) VALUES (:rID, :sID, :dID)";
$sth = $this->db->prepare($query2);
$sth->execute(array(
':rID' => $relationID,
':sID' => $sourceID,
'dID' => $desID
));
}
I received this syntax error message
Fatal error: unhandled PDOException with the message "SQLSTATE [42000]: syntax error or access violation: 1064 There is an error in the SQL syntax; check the manual that matches your version of MySQL server for the correct syntax to use next to the -relation values (ratioID, firstConceptID, secondConceptID) ("on line 1" in C: \ xampp \ htdocs \ Mar7ba \ models \ ontology_model.php: 86 Trace stack: # 0 C: \ xampp \ htdocs \ Mar7ba \ models \ ontology_model.php ( 86): PDOStatement-> execute (Array) # 1 C: \ xampp \ htdocs \ Mar7ba \ controlers \ Ontology.php (69): Ontology_Model-> addRelation ('jklljkljk', Array, Array) # 2 C: \ xampp \ htdocs \ Mar7ba \ libs \ Bookstrap.php (42): Ontology-> ratioAdd () # 3 C: \ xampp \ htdocs \ Mar7ba \ index.php (13): Bootstrap->__ construct () # 4 {main} in C: \ xampp \ htdocs \ Mar7ba \ models \ ontology_model.php on line 86
MySQL , ,
# 1064 - SQL; , MySQL, '"-". (ratioID, firstConceptID, secondConceptID) VALU' 1
, , , MySQL
INSERT INTO concept - relation(
relationID,
firstConceptID,
secondConceptID
)
VALUES ( 3, 3, 3 )
"- " ,
, :)