note 88303 added to pdo.lastinsertid
| From: | infoatnospamdottimreevesdotde at osu1 dot php dot net | Date: | Mon, 19 Jan 2009 20:40:44 +0000 |
| Subject: | note 88303 added to pdo.lastinsertid | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149480@lists.php.net to get a copy of this message | ||
Improvement to my previous post - the ID returned by MSSQL was assumed stringified (and still is,
this is PDO default) - but the string-cleanup assumed german locale formatting. The following
snippet (replacing about 6 lines towards the end of the previous fragment) makes it locale
independent:
<?php
$strLastRowId = trim($rowTd[0]); // trim() for trailing Nullbyte
// Integers are returned stringified, format depends on locale
// Generally ends with ",00" or ".00" - trim that off
$strLastRowId = preg_replace('/[,.]0+$/', '', $strLastRowId);
// Remove any remaining "." or "," for thousands
$strLastRowId = preg_replace('/[,.]/', '', $strLastRowId);
?>
----
Server IP: 69.147.83.197
Probable Submitter: 79.230.60.242
----
Manual Page -- http://www.php.net/manual/en/pdo.lastinsertid.php
Edit -- https://master.php.net/note/edit/88303
Del: integrated -- https://master.php.net/note/delete/88303/integrated
Del: useless -- https://master.php.net/note/delete/88303/useless
Del: bad code -- https://master.php.net/note/delete/88303/bad+code
Del: spam -- https://master.php.net/note/delete/88303/spam
Del: non-english -- https://master.php.net/note/delete/88303/non-english
Del: in docs -- https://master.php.net/note/delete/88303/in+docs
Del: other reasons-- https://master.php.net/note/delete/88303
Reject -- https://master.php.net/note/reject/88303
Search -- https://master.php.net/manage/user-notes.php