Extracting array values and transforming into integers

1

Please, who can help me. The question is this: I need to extract two variables from an array and use them as integer type to compare values between them. The code is this:

$sql = "SELECT *
FROM 
inf_user
WHERE
login = '" . $login
."' and senha = '" . $senha ."'";

try{
    $conn = new PDO('mysql:host=' . $servername . ';dbname=' . $dbname, $username, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    $result = $conn->query($sql) or die('Nao foi possivel executar o comando.');
    $rows = $result->fetch();

    extract($rows);

    //echo "\$limite = $limite; \$consultas = $consultas";

    $limite = intval($limite);
    $consultas = intval($consultas);

    var_dump($limite);

The return of var_dump is int(2) , but I need it to be only the number 2 without int() . How do I?

    
asked by anonymous 15.01.2018 / 13:58

1 answer

0

I usually access the return value by accessing the indexes of the arrays, for example:

$result = $conn->query($sql) or die('Nao foi possivel executar o comando.');
$rows = $result->fetch(PDO::FETCH_ASSOC);

$id = $rows['id'];
$nome = $rows['nome'];
    
15.01.2018 / 14:09