Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122184 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 13571 invoked from network); 19 Jan 2024 00:51:24 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Jan 2024 00:51:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1705625524; bh=byi44YH68b3gfeB1R44RPVi9AgEcdolhmRoA5pJ7rUI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ZhGRjZasCep9sSC7+QYbzC8yGKEKDhwLJw2lXwVHaIW2eHLyNFlrkd3nLiEwQlKKj pKGOg/D6nPbo6IlMZS72iK048i1ewZSIGJ/TMjiDnp8Xo5xE+CvekNMoEQaXxnStu2 DeerR54DBbkwXJA6nYv8kEheJY2lS7b/OY/Zof20QVCDjU+2FGt0FZNeRGXfpEKRh6 F/9pzAV9ma1btQTL+iQXzdUoUiocdNYtRu1/AKUrMnOMI438lR+5LFGc/1qys48/y0 D8Wcl4/CwOl6q9YI9tm/ngTF2D30xo+Knpni2eE6ci0s96f7RjPSRs/UIfMUmX6y+T rg6VJ2wzSr+eQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 605CF180082 for ; Thu, 18 Jan 2024 16:52:03 -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=-2.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) (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 ; Thu, 18 Jan 2024 16:52:02 -0800 (PST) Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-dc223f3dd5eso255709276.2 for ; Thu, 18 Jan 2024 16:51:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=interi-co.20230601.gappssmtp.com; s=20230601; t=1705625481; x=1706230281; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=4hckxroFFvWvplvWq/azWYABZsm9/qVaeElxz40RVrk=; b=oq9oOYAfeHXkqhzPkUn9O0EqHBlvWWybcGeBA/h8/aytxupV1wZBf+xua2jzYH6FCd BrJ/nL03bJzt0GR83yd+8F1e4nZoP9DEdS4HZoSKT6A2rwUVb4foFeMZ6GgTRBLUJKLX +LAud+Fiywza3IBpa3VWvDkIgsJhe9oBl4TibgZV7zzBye01L9JhtyiNwYamAMMd85G0 qPoeszWcEIFecVclp3k2Bn1xGlfQ8T6bLqqTviwwYz4wT5t19qbfOrKb6OAxFACMoBVu 2Jbnun2ZQmEFSmeFxUWc44JOzxpDmktijJt6ej370cLH3OfVKrovFNYeS+FwMX/5CaVx o13g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705625481; x=1706230281; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4hckxroFFvWvplvWq/azWYABZsm9/qVaeElxz40RVrk=; b=SYrGkIhkaEyEWNRHoCZPIKSzJmTGEmEQZrRm5RF0wB47mDSHzZ/Qd+E9rrXt13fjt1 JkOPf20/qCl16omuP9byK3eVGK93gk5w1GANivYaYKLzRBc5xoa1lulnxg0No3KIY0NI sn6wGdxww8FgxSsmTHZxxiAVp+uTaixsW5NEvSSlBtbTLrLa2Oo39HkjsgEjL00c3EeH pIpt9F39mKLJMvTLBAwYD3wMReFqQYvBqm5rx/VifA+rFmr+jvnOAOH5drQT1uhPm+AZ 2CcsPVALm0Jou9gUp38ZkjtrBkMDwgN18LFXASFdqSqwwQ1CKgVt0jWoJ0Tgsk9UWNOH tvkg== X-Gm-Message-State: AOJu0Yw9B0dEveBeKTOmd1KfqTBl+WZwzOj1pzGipM/gAnTe16AcS4gE rMCPNqoL+lm1QRSMD18oIj2+fEGBaeTOlG03r388U9TYQhm6hJHIF5JYW4Lo2gM3cC88wj8GzMr c4kmuotZ0XN96lCKc4I/9vWf2DsWx/14vtbd8VA== X-Google-Smtp-Source: AGHT+IGx/z9PWGWY0HlZEljo4bn31fBfO2o3nO8x2qsqXQwQ6l0Nus4FIjKubq/KR69fbuMGXRSFp5BESycTrTWjazU= X-Received: by 2002:a25:bcc:0:b0:dbd:4eff:3981 with SMTP id 195-20020a250bcc000000b00dbd4eff3981mr1375863ybl.69.1705625481501; Thu, 18 Jan 2024 16:51:21 -0800 (PST) MIME-Version: 1.0 References: <6246AF4D-C204-443C-9056-F662E59AA687@sakiot.com> In-Reply-To: <6246AF4D-C204-443C-9056-F662E59AA687@sakiot.com> Date: Fri, 19 Jan 2024 09:51:09 +0900 Message-ID: To: Saki Takamachi Cc: php@xpple.dev, Niels Dossche , internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000f1f2bf060f41e043" Subject: Re: [PHP-DEV] `PDO::FETCH_CONSTRUCTOR` fetch mode proposal From: alex.pravdin@interi.co (Alexander Pravdin) --000000000000f1f2bf060f41e043 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I would also suggest supporting readonly classes and creating special attributes to help map data fields to constructor arguments. Something like this: readonly class User { public function __construct( #[PDOField('user_id')] public string $userId, #[PDOField('user_name')] public string $userName, #[PDOField('user_address')] public ?string $userAddress =3D '', // Optional field with default value ); } -- Best regards, Alex On Fri, Jan 19, 2024 at 9:05=E2=80=AFAM Saki Takamachi wr= ote: > Hi Frederik > > > First off, please excuse me if I=E2=80=99ve done something wrong relate= d to the > usage of the mailing list. This all is completely new to me. > > Welcome to the internal mailing list! I had looked the pull request, and > I'm pleased to have received your email promptly. > > > Thank you, the link was originally on the text "on GitHub" but it seems > to have been stripped. > > Since mailing lists are text rather than HTML, you cannot attach links to > strings. > > > I hereby want to propose a new fetch mode for PDO. I=E2=80=99ve detaile= d the > motivation for it on GitHub. I haven=E2=80=99t actually written the code = for it, > but it should not be too difficult. > > 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; > ``` > > In addition to the concerns mentioned in the pull request, I'm also > concerned that more modes with similar functionality will confuse users. > > Regards. > > Saki > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > --000000000000f1f2bf060f41e043--