FaaPz / PDO

Just another PDO database library
MIT License
316 stars 103 forks source link

INSERT documentation update #55

Closed ghost closed 3 years ago

ghost commented 8 years ago

Please update README.md and INSERT.md documentation, the argument for INSERT execute() must be TRUE or undefined to return insert id.

This looks wrong: $insertId = $insertStatement->execute( false );

As it stands in source code, the value must be TRUE or undefined.

/**
 * @param bool $insertId
 *
 * @return string
 */
public function execute($insertId = true)
{
    if (!$insertId) {
        return parent::execute();
    }
    parent::execute();
    return $this->dbh->lastInsertId();
}
kwhat commented 3 years ago

I have updated the way this works in 2.2 so that it returns the statement which you can call ->lastInsertId() against.