In the index used in the query / prepared statement

Asked

Viewed 88 times

1

I have a strange Warning in my code, when there is only one data in DB it recognizes and works well, but when I insert more than 1 data in DB it shows me the following Warning:

No index used in query/Prepared statement SELECT * FROM con_users "SELECT * FROM con_users"

To query phpmyadmin I used the following code:

<?php

include_once 'includes/settings.php';
require_once 'includes/autoloader.php';

$querys = $db->Execute("SELECT * FROM con_users");

while($ln = $db->FetchArray($querys)) {

    $id = $ln['id'];
    $nome = $ln['nome'];
    $lastname = $ln['lastname'];

}

echo 'id: '.$id.'<br/>';
echo 'nome: '.$nome.'<br/>';
echo 'sobrenome: '.$lastname.'<br/>';?>

Whoever can help me, thank you...

  • Show me how you got the table con_users in the database

  • is like, id int 11 not null Primary key auto increment, name varchar 255 , lastname varchar 255

1 answer

1


According to that reply from Soen you should change the level of rigor of mysqli_report of: MYSQLI_REPORT_ALL for: MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT, so the extension will not report warnings on indices in general.

  • I think he wants to solve the Warnig and not that it stops appearing...

  • This I wanted to solve, but if you tell me that no problem change to MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT I can try?

  • The bank said I ran a query in tablescan, which is a rod through the entire table is the slowest operation. You can set an index for PK and see if Warning goes missing. Unless you are tunning, it is not a problem to omit the index warnings.

  • I even switched to : MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT and it’s already solved, but before you mark your answer as solved, you could answer me if Try and catch errors will be shown normally ?

  • @Guilhermealves, yes it will launch Exception for the other mistakes.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.