Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25509 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42552 invoked by uid 1010); 2 Sep 2006 18:24:52 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 42537 invoked from network); 2 Sep 2006 18:24:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2006 18:24:52 -0000 Authentication-Results: pb1.pair.com header.from=evan@coeus-group.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=evan@coeus-group.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain coeus-group.com from 68.230.241.30 cause and error) X-PHP-List-Original-Sender: evan@coeus-group.com X-Host-Fingerprint: 68.230.241.30 fed1rmmtao09.cox.net Solaris 8 (1) Received: from [68.230.241.30] ([68.230.241.30:56443] helo=fed1rmmtao09.cox.net) by pb1.pair.com (ecelerity 2.1.1.8 r(12602M)) with ESMTP id ED/70-23420-27CC9F44 for ; Sat, 02 Sep 2006 14:24:51 -0400 Received: from fed1rmimpo02.cox.net ([70.169.32.72]) by fed1rmmtao09.cox.net (InterMail vM.6.01.06.01 201-2131-130-101-20060113) with ESMTP id <20060902182447.SZKK4015.fed1rmmtao09.cox.net@fed1rmimpo02.cox.net> for ; Sat, 2 Sep 2006 14:24:47 -0400 Received: from [192.168.1.101] ([68.111.214.179]) by fed1rmimpo02.cox.net with bizsmtp id HWQn1V00y3soQ7Y0000000 Sat, 02 Sep 2006 14:24:48 -0400 Message-ID: <44F9CC6E.4020306@coeus-group.com> Date: Sat, 02 Sep 2006 11:24:46 -0700 User-Agent: Thunderbird 1.5.0.5 (X11/20060728) MIME-Version: 1.0 To: internals@lists.php.net X-Enigmail-Version: 0.94.0.0 Content-Type: multipart/mixed; boundary="------------040200000306040706080004" Subject: [PATCH] mysqli interoperability From: evan@coeus-group.com (Evan Nemerson) --------------040200000306040706080004 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi everyone, I'm working on an extension for an RDF triple store that is built on top of MySQL 5+, and I'd like to be able to share the MySQL connection with mysqli. Unfortunately, since the mysqli header isn't installed, I can't seem to find a way that could withstand changes in mysqli. What I've come up with is to create a trivial function which will take a (zval *) and return a (MYSQL *). I know it's a bit of a hack, but I was trying to be as unintrusive as possible. Patch is attached. -Evan Nemerson --------------040200000306040706080004 Content-Type: text/x-patch; name="mysqli_interop.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="mysqli_interop.diff" Index: mysqli.c =================================================================== RCS file: /repository/php-src/ext/mysqli/mysqli.c,v retrieving revision 1.97 diff -u -r1.97 mysqli.c --- mysqli.c 27 Jul 2006 10:53:03 -0000 1.97 +++ mysqli.c 2 Sep 2006 07:10:52 -0000 @@ -331,6 +331,16 @@ } /* }}} */ +/* {{{ MYSQL * mysqli_get_connection(zval *mysql_link TSRMLS_DC) */ +MYSQL * mysqli_get_connection(zval *mysql_link, INTERNAL_FUNCTION_PARAMETERS) { + MY_MYSQL *mysql; + + MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); + + return mysql->mysql; +} +/* }}} */ + static union _zend_function *php_mysqli_constructor_get(zval *object TSRMLS_DC) { mysqli_object *obj = (mysqli_object *)zend_objects_get_address(object TSRMLS_CC); --------------040200000306040706080004--