get_result()需要迁移到php

时间:2018-09-10 19:43:37

标签: php mysqli

我创建了一个函数来接收我的查询(receiveQuery)并对其进行处理。 它可以接收INSERTDELETESELECTUPDATE。 另外,我从另一个函数(getParameter)调用此函数,它将把查询发送到第一个查询。 我正在向arrayWithValues传递要在SELECTDELETEUPDATEINSERT中使用的所有值。

我遇到以下错误:

Fatal error: Call to undefined method mysqli_stmt::get_result

我了解我必须迁移到bind_result,但我无法做到这一点。您能帮我解决这个问题吗?

function receiveQuery($query, $mysqli1, $arrayWithValues)
{
    global $stmt;
    $stmt = $mysqli1->prepare($query);
    $arrayCount = count($arrayWithValues);

    if ($arrayCount >= 1)
    {
        $s = "";
        for ($x = 0; $x < $arrayCount; $x ++)
        {
            $s .= 's';
        }
        array_unshift($arrayWithValues,$s);
        $tmp = array();
        foreach($arrayWithValues as $key => $value) $tmp[$key] = &$arrayWithValues[$key];
        call_user_func_array(array($stmt, 'bind_param'), $tmp);
    }

    $stmt->execute();
    $result = $stmt->get_result();

    return $result;
}

function getParameter($modulo, $descripcion)
{
    $valor = NULL;
    $arrayWithValues = array($modulo, $descripcion);
    $mysqli1 = conectar2();
    $query = "SELECT  clmValor
                FROM  tblParametro
                WHERE clmModulo      = ?
                  AND clmDescripcion = ?";
    $result = receiveQuery($query, $mysqli1, $arrayWithValues);
    $foundRecords = $result->num_rows;
    cerrarCon($mysqli1);
    if ($foundRecords > 0)
        while ($rs = $result->fetch_assoc())
            $valor = $rs['clmValor'];
    return $valor;
}

0 个答案:

没有答案
相关问题