Re: Type hinting
| From: | Derick Rethans | Date: | Thu, 27 May 2010 15:40:16 +0000 |
| Subject: | Re: Type hinting | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-48526@lists.php.net to get a copy of this message | ||
On Thu, 27 May 2010, Arvids Godjuks wrote:
> Please read more carefully - what I mean that is we deal mostly with
> numbers witch are represented as strings, because all data that comes
> from external sources are STRING regardless of actual contents - be
> that integer or float - no matter. I don't want to make my code look
> like this:
>
> function doSomeStuffWithDbData(int $id, string $name, int $someFlag) {
> }
>
> $sql = 'SELECT id, name, some_flag, .... FROM table WHERE .....';
> $res = mysqli_query($db, $sql);
> $row = $res->fetch_assoc();
> doSomeStuffWithDbData((int)$row['id'], $row['name'],
> (int)$row['some_flag']);
PDO's bind values already provide the correct type if you specify so. So
this is moot point.
regards,
Derick
--
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug