0

これは報告されたバグで、回避しようとしています。クライアントは PHP V-whoknowswhat から PHP V5.3 にアップグレードしたばかりです。このエラーは、サイトを台無しにしている多くのエラーの 1 つだと思います。とにかく、簡単に言えば、 $params を値としてではなく参照として渡す必要がありますが、どうすればよいのか混乱していますか? 多分いくつかの助け?

mysqli_stmt::bind_param() へのパラメータ 2 は参照であると予想され、値は ../Zend/Db/Statement/Mysqli.php で指定されます

public function _execute(array $params = null)
{

var_export ($params);
// output1: array ( )
/* output2: array ( 
     0 => '34',
     1 => 'Four Seasons Seattle',
     2 => 'Four Seasons Seattle',
     3 => '{//...copy text...}',
     4 => '1',
     5 => '1',
     6 => 'four-seasons-hotel',
     7 => '14',
)
*/

    if (!$this->_stmt) {
        return false;
    }
    // if no params were given as an argument to execute(),
    // then default to the _bindParam array
    if ($params === null) {
        $params = $this->_bindParam;
    }


    // send $params as input parameters to the statement
    if ($params) {
        array_unshift($params, str_repeat('s', count($params)));

var_export ($params);
// output1: array ( )
/* output2: array ( 
     0 => 'ssssssss',
     1 => '34',
     2 => 'Four Seasons Seattle',
     3 => 'Four Seasons Seattle',
     4 => '{//...copy text...}',
     5 => '1',
     6 => '1',
     7 => 'four-seasons-hotel',
     8 => '14',
)
*/
        call_user_func_array(
            array($this->_stmt, 'bind_param'),
            $params
        );
die();

    }

これがバグレポートです。私はそれが話している怠惰な方法を試しましたが、エラーなしでホワイトスクリーンになりました =(

https://bugs.php.net/bug.php?id=43568

4

1 に答える 1

0

その答えは、参照によって値を渡すように bindParams 関数を完全に書き直すことでした。以下のコード。

private static function _bindParams(&$stmt, $valuesArray)
{
    if (count($valuesArray) > 0)
    {

        $types = str_repeat('s', count($valuesArray));
        $params = array_merge(array($types), $valuesArray);

        $tmpArray = array();
        foreach ($params as $i => $value)
        {
            $tmpArray[$i] = &$params[$i];
        }

        $bindOK = call_user_func_array(array($stmt,'bind_param'), $tmpArray);
    }
    else
    {
        $bindOK = true;
    }
    return $bindOK;
}
于 2012-07-26T15:43:20.173 に答える