Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130544 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 5872E1A00BC for ; Fri, 3 Apr 2026 15:21:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1775229696; bh=cRT2JXLaMaD0xzYBhJNgzw8pTPlawrieUuKrEJtCKAA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HbDZeYgvmxQM0VjsH6D9UMDpHjIXYLlFo2yc+TxqySEL7SoRNiBBbteNn+M/LJ/20 xBu0ougbL+W5cbb3qc5W5ef6Ya+sZYDegZHV3HPZyOm3qIUfXZOBho61VWAXrrl3qh nQDfgLnhQirSuRNVrOFYQzIY82ULLnNTs8b6ic69SGG8ddY3sUW1kS6rvexMFvnKJg iK8n4EDeArLV6pAR9pwnuCHoHpoktvtsLGIhdR7RWqAYMl64i23zxgti/+ITd3g6fW mHSK87T8fQUcmmKiBtDgV5sSGYMP79rrtRsRR9OrqsLPBx+HanQH6pv4JtelMeqXLA 6d6LgV0vSSVzg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0F5C01801D5 for ; Fri, 3 Apr 2026 15:21:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.9 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FORGED_GMAIL_RCVD,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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, 3 Apr 2026 15:21:28 +0000 (UTC) Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-38dd5f28a4cso4367641fa.2 for ; Fri, 03 Apr 2026 08:21:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775229682; cv=none; d=google.com; s=arc-20240605; b=EOvxy0QltE22FjM6i3k/JxAa98aacUh2yRqG+kQtHOrBrg4unu2+UBqqIG6gVQ4ktw AtbwpzTuGLinep9fkva5GmMcAS9nCeWODW67dj98Jmd9UUfIROWhWv5uZJAJ5Nnqnd5M wL0W0OXzQEHyzVaWBlyrqZIxxtsNCtj7/Jbis498pdfrx6mfbuLcf8KzbN8EC6+bMsAu gvkiEfLc+AphH9jab4sdZItiTUekpUIInD2KwQo3tMB+69tBCI53I+JAlz2AXMzbr+aS RHeonCt567qGYpSoqokll4FydB4act8hpRm905cG4EFgoYZJZepNkVMW8XFpA4Fpc212 jdBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=EZuTn0saF3kE3d42+GawDtg6FPPbAO1ZOoLDYNZCIec=; fh=7e15xKRJAon8pLDlF842JFM5f+9N5tuV8Yqt70o1sNs=; b=izlziWwjJ14D2DASR6SGKeAb6IR09tEdxxSdgXP5gqkwEHn3W/9OIQUCXvjycBEJas ePcvyQmRqsG7P2fn1MAj4ANBUfz/Q2q8+GlJmvnNEjfqrWRJK4DH/9i9Us/J52zbIcjP GyvbIlINfUJAFZ0KW+xL97Yc626ZN3w0Gr1/ZgfCvhqGL4aZ76kiK/ipm0PcMg7SRkj/ 555183tkCy90sMz4yTWwOGCTZG1+5PDH+ds5ovAGvczQgklFcIsorbh1fxyFYV8iMBcl LdfUrrIi1kF7DfhGu75v6CryLYRD1gRevR0twMEMWFOOAC6hcQWUSuzOhPtExSMQYDHE IODQ==; darn=lists.php.net ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775229682; x=1775834482; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=EZuTn0saF3kE3d42+GawDtg6FPPbAO1ZOoLDYNZCIec=; b=T/KGaGxq9bmH8hB+403xs7+olz0DM2EeNPYBwUQibdHe7Y6hSuKi51JcxHolb6sghw 4fZjdHP5KzF4y9Z7D4DMEANwRGNI6ZDRtcbqXL+y7ZlGeTarGIbHr/gsj1F4PFgt96Wc 0GutfOlK2TczM+E0B45RuM7NuFSsAH8Qo/YB3o9hfYa+nLpt/EzxyYTgk2Ib0zOlZFsG kJBfo2vium7CXE0CWhYC3KfXlhA1qkOdCD+umDHOLGYxALtr9Kp1WzycsuYmNygyC7Y/ 5lqBnWA22bytMREheMTDWfHysW9lXxP+2ghNUwz37h5zVoe9Zm8WT+2MwSw7kr3pBmsn zUVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775229682; x=1775834482; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=EZuTn0saF3kE3d42+GawDtg6FPPbAO1ZOoLDYNZCIec=; b=FKzetpYpbqHCbILR1QZ55Qq3CRhCKOUzRh9cZTArc2w6n7hKvy9eEnpFLnu5h4uoti JgT1jEcSA2hKq74te/ygAoX8sral6GKScCTZOQ/rbvORmOtUOKtnqSPvaYblsckd7JD2 vyV7asOzC1yLIrLEB0GGG18NGCUv7+3TFFXJwCZOPHPWbHjnGnjRV/LR9NbSUN54nNpb N4qvvyV9U/wBTnYIpb7iVEezQ4jCcqtD2LZ+MbSGVMSUqhks68B28tvkzuq//fFZTNVG H5XdVGIbfML9t3eafgqVEvgRZwpkiM9qmAvr2IiZF+7JimObmJLln3IfDfTZEIyhuClr bfug== X-Gm-Message-State: AOJu0YxANpDx2FLW1O6JJidYta3L0c9bA6i93P/jIJcW45JNUV/rmqMp 5rB90SXEaZiC/ghUGJtUPBPaF+clSrUTsN6qkWAteMCc2ssbMGBIKKUHbLh0avDadpO+YZzWHaQ MXsFRAP0yPFo4WhAVo2LvS76hazPA6ro= X-Gm-Gg: AeBDieso+IjWAbUhinplZK4z7UyAgfQq9vDNvQJiUD/haoLD1LZHPTHSGEuGZAScfyp JQB9OjHFe+IsjPphMdcmIv6atO2Kkr7A8OrO7XxJEw7lrnzJ0mIbpIqJLBEffPaKZ9XsRimpcqr p6jRQ6fZQwI041RLZPnvzMBUac4ggOhH3MR7A5j291nSc4W+OkdJpz6q5Ee0dRXQdqOqS43Gpc6 Qzg3XV0hDeyaQArfOPBfCIdA8pi8T4MjkxMK0xKvDGqk4LDrmFnVvgQbOkVCZDE58QiJ/GZnt77 VUrDOPM= X-Received: by 2002:a2e:be92:0:b0:38c:6979:f75d with SMTP id 38308e7fff4ca-38d91d89693mr11388431fa.34.1775229681749; Fri, 03 Apr 2026 08:21:21 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 3 Apr 2026 16:21:11 +0100 X-Gm-Features: AQROBzAGSqB08EhXP-je5tgS91r39wzpXjjL6j7p5oynjZBAlx3nfSX9VCZhvXQ Message-ID: Subject: Re: [PHP-DEV] PDO SQLite: statement attributes for SQL text retrieval To: Ilia Cc: PHP Developers Mailing List , saki@php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: tekiela246@gmail.com (Kamil Tekiela) On Fri, 3 Apr 2026 at 13:29, Ilia wrote: > > Hi internals, > > I'm looking for feedback on a small pdo_sqlite addition. > > PR: https://github.com/php/php-src/pull/21456 > Implements: https://github.com/php/php-src/issues/21322 > > Two new read-only statement attributes on Pdo\Sqlite: > - Pdo\Sqlite::ATTR_SQL =E2=80=94 original SQL text of a prepared statemen= t (via sqlite3_sql()) > - Pdo\Sqlite::ATTR_EXPANDED_SQL =E2=80=94 SQL with bound parameters inlin= ed (via sqlite3_expanded_sql()) > > $stmt =3D $db->prepare('SELECT :name AS greeting'); > $stmt->bindValue(':name', 'hello'); > $stmt->execute(); > > $stmt->getAttribute(Pdo\Sqlite::ATTR_SQL); // "SELECT :name AS g= reeting" > $stmt->getAttribute(Pdo\Sqlite::ATTR_EXPANDED_SQL); // "SELECT 'hello' AS= greeting" > > This mirrors SQLite3Stmt::getSQL() from the non-PDO API, but uses PDO's g= etAttribute() mechanism rather than adding a driver-specific method. The at= tribute system is how PDO drivers expose driver-specific functionality, so = it's a natural fit. > > ATTR_EXPANDED_SQL is gated behind a configure check for sqlite3_expanded_= sql availability. > > I don't think this needs a full RFC given the scope (two read-only attrib= utes, single driver, no BC impact), but I wanted input from the list. > > Thoughts? > > -- > Ilia Alshanetsky > Technologist, CTO, Entrepreneur > E: ilia@ilia.ws > T: @iliaa > B: http://ilia.ws I agree with Saki that a dedicated function would be better than treating this as an attribute. However, I fail to understand why this is useful at all. SQL is something that is coming from the developer using the function, so why would they need to look it up again from the prepared statement? The emulated statement could be useful in case an error is triggered due to a data issue, but not only does this happen rarely, but the error already contains all the necessary information. I think I would like to see a concrete use case of when this is helpful.