Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122192 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 60952 invoked from network); 19 Jan 2024 15:47:03 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Jan 2024 15:47:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1705679264; bh=VOaHqheHYGAUftkYcunYGr5P0fSt2owzlHFXi4ZQFPw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=CAXXGhBpjHKxwcWWWeVzLK1blRIfAJDmzo2abC4Pc/YQKyPBq1SuvHDc1ed7Dd3jT ZfMjh/r5NiMyCwVvy6WFWaiAIWmaISrCyh6rMawtuvt+E7PxDmXaHUc64CWjk3AGwD 2MdzWw92cPoVjUhc1KG0M+2e5JkKSSiCM5++JAzjs3pypH792cDcWNwMETOMMl0Url td1ikAaKHnwyN6v3hYSOKBdcLPtxGaAHvkZubiuOIlGmWLFp3PsNW3TdQt7YkEZEnm vTv42ASCs6DUAMgm+WTss/y67skz/+bqEyxVf7M0g+f2vRQfV9JqvMm25NaJtthOIy 7ptAzAjkHZfSw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 448D618005A for ; Fri, 19 Jan 2024 07:47:42 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING, RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from relay.yourmailgateway.de (relay.yourmailgateway.de [188.68.63.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 19 Jan 2024 07:47:41 -0800 (PST) Received: from mors-relay-8201.netcup.net (localhost [127.0.0.1]) by mors-relay-8201.netcup.net (Postfix) with ESMTPS id 4TGkWR011Kz3t8T; Fri, 19 Jan 2024 16:46:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xpple.dev; s=key2; t=1705679219; bh=VOaHqheHYGAUftkYcunYGr5P0fSt2owzlHFXi4ZQFPw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ioh8HOYufsjzs2YL+Gc2NAdLSY/UPy4Q7QbdyAGzt7fvghhCxabRwCvNnYuuwFG4h qv+CxS9SIbLJ6oqF/fyN8kDv6h1QXm4T71I7IptmRBXdafoN7x/MEYcm0NpwOhv63N sM9SbztIE4BnKtR8dhsn5TXOCWsVki0nBIEDPfWvLZzgbnoOMrE6w1GTPgRAJLdWx0 +NNyQ+ER+e8t4nYfy+GXOU84Ig+m3EFi6Nil4I9t0HBAEokXx03N2LFXGz6nzYivW/ RmdFy/13QKwQznC89/CNb3xZAjO6kK704ecL2YAKEA2JJlAsnE1agv4lTZCWI6oKC6 rKql7NxoUuPTg== Received: from policy02-mors.netcup.net (unknown [46.38.225.35]) by mors-relay-8201.netcup.net (Postfix) with ESMTPS id 4TGkWQ6NTRz3t7v; Fri, 19 Jan 2024 16:46:58 +0100 (CET) Received: from mxe938.netcup.net (unknown [10.243.12.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by policy02-mors.netcup.net (Postfix) with ESMTPS id 4TGkWQ1nvnz8svG; Fri, 19 Jan 2024 16:46:58 +0100 (CET) Received: from webmail01.netcup.net (unknown [46.38.249.153]) by mxe938.netcup.net (Postfix) with ESMTPA id C7A3260CA2; Fri, 19 Jan 2024 16:46:53 +0100 (CET) Authentication-Results: mxe938; spf=pass (sender IP is 46.38.249.153) smtp.mailfrom=php@xpple.dev smtp.helo=webmail01.netcup.net Received-SPF: pass (mxe938: connection is authenticated) MIME-Version: 1.0 Date: Fri, 19 Jan 2024 16:46:53 +0100 To: Saki Takamachi Cc: Niels Dossche , internals@lists.php.net In-Reply-To: <6246AF4D-C204-443C-9056-F662E59AA687@sakiot.com> References: <6246AF4D-C204-443C-9056-F662E59AA687@sakiot.com> User-Agent: Roundcube Webmail/1.4.15 Message-ID: <37f5b6600ef3727f263e00e16acb4766@xpple.dev> X-Sender: php@xpple.dev Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-PPP-Message-ID: <170567921391.3680456.9971177044881611204@mxe938.netcup.net> X-Rspamd-Queue-Id: C7A3260CA2 X-Rspamd-Server: rspamd-worker-8404 X-NC-CID: HNyicAlM/B462CJ4/tYNpBjtumJdVFYOtxEsggA= Subject: Re: [PHP-DEV] `PDO::FETCH_CONSTRUCTOR` fetch mode proposal From: php@xpple.dev Hi Saki, > Welcome to the internal mailing list! I had looked the pull request, > and I'm pleased to have received your email promptly. Thank you! > Now, I agree that it is often not possible to use `PDO::FETCH_CLASS` > because DB column names are typically snake case and variables and > properties are camel case. > > IMHO, passing arguments to the constructor in order is a good > approach, but I think another option would be to give attributes to > properties and map data appropriately when using PDO::FETCH_CLASS. > > e.g. > ``` > #[ColumnName('user_name')] > private string $userName; > ``` The main motivation for this new fetch mode is the fact that it is now infeasible to use the constructor. You would expect to use `PDO::FETCH_CLASS` for it, as you're trying to create a class, but that is impossible entirely. You need to resort to a hacky usage of `PDO::FETCH_FUNC`, which in my view is unwanted. A nice consequence of using the constructor is that the casings need not match. I like the idea of using annotations, but they solve a different problem I think. > In addition to the concerns mentioned in the pull request, I'm also > concerned that more modes with similar functionality will confuse > users. That is a valid concern. When I first starting looking into this I was also a bit overwhelmed by the amount of possibilities one has. I think giving an appropriate name to this new fetch mode is therefore important. I thought of `PDO::FETCH_CONSTRUCTOR`, but I'm happy to hear other ideas. Kind regards, Frederik van der Els