1

MysqliDb クラスを使用していますが、次のエラーが発生します。

「非推奨: Call-time pass-by-reference は C:...\MySqlDb.php の 101 行目で廃止されました」、340、348、および 375

array_push 関数は次のとおりです。

array_push($params, &$bindParams[$prop]);

array_push($this->_bindParams, &$tableData[$prop]);

「&」を削除すると機能しましたが、これらの/\ 2つだけで機能し、これら/ 2つでは機能しませんでした(多くのエラーが発生しました)

if($hasConditional) {
            if ($this->_where) {
                $this->_bindParams[0] .= $this->_whereTypeList;
                foreach ($this->_where as $prop => $val) {
                    array_push($this->_bindParams, &$this->_where[$prop]);
                }
            }   
        }

while ($field = $meta->fetch_field()) {
            array_push($parameters, &$row[$field->name]);
        }

MysqliDb クラスはここにあります: https://github.com/ajillion/PHP-MySQLi-Database-Class

4

1 に答える 1

3

array_push配列に要素を追加するのと同じです。行を書き換えることができます

     array_push($this->_bindParams, &$this->_where[$prop]);

     $this->_bindParams[] =  & $this->_where[$prop];

あなたの場合。


E_DEPRECATED エラーは警告です。参照渡しは引き続き可能です。警告を回避するには、次の不器用な回避策を使用して警告を強制することもできます。

call_user_func_array("array_push", array(&$this->_bindParams, &$this->_where[$prop]));

(実際には、両方のパラメーターの参照渡しが必要です。)

于 2011-07-03T11:27:06.390 に答える