Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114267 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 63250 invoked from network); 4 May 2021 11:07:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 May 2021 11:07:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9507C1804C8 for ; Tue, 4 May 2021 04:13:52 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f178.google.com (mail-il1-f178.google.com [209.85.166.178]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 4 May 2021 04:13:52 -0700 (PDT) Received: by mail-il1-f178.google.com with SMTP id h6so6016222ila.7 for ; Tue, 04 May 2021 04:13:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=o8MSQSKJ8Nl3it5U5pphAhWaRekYPkrc77nv/6cYm+I=; b=RQZVc4pLOcHCPrLnkbMKs2dr8Wa2Fehs52yz7e5cA0wmeN0h8mpky9s4rbMj3KrT68 Tv1AOohGG/CCZwMTqoXifK4E0FqVPPAil3Zjj6QEvUbsy7mE8geeHXO/2fzHTdfFuDTE NL870Ry82RcI8pc62PT6UkrAt8+hhFJLKt8aySOoZwqV6QtpxHiTomMLgCD7xmR/D5lS vUzJLhfff7DYM2AIQbSlXR31inXjsDMzUYb4YDyOJfhWPxrTcBj/z+oHSoUnYl62CicW KrYE7tCV79bUAB8YZEsIFGzqIGL9r6gJZ9tgIOGvkGpyp3I+nCXqapJTuScYlVp8u3Tg e7ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=o8MSQSKJ8Nl3it5U5pphAhWaRekYPkrc77nv/6cYm+I=; b=kvKVNjxRcWPAZMsxlG6ox08EJAZKLDurNLmU+wdrf2i0ud+d8ysF4cMtWogq/PvY8R pBr6TA/OMRN8ElTrZRuNwE9gCIF3QuuVjB/hnMoCEDPcTwLfdMaF/KU959r28VV2pLEi V40YfmDqlCKjeEgA3EPBZvk41nGyKjJ+qh+oTG0YILIF4MMOwtl6ZYvIBNHBmbofaZGp nDsa0k/oY/Koy4wwASMEbU4hfgFXCGyT2YVd/t8wrxaaHtg3cyrAsSx9yiCytaEuipfW 3C9anprYRyJffAoLgZP9sG3dcYiXEJJNHsxcDN2+7LfLPtRRgvoc1wfe0OumsmdG0qy4 3sYQ== X-Gm-Message-State: AOAM532r274Axy6lWjtqA52ACUtQHGK53nMKn61IxN9AdRzLCrkU11HL LoIpMlY3WfF+AvLBv1OdXj5wq2UNlyLYePW+r9c= X-Google-Smtp-Source: ABdhPJw5bHp3d3eWLbb3bLOJ6mG7twnkJD/GLVmQkgmBYrZM7HHkCI9rKRDDERKhkwkW1Bn5pPv42CgXmsuwXo5U45s= X-Received: by 2002:a05:6e02:1d9e:: with SMTP id h30mr19518413ila.214.1620126830757; Tue, 04 May 2021 04:13:50 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 4 May 2021 13:13:38 +0200 Message-ID: To: Kamil Tekiela Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000003d0b3d05c17f2c84" Subject: Re: [PHP-DEV] feat(pdo): add `clearParams` method From: juanrgm724@gmail.com (Juanra GM) --0000000000003d0b3d05c17f2c84 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello Kamil, thanks you for your reply. I am going to enumerate the answers. 1. `PDOStatement::clearParams` should reset the statament params ( https://github.com/php/php-src/blob/31c74aaeebf3af3c87e3981703f9f775c65600b= 9/ext/pdo/pdo_stmt.c#L406-L410 ). 2. Recreate the prepared statement is very cost. 3. SQL engine is choosing bad the search index because I am passing a param as string insteadof integer. If you call `PDOStatement::execute` without params, the statement will use the last params. Don't to clear the last params can be a problem. For example: ```php $pdo->bindValue("id1", 1, PDO::PARAM_INT); $pdo->bindValue("id2", 2, PDO::PARAM_INT); $pdo->execute(); // id1 =3D> 1, id2 =3D> 2 $pdo->bindValue("id2", 3, PDO::PARAM_INT); $pdo->execute(); // id1 =3D> 1, id2 =3D> 3 ``` If you call `$pdo->clearParams();` before of each `execute`, then it will throw a fatal error because it won't use the previous params. The main idea is to overwrite the `PDOStatement::execute` method, using a custom class (`PDO::ATTR_STATEMENT_CLASS`) for bind values individually with their types (`bindValue`), but firstly I need call `clearParams`. El mar., 4 may. 2021 12:18, Kamil Tekiela escribi=C3= =B3: > Hi Juanra, > > Thanks for sharing your interest in improving PHP. Your proposal is very > unclear at the moment. What do you think this function should do? Why can= 't > you just recreate the prepared statement? What performance hit are you > talking about? > I don't see how such a function would be useful, but I hope you can > explain your use case and its reasoning. > > Regards, > Kamil > --0000000000003d0b3d05c17f2c84--