… | |
… | |
186 | die "duplicate key" |
186 | die "duplicate key" |
187 | if sql_exists "user where name = ? and pass = ?", "stefan", "geheim"; |
187 | if sql_exists "user where name = ? and pass = ?", "stefan", "geheim"; |
188 | |
188 | |
189 | =cut |
189 | =cut |
190 | |
190 | |
191 | # uncodumented, since unportable (only works with DBH even!). yet it is exported (aaargh!) |
191 | =item $lastid = sql_insertid $sth |
|
|
192 | |
|
|
193 | Returns the last automatically created key value (e.g. for mysql |
|
|
194 | AUTO_INCREMENT or sybase IDENTITY fields). It must be executed directly |
|
|
195 | after executing the insert statement that created it. |
|
|
196 | |
|
|
197 | =cut |
|
|
198 | |
192 | sub sql_insertid { |
199 | sub sql_insertid($) { |
193 | $DBH->{mysql_insertid}; |
200 | my $sth = shift or die "sql_insertid requires a statement handle"; |
|
|
201 | my $dbh = $sth->{Database}; |
|
|
202 | my $driver = $dbh->{Driver}{Name}; |
|
|
203 | |
|
|
204 | $driver eq "mysql" and return $sth->{mysql_insertid}; |
|
|
205 | $driver eq "Sybase" and return sql_fetch($dbh, 'SELECT @@IDENTITY'); |
|
|
206 | $driver eq "Informix" and return $sth->{ix_sqlerrd}[1]; |
|
|
207 | |
|
|
208 | die "sql_insertid does not spport the dbd driver '$driver', please see PApp::SQL::sql_insertid"; |
194 | } |
209 | } |
195 | |
210 | |
196 | =item [old-size] = cachesize [new-size] |
211 | =item [old-size] = cachesize [new-size] |
197 | |
212 | |
198 | Returns (and possibly changes) the LRU cache size used by C<sql_exec>. The |
213 | Returns (and possibly changes) the LRU cache size used by C<sql_exec>. The |