bcosca/fatfree — pull request #124 by ikkez (2012-10-08 06:30:38+00:00)
Title: deliver the right lastInsertID in PostgreSQL

For the PGSQL PDO driver we need to tell pdo->lastinsertid() the name of the sequence object, otherwise it returns FALSE. read more on http://php.net/manual/de/pdo.lastinsertid.php

The default seq object name syntax is "table_pkfield_seq" i.e.: "article_id_seq"
I used end($this->pkeys) to get the last key in that array, because if the current table has multiple primary keys, the order in pkeys is vice-versa the way they were defined. i.e. you'll add a pkey "version" later on, "version" will be the first element in that array. But in the most cases, the earliest pkey of a table is also the autoincremented pkey. So this end() thing is just an enhancement for multiple pk tables, and does not effect tables with a single primary key.

*cheers*