Because the sql types could be combined it would be better to use a function like this:
function getMySQLType($str){
$str=trim($str);
return strtoupper(substr($str,0,strpos($str,' ')));
}
$sql="select * from user;";
if (getMySQLType($sql) == 'SELECT'){
//true
}
mysqli::rpl_query_type
mysqli_rpl_query_type
(PHP 5)
mysqli::rpl_query_type -- mysqli_rpl_query_type — Devuelve un tipo de consulta RPL
Descripción
Estilo orientado a objetos
int mysqli::rpl_query_type
( string
$query
)Estilo por procedimientos
Devuelve MYSQLI_RPL_MASTER,
MYSQLI_RPL_SLAVE o
MYSQLI_RPL_ADMIN dependiendo del tipo de consulta.
INSERT, UPDATE y similares son
consultas master, SELECT es
slave, y FLUSH,
REPAIR y similares son admin.
Advertencia
Esta función no está documentada actualmente, solamente se encuentra disponible la lista de parámetros.
Advertencia
Esta función ha sido declarada OBSOLETA y ELIMINADA desde PHP 5.3.0.
steohan at gobro dot de ¶
2 years ago
technique-glamour at condenast dot fr ¶
5 years ago
WARNING : this function (or maybe the "enable_rpl_parse" function) randomly causes a segfault into PHP.
We don't use this function anymore. Instead we check if the query contains the word 'SELECT' :
function query_type($query)
{
if ( stripos($query,'SELECT'))
return true;
return false;
}
