获取 sql return php 的值

get values of sql return php

我有这个型号

class LoginModel extends Database
{
    public function signIn($userName,$password){
        return $this->select("select count(*) as o_user_exists from users where usuario = ? and password =  ?");                    
    }
}
?> 

我的函数select

public function select($query = "" , $params = [])
{
    try {
        $stmt = $this->executeStatement( $query , $params );
        $result = $stmt->get_result()->fetch_all(MYSQLI_ASSOC);             
        $stmt->close();

        return $result;
    } catch(Exception $e) {
        throw New Exception( $e->getMessage() );
    }
    return false;
}

在我的控制器中我有

$userModel = new LoginModel();            
 $actionSignIn = $userModel->signIn($p_userName,$p_password);        
 $responseData = json_encode($actionSignIn[0],true); 
 echo $responseData->o_user_exists;

如何从中获取值 return?

{"o_user_exists":1}

我将我的代码编辑为

 $userModel = new LoginModel();            
                $actionSignIn = $userModel->signIn($p_userName,$p_password);                                        
                $responseData = json_decode(json_encode($actionSignIn),true);                 
                echo $responseData['o_user_exists'];

现在你得到未定义的索引

结果您得到了一个 JSON 对象。您可以 json_decode 并将其作为数组访问。

$responseArray = json_decode($response, true);
$responseArray['o_user_exists'];