gpt4 book ai didi

php - mysqli num rows 的问题

转载 作者:行者123 更新时间:2023-11-29 00:53:07 24 4
gpt4 key购买 nike

我有一个用于从数据库中选择的函数

function selectquery ($sql, $types, $params)
{
$connection = getConnect ();
$result = $connection->prepare("$sql");
$result->bind_param($types, $params);
$status = $result->execute();
$result->store_result();
$return=array('obj'=>$result, 'status' => $status, 'data'=>array());
$meta = $result->result_metadata();
while ( $field = $meta->fetch_field() )
{
$parameters[] = &$row[$field->name];
}
call_user_func_array(array($result, 'bind_result'), $parameters);

while ( $result->fetch())
{
$x = array();
foreach( $row as $key => $val )
{
$x[$key] = $val;
}
$return['data'][] = $x;
}
$result->close();
return $return;
}

当我运行查询时:

$resultobj=selectquery ("select id from employers where subdomain = ? ", "s", $reg_subdomain);
if ($resultobj['obj']->num_rows()>0 || in_array($reg_subdomain, $locked_subdomains)) { $error .="Subdomain already exist, please choose another <br>"; }

我收到此错误消息:

Warning: mysqli_stmt::num_rows() [mysqli-stmt.num-rows]: Couldn't fetch mysqli_stmt in /home/drac/public_html/dracxyz.com/functions.php on line 174

请问我做错了什么?

谢谢

最佳答案

像这样使用

$resultobj->num_rows() 

http://php.net/manual/en/mysqli-result.num-rows.php

关于php - mysqli num rows 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7414290/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com