Наткнулся на проблему, которую не в получается решить.
Есть запрос в БД:
PHP:
скопировать код в буфер обмена
скопировать код в буфер обмена
- public function insert() {
- if ( !is_null( $this->id ) ) trigger_error ( "Article::insert(): Attempt to insert an Article object that already has its ID property set (to $this->id).", E_USER_ERROR );
- $conn = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD );
- $sql = "INSERT INTO articles ( publicationDate, categoryId, title, summary, content ) VALUES ( FROM_UNIXTIME(:publicationDate), :categoryId, :title, :summary, :content )";
- $st = $conn->prepare ( $sql );
- $st->bindValue( ":publicationDate", $this->publicationDate, PDO::PARAM_INT );
- $st->bindValue( ":categoryId", $this->categoryId, PDO::PARAM_INT );
- $st->bindValue( ":title", $this->title, PDO::PARAM_STR );
- $st->bindValue( ":summary", $this->summary, PDO::PARAM_STR );
- $st->bindValue( ":content", $this->content, PDO::PARAM_STR );
- $st->execute();
- $this->id = $conn->lastInsertId();
- $conn = null;
- }