Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110580 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 1838 invoked from network); 16 Jun 2020 12:05:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Jun 2020 12:05:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2C8F01804DA for ; Tue, 16 Jun 2020 03:50:51 -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-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) (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, 16 Jun 2020 03:50:50 -0700 (PDT) Received: by mail-lj1-f194.google.com with SMTP id s1so22955366ljo.0 for ; Tue, 16 Jun 2020 03:50:50 -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=YMSB/GPFKq6JHM9NxrDL8ybGXfXY2R7/KAmXHyEJ+4Q=; b=gzj6WKwSXNTBW1ZXoay4WEDiNr05daAwpWumlQlqMrCwuMHYlG2cRefwrwtaAKVhUm 150kqV2XetN1Fhp40nqyt1cAusE4esSk9BNKpi1lF2FVXfGj5gHySw3GNFKcW6dgwCKD yDK0FIY9mrqWnS4gSiXFk4vMwM0qTBwLWhzANwHc3ZD9OpkkQQC5mZk2bgl8Fgkp1c7U PQbaqU3hk+ezq2PCuewQRsbL0hk31VBZd4bN+zp1reTo6LODLwQIzbEFNk/uyE5knZch F/6L0Xbyk9aq8iMpYukVSD90US3zywrlW7WRaXDqHd5yugrcqBJeMEWItsvoxNrdRLXr tyuA== 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=YMSB/GPFKq6JHM9NxrDL8ybGXfXY2R7/KAmXHyEJ+4Q=; b=K7pQL7LNgK5EYtBj6HZmdmtDHO+zRXh4YNM1K113kBnUb7p/4yLNGcJq+Lh0hWdzkr pV8B5rspKVufJz8IVn/Li9P9xtI+QxvCne2L6mzPYPpXigSiMKmjZeMuxiY18E1xuhv+ uRnFtQ0ZX4CoBSSNWoh3LRQuQ0X58HMGbff/0Ik+Lhpqu6hl/T52Mppj/wtiDTVaTKa3 0CCqboqgJflEncWui7PGHdOwqR5gQstb8S8KsKwDENiETkz93UELQVUNTbK9Tj+2d7I+ 6XKel8LuupwrBFXNHUfu0SIoONdfQEVubaKmibdH0I6A8n+Favk5iXm+faNxuvWygwQu wVew== X-Gm-Message-State: AOAM532dZWtgex9+fsQ5mi1jxwnLS1wyVxxLp9zMkOPjL00WUolwHrkk 2eonslnrMXQ9ko73xEfryLu0NTx7ZK9rmWoggayotiTm X-Google-Smtp-Source: ABdhPJzW7u6RSltImgEr9e77Swwy50S1Un/wdcYqDCz6VXhcBMTYi35oUYh0URDrel7INGmExF5MMkFFr1B31AVVl78= X-Received: by 2002:a2e:b550:: with SMTP id a16mr1188480ljn.345.1592304647582; Tue, 16 Jun 2020 03:50:47 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 16 Jun 2020 12:50:31 +0200 Message-ID: To: Dan Ackroyd Cc: Peter Bowyer , PHP internals Content-Type: multipart/alternative; boundary="000000000000e4f14b05a831500c" Subject: Re: [PHP-DEV] SQLite3, PDO/SQLite and driver specific methods From: nikita.ppv@gmail.com (Nikita Popov) --000000000000e4f14b05a831500c Content-Type: text/plain; charset="UTF-8" On Tue, Jun 16, 2020 at 12:42 PM Dan Ackroyd wrote: > On Tue, 16 Jun 2020 at 11:32, Peter Bowyer > wrote: > > > > If it is, how can we change and improve the current situation? > > > > Hi Peter, > > I think what I wrote earlier is still a good approach: > https://externals.io/message/100773#100813 > > > Taking it to a better solution is that the method sqliteCreateFunction > > shouldn't exist on the PDO class, but instead on a PDOSqlite that > > extends PDO. > > > > class PDOSqlite extends PDO { > > public function createFunction(...) {...} > > } > > > > class PDO { > > public static function connect(string $dsn [, string $username [, > > string $password [, array $options ]]]) { > > if (connecting to SQLite DB) { > > return new PDOSqlite(...); > > } > >. // return new PDO(...); > > } > > } > > Note, I haven't done the work to actually make sure that this plan is > actually feasible, so it's not guaranteed to be the correct approach. > But it still sounds sensible and would scale out to other custom > methods for other connection types, and avoid any magic. > > If you (or anyone) have the time to work on this, that would be fantastic. > +1 on this approach. No magic, just normal inheritance. For backwards-compatibility reasons, we'd presumably still have to retain the ability to call those methods on the plain PDO object though :( But at least there would be a way to use it in a sensible way in new code. In particular this also allows you to write things like: if ($pdo instanceof PDOSqlite) { $pdo->loadExtension(...); } Regards, Nikita --000000000000e4f14b05a831500c--