Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:14636 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30024 invoked by uid 1010); 4 Feb 2005 04:19:43 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 29579 invoked from network); 4 Feb 2005 04:19:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2005 04:19:30 -0000 X-Host-Fingerprint: 66.92.75.243 dsl092-075-243.bos1.dsl.speakeasy.net Linux 2.4/2.6 Received: from ([66.92.75.243:1311] helo=amber.vis-av.com) by pb1.pair.com (ecelerity HEAD (r4105:4106)) with SMTP id B6/AD-05104-A52F2024 for ; Thu, 03 Feb 2005 22:56:10 -0500 Received: (qmail 13109 invoked from network); 4 Feb 2005 03:56:05 -0000 Received: from unknown (HELO random.internal) (192.168.1.9) by amber.internal with SMTP; 4 Feb 2005 03:56:05 -0000 Received: (nullmailer pid 6769 invoked by uid 0); Fri, 04 Feb 2005 03:56:04 -0000 To: Wez Furlong Cc: internals References: <4e89b426050203173642c9c28b@mail.gmail.com> Reply-To: Derrell.Lipman@UnwiredUniverse.com Date: Thu, 03 Feb 2005 22:56:04 -0500 In-Reply-To: <4e89b426050203173642c9c28b@mail.gmail.com> (Wez Furlong's message of "Thu, 3 Feb 2005 20:36:58 -0500") Message-ID: <3bwdnfl7.fsf@random.internal> User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Corporate Culture, linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [PHP-DEV] how to make nasty code less nasty (obtaining sqlite db handle) From: Derrell.Lipman@UnwiredUniverse.com Wez Furlong writes: > There is no official way to do this kind of thing between arbitrary > extensions. When extensions that are written to share this information, > they typically export an XXX_API function that you can link against to fetch > the data. > > What you've done works, so that's fine, although there is a risk of > crashing if someone passes the wrong type of resource in. If you're > thinking of distributing your extension, we could add a more official > API for you to use, although that doesn't exist in older versions of > the extension, etc. etc. Thanks, Wez. My extension will likely never be used other than with locally-written code. My biggest concern is making use of the incestual knowledge of the private php_sqlite_db structure and that the database handle is the first field in it. That structure may change in the future. My use of this is as a function used in a query -- sqlite_create_function() is used to allow a call to a php function which passes the database handle to the extension function. Prior to today, my extension had its own private database handle that it initialized on the MINIT function, but I was causing a deadlock by calling this function from within a query in PHP which called the extension which tried to issue additional queries using my private database handle in the extension. Passing in the php-derived handle is the only way of eliminating that deadlock. I wonder whether I'm really alone in wanting access to a database handle for extensions. It would seem appropriate to provide access to the C-level database handle given a PHP resources. That would eliminate the need to base an extenion on insestual knowledge of the database-specific extension. Thanks again, Derrell