Re: [PHP4BETA] zend_fetch_resource_ex/ZEND_FETCH_RESOURCE & friends.
| From: | Thies C. Arntzen | Date: | Thu, 23 Sep 1999 06:56:57 +0000 |
| Subject: | Re: [PHP4BETA] zend_fetch_resource_ex/ZEND_FETCH_RESOURCE & friends. | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-4815@lists.php.net to get a copy of this message | ||
On Thu, 23 Sep 1999, Zeev Suraski wrote:
> Hmm, you're not supposed to pass NULL as the resource_type_name.
than we need to have an _ex_ex() API call. some functions can take 2
different types of resources (see attached ora_error).
either zend_fetch_resource_ex needs to "shut-up" or we need a new
parameter that also returns the resource_type so that the caller can find
out what kind of a resource he got back!
btw: i'm not very happy with this kind of low-level functions printing
warnings at all. i think zend_fetch_resource_ex should just return NULL
and maybe let ZEND_VERIFY_RESOURCE print a warning - at the module authors
choice.
another thing that could be nicer is the ZEND_REGISTER_RESOURCE() - often
a module needs to store the list-id somewhere for it's own purposes. right
now you have to do (from php_mysql.c):
ZEND_REGISTER_RESOURCE(return_value, mysql, le_link);
/* add it to the hash */
new_index_ptr.ptr = (void *) return_value->value.lval;
i think we should make ZEND_REGISTER_RESOURCE a function that returns the
new id!
tc
-----------------
/* {{{ proto string ora_error(int cursor_or_connection)
Get an Oracle error message */
PHP_FUNCTION(ora_error)
{
pval *arg;
oraCursor *cursor;
oraConnection *conn;
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
conn = (oraConnection *) zend_fetch_resource_ex(arg, -1, NULL, 2, le_conn, le_pconn);
if (conn) {
RETURN_STRING(ora_error(&conn->lda),1);
} else {
cursor = (oraCursor *) zend_fetch_resource_ex(arg, -1, NULL, 1, le_cursor);
if (cursor) {
RETURN_STRING(ora_error(&cursor->cda),1);
}
}
RETURN_FALSE;
}
/* }}} */
>
> Zeev
>
> At 11:49 22/09/1999 , Thies C. Arntzen wrote:
> >hi,
> >
> >if you pass NULL as the resource_type_name to zend_fetch_resource*&friends
> >the functions will not print any warnings if the resource is not found!
> >
> >(just committed to CVS)
> >
> >tc
> >
> >
> >--
> >PHP 4 Beta
>
> --
> Zeev Suraski <zeev@zend.com> http://www.zend.com/
> For a PGP public key, finger bourbon@netvision.net.il
>
>
> --
> PHP 4 Beta
>
>
Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!"
Digital Collections Phone +49 40 235350 Fax +49 40 23535180
Hammerbrookstr. 93 20097 Hamburg / Germany