Warning about passing argumensts by reference
| From: | Robert Twitty | Date: | Mon, 24 Nov 2003 16:12:06 +0000 |
| Subject: | Warning about passing argumensts by reference | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-227@lists.php.net to get a copy of this message | ||
Hello
When I call a funtion as follows:
odbtp_attach_field( $qry, 0, &$col1 );
I get the following warning:
Warning: Call-time pass-by-reference has been deprecated - argument passed
by value; If you would like to pass it by reference, modify the
declaration of odbtp_attach_field(). If you would like to enable call-time
pass-by-reference, you can set allow_call_time_pass_reference to true in
your INI file. However, future versions may not support this any longer
The problem is that odbtp_attach_field() is a PECL function and not a
script declared function. What do I need to do in the C code declaration
of this function to prevent this warning from occuring? Below is the code
for this function.
PHP_FUNCTION(odbtp_attach_field)
{
php_odbtp_attach_variable(INTERNAL_FUNCTION_PARAM_PASSTHRU, TRUE);
}
static void php_odbtp_attach_variable(INTERNAL_FUNCTION_PARAMETERS, odbBOOL bAttachToCol )
{
odbHANDLE hQry;
odbtp_query* qry;
zval* rQry;
odbUSHORT usId;
zval* zId;
zval* zVar;
if( zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rzz",
&rQry,
&zId,
&zVar ) == FAILURE )
return;
ZEND_FETCH_RESOURCE( qry, odbtp_query*, &rQry, -1, le_query_name, le_query );
if( !(hQry = qry->hQry) )
{
process_odbtp_invalid(le_query_name TSRMLS_CC);
RETURN_FALSE;
}
if( !PZVAL_IS_REF(zVar) )
{
php_odbtp_invalid(hQry, "Variable not passed by reference" TSRMLS_CC);
RETURN_FALSE;
}
if( bAttachToCol )
{
if( !(usId = odbtp_get_col_num(hQry, zId TSRMLS_CC)) )
{
RETURN_FALSE;
}
odbSetColUserData( hQry, usId, zVar );
qry->attached_cols = TRUE;
}
else
{
if( !(usId = odbtp_get_param_num(hQry, zId TSRMLS_CC)) )
{
RETURN_FALSE;
}
odbSetParamUserData( hQry, usId, zVar );
qry->attached_params = TRUE;
qry->dont_set_params = FALSE;
}
ZVAL_ADDREF(zVar);
RETURN_TRUE;
}
-- bob