Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114050 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 80388 invoked from network); 14 Apr 2021 08:47:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Apr 2021 08:47:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8771E1804DD for ; Wed, 14 Apr 2021 01:48:56 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 ; Wed, 14 Apr 2021 01:48:56 -0700 (PDT) Received: by mail-lj1-f173.google.com with SMTP id l14so19545010ljb.1 for ; Wed, 14 Apr 2021 01:48:56 -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=gwBzeevE2IlwFR5ZFK+RRodkUGAOAkumsRJbcpkEBS0=; b=KjiJfM/cwl9WpGs6JMy39NE4km7ojIzJ4KY9akPM0H9fT+WcSoEu6vGxOwkrI1LyRV mYN9TNcXRtsJ24k4gFRBxUEx59Gt3YMFXZCqrRwlxqNfanVVg6duqczY3E4LsAeTCgS3 pD4Ex6KRIkIGUS4KsWgj6zNV2wRGHwF8+6seacj6bqujZoQaF3VpNscnbZaZAtMufSdG u/vxQkCy+SpR+7kk80qZ9bkW651Uj8lmt7R/Wu4oiL8T3ggQv2MkcttaH6imQjFokaVK SkVZXERrYDso4LE8ya8doxzcYtb0MD0jr9JQxcZFjwnctMlKmuk9n4e8EiwKpKcWzvgW 0rpw== 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=gwBzeevE2IlwFR5ZFK+RRodkUGAOAkumsRJbcpkEBS0=; b=m4+Jc+3do+KAmMqLuKtOQuE5SL/9M6SRkM9glGEsX2/GqchbsCR3Zpyqqt/5BYH4ob AEY5Bgth8t6JtCx88tenVoU4qUH/b+6a7Y4m4E9+8FrO4xh/j7wB5ymzXGZ5dYiMcN1p pIEwXAXE3XUXoUTw+2W6Tvsh+o5OnTutfGVU9gpz0xgluBFiPuumpiJ1g/sTGAG1gvZC faZIIMOWvL3CTMMbDJdjxcl+T8Jd/L0nevFDEodYsh05gtuhI8aQ8rGhBNhTV9D0M21v 7VFZuYgoFRCAWNNZbEAF6g7i1uoybiURUi0tK99pTNS9aZ+lqIJRgpLjmGE7WFG/f+qK ObSQ== X-Gm-Message-State: AOAM530L8ATX0m+BQ0yNf2TJ5cHkaRyZ8UAi7uKvwzda8WxBVlz+pNvb ZbNIYktumv6FC+qVx+wTQSblCYm8LtL0aSBrs6I= X-Google-Smtp-Source: ABdhPJwRfHldVkZ9R8t4PDLixMro590a1HDDoo66MbPeHY4FFMxVsd2etYNal/2dXgi9kobu7719ogK3abE7imWLSoQ= X-Received: by 2002:a05:651c:1198:: with SMTP id w24mr13192221ljo.29.1618390131676; Wed, 14 Apr 2021 01:48:51 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 14 Apr 2021 10:48:35 +0200 Message-ID: To: Kamil Tekiela Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000e818d505bfead01f" Subject: Re: [PHP-DEV] [RFC] Add fetch_column method to mysqli From: nikita.ppv@gmail.com (Nikita Popov) --000000000000e818d505bfead01f Content-Type: text/plain; charset="UTF-8" On Sun, Mar 28, 2021 at 6:00 PM Kamil Tekiela wrote: > Hi Internals, > > I have written a new proposal in the series of improvements to mysqli > extension. This one aims to add a new method mysqli_result::fetch_column as > well as its functional counterpart. > > https://wiki.php.net/rfc/mysqli_fetch_column > > The RFC is very simple, but I am looking for your opinions. I also have > doubts about the scope. Is the scope too limited? Should it involve a > change to fetch_all as well? > > On the implementation part, I wonder if it could be optimized. The one I > have written works but doesn't look like the most efficient way to do this. > Looks like a reasonable addition to me. The implementation can be optimized if mysqlnd is used. It's possible to call mysqlnd_fetch_row_zval(), which will return the row in a flat zval buffer, and then pick out the one result you want and destroy the rest. You can find a sample usage in ext/mysql: https://github.com/php/pecl-database-mysql/blob/ca514c4dfacd7f1495d2fe142101fe3d91494d12/php_mysql.c#L2103-L2112 Not sure about fetch_all() support. I think the primary use case here is the case where you expect exactly one result (or zero/one results) and just need the one fetch_column() call. If you have multiple results you should be iterating the result set, not calling fetch_all()... Regards, Nikita --000000000000e818d505bfead01f--