Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58216 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94863 invoked from network); 27 Feb 2012 23:16:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Feb 2012 23:16:33 -0000 Authentication-Results: pb1.pair.com header.from=keisial@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=keisial@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: keisial@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:50582] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 13/F3-11273-1DE0C4F4 for ; Mon, 27 Feb 2012 18:16:33 -0500 Received: by werh12 with SMTP id h12so1244611wer.29 for ; Mon, 27 Feb 2012 15:16:30 -0800 (PST) Received-SPF: pass (google.com: domain of keisial@gmail.com designates 10.180.107.162 as permitted sender) client-ip=10.180.107.162; Authentication-Results: mr.google.com; spf=pass (google.com: domain of keisial@gmail.com designates 10.180.107.162 as permitted sender) smtp.mail=keisial@gmail.com; dkim=pass header.i=keisial@gmail.com Received: from mr.google.com ([10.180.107.162]) by 10.180.107.162 with SMTP id hd2mr1502507wib.8.1330384590662 (num_hops = 1); Mon, 27 Feb 2012 15:16:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=rSlQrLZdk2TjPpqbBA7ApXaC7qzV2zlBGlQSNIMJyLc=; b=iAOdAENDnKTgEy2zLv0up4JK0lt2Mzccrk/9jMG9mrCmI374qxkp92pejc2EmBlbb5 JOqLkRB/ujqr/FteImtGlpyIme6djEngvUdulLtpNFQ9O36kkdllzMawlDYpi8Dl7rY4 vkBTYdbBIsY36dMwn0stOcPmeNmLtatyapDPw= Received: by 10.180.107.162 with SMTP id hd2mr1177004wib.8.1330384590574; Mon, 27 Feb 2012 15:16:30 -0800 (PST) Received: from [192.168.1.26] (71.red-80-28-70.adsl.dynamic.ccgg.telefonica.net. [80.28.70.71]) by mx.google.com with ESMTPS id dw7sm25082727wib.4.2012.02.27.15.16.28 (version=SSLv3 cipher=OTHER); Mon, 27 Feb 2012 15:16:28 -0800 (PST) Message-ID: <4F4C0FF2.70507@gmail.com> Date: Tue, 28 Feb 2012 00:21:22 +0100 User-Agent: Thunderbird MIME-Version: 1.0 To: Richard Lynch CC: internals@lists.php.net References: <4F4686C6.2040207@sugarcrm.com> <4F496818.8000405@sugarcrm.com> <4F4982BF.8090102@sugarcrm.com> <4F4AA569.10502@gmail.com> <6d7e3ff8878174e4ae627b6744744330.squirrel@www.l-i-e.com> In-Reply-To: <6d7e3ff8878174e4ae627b6744744330.squirrel@www.l-i-e.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Enum proposal (yet another) From: keisial@gmail.com (=?ISO-8859-1?Q?=C1ngel_Gonz=E1lez?=) On 27/02/12 19:22, Richard Lynch wrote: >>> I'm not so sure about that. In a well-written web application, you >>> would >>> typically convert them on the first layer, when receiving from the >>> web. >>> On next usages, your int variables are usually ints already. > Afraid not. > > It turns out that PHP, on 32-bit hardware, converting large BIGINT > using (int) $ID ends up as a negative number, and then when you pass > it in to the database if a string query, you get a negative ID, not at > all what was intended. > > (Been there, done that, got burned) > > At least, that's been my experience with some versions of PHP and some > database drivers. > > So at least the database IDs have to remain as strings, if you are > using BIGINT. > > You could, of course, only convert the values known to be in range of > PHPs positive integers, and leave the others as strings. > > This is just a simple example of how the super strict typing simply > doesn't work out too well in PHP. That's a good example from experience. Although if you want to keep ids as strings, you can simply keep them as a string type. I was thinking on input coming from a web browser, btw.