#30616 [Fbk->Csd]: Cant return as reference from offsetget() for mysqli_stmt->bind_param()

2004-10-29 Thread john at milsson dot nu
 ID:   30616
 User updated by:  john at milsson dot nu
 Reported By:  john at milsson dot nu
-Status:   Feedback
+Status:   Closed
 Bug Type: MySQLi related
 Operating System: Windows
 PHP Version:  5.0.2
 New Comment:

Tried to trigger this at home. But it works as expected.

But: 
  1. This is a linux machine.
  2. Home compiled
  3. I'm not stressed out...
  4. The code is much cleaner.

My guess is that I screwd up with one of the '&' in some deep nested
retuen tree


As I said, this code works:
class ArrayObj implements ArrayAccess {

private $_val;
public  $valAsProp;

function __construct($val){
$this->_val = $val;
$this->valAsProp =& $this->_val;
}
//
// ArrayAccess interface
//
function  offsetExists($key)   { return isset($this->{'_'.$key});  
}
function &offsetGet($key)  { return  
$this->{'get'.ucfirst($key)}();}
function  offsetSet($key,$val) {  $this->{'_'.$key} =
$val; }
function  offsetUnset($key){  $this->{'_'.$key} =
null; }

function &__get($key)  { return   $this->{'_'.$key};   
}

function &getVal() {
return $this->_val;
}
 }

$arrayobj = new ArrayObj(new ArrayObj('an other val'));

$db = new mysqli('localhost');
$stmt = $db->prepare("SELECT ? as `val`");
//$stmt->bind_param('s', $arrayobj->valAsProp);
//$stmt->bind_param('s', $arrayobj->val);
$stmt->bind_param('s', $arrayobj['val']['val']);
$stmt->execute();
$stmt->bind_result($res);
$stmt->fetch();
$stmt->close();

echo "\n$res\n";

?>


Previous Comments:


[2004-10-30 00:56:11] [EMAIL PROTECTED]

Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.




[2004-10-29 21:26:35] john at milsson dot nu

Description:

Fatal error: Objects used as arrays in post/pre increment/decrement
must return values by reference

when I try to use
$mysqli_stmt->bind_param('s',$arrayAccessObj['offset']);

even though offsetget is declared as

function &offsetGet($key) {
return $this->{'_'.strtolower($key)};
}







-- 
Edit this bug report at http://bugs.php.net/?id=30616&edit=1


#30616 [NEW]: Cant return as reference from offsetget() for mysqli_stmt->bind_param()

2004-10-29 Thread john at milsson dot nu
From: john at milsson dot nu
Operating system: Windows
PHP version:  5.0.2
PHP Bug Type: MySQLi related
Bug description:  Cant return as reference from offsetget() for 
mysqli_stmt->bind_param()

Description:

Fatal error: Objects used as arrays in post/pre increment/decrement must
return values by reference

when I try to use
$mysqli_stmt->bind_param('s',$arrayAccessObj['offset']);

even though offsetget is declared as

function &offsetGet($key) {
return $this->{'_'.strtolower($key)};
}



-- 
Edit bug report at http://bugs.php.net/?id=30616&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30616&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30616&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30616&r=trysnapshot51
Fixed in CVS:http://bugs.php.net/fix.php?id=30616&r=fixedcvs
Fixed in release:http://bugs.php.net/fix.php?id=30616&r=alreadyfixed
Need backtrace:  http://bugs.php.net/fix.php?id=30616&r=needtrace
Need Reproduce Script:   http://bugs.php.net/fix.php?id=30616&r=needscript
Try newer version:   http://bugs.php.net/fix.php?id=30616&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30616&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=30616&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=30616&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=30616&r=submittedtwice
register_globals:http://bugs.php.net/fix.php?id=30616&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30616&r=php3
Daylight Savings:http://bugs.php.net/fix.php?id=30616&r=dst
IIS Stability:   http://bugs.php.net/fix.php?id=30616&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30616&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30616&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30616&r=mysqlcfg