Ben PDO kullanımı ve ben bazı verileri eklemek edemez:
Bu kodu kullanın:
$sql = 'INSERT INTO `releases` (id, artists, release, label, catalog, date, tracklist, type, status, vote, votes_count) ';
$sql .= 'VALUES (:id, :artists, :release, :label, :catalog, :date, :tracklist, :type, :status, :vote, :votes_count)';
$query = $this->db->prepare($sql);
$query->bindParam(':id', 0, PDO::PARAM_INT);
$query->bindParam(':artists', implode('|||', $data['artists']), PDO::PARAM_STR);
$query->bindParam(':release', $data['release'], PDO::PARAM_STR);
$query->bindParam(':label', $data['label'], PDO::PARAM_STR);
$query->bindParam(':catalog', $data['catalog'], PDO::PARAM_STR);
$query->bindParam(':date', $data['date'], PDO::PARAM_STR);
$query->bindParam(':tracklist', $data['tracklist'], PDO::PARAM_STR);
$query->bindParam(':type', $data['type'], PDO::PARAM_STR);
$query->bindParam(':status', $data['status'], PDO::PARAM_INT);
$query->bindParam(':vote', 0, PDO::PARAM_INT);
$query->bindParam(':votes_count', 0, PDO::PARAM_INT);
$query->execute();
ancak veri veritabanına eklenen değilsiniz. Tüm isimler kontrol ve geçerli. Otomatik artma alanı olarak kimliği.
if i Bu kodu kullanın:
$this->db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
$sql = 'INSERT INTO releases
(artists, release, label, catalog, date, tracklist, type, status, vote, votes_count) ';
$sql .= 'VALUES (:artists, :release, :label, :catalog, :date, :tracklist, :type, :status, :vote, :votes_count)';
$query = $this->db->prepare($sql);
$array = array(':artists' => implode('|||', $data['artists']),
':release' => $data['release'],
':label' => $data['label'],
':catalog' => $data['catalog'],
':date' => $data['date'],
':tracklist' => $data['tracklist'],
':type' => $data['type'],
':status' => $data['status'],
':vote' => 0,
':votes_count' => 0);
$query->execute($array);
i receive error:
Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'release, label, catalog, date, tracklist, type, status, vote, votes_count) VALUE' at line 1 in C:\Program Files\Wamp\www\forthcoming\application\controllers\release.php on line 89