为什么我得到:致命错误:未捕获错误:只有变量可以通过引用消息传递?

时间:2016-09-28 16:07:47

标签: php

我有注册类,在这里我定义了公共函数insert并在bindParam函数行中我收到错误消息:

  

致命错误:未捕获错误:只能通过引用传递变量

public function insert ( $table, $coloumns, $values, string $where = null, string $whereValue = null )
    {
        global $db; 
        $tbl_columns = array(); 
        foreach ($coloumns as $key => $value) {
            $tbl_columns[] = ":{$value}";
        }       
        $tbl_columns = implode(', ', $tbl_columns);     
        $values = implode(',', $values);

        $coloumns2 =  implode(',', $coloumns);

        $sql = " INSERT INTO $table ( $coloumns2 ) VALUES ( $tbl_columns )";
        if($where && $whereValue) {
            $sql .= " WHERE $where = '$whereValue' ";
        }
        $stm = $db->prepare($sql);
        foreach ($coloumns as $key => $value) {
            $stm->bindParam(":{$value}", $values[$key]);
        }           

        return $sql;
    }

0 个答案:

没有答案