Mysql
 sql >> Database >  >> RDS >> Mysql

Rileva il tipo di dati durante l'utilizzo di fetch_array con MySQLi

Prima di tutto, stai facendo una domanda sbagliata.
In realtà non hai bisogno di un tipo di colonna. In effetti, puoi già distinguere una stringa da un numero con una semplice condizione PHP. Ma nessuno dei due metodi ti dirà NULL .

Prova questo

$sql = "SELECT * FROM users WHERE live = 1";
$stm = $db->prepare($sql) or trigger_error($db->error);
$stm->execute() or trigger_error($db->error);
$res = $stm->get_result();
$row = mysqli_fetch_assoc($res);

Se sei fortunato, avresti tutti i tipi impostati.
In caso contrario, dovrai abilitare mysqlnd in PHP