mysqli::rpl_query_type
mysqli_rpl_query_type
(PHP 5, PHP 7)
mysqli::rpl_query_type -- mysqli_rpl_query_type — 返回 RPL 查询类型
说明
面向对象风格
mysqli::rpl_query_type ( string$query
) : int
过程化风格
mysqli_rpl_query_type ( mysqli$link
, string $query
) : int
返回 MYSQLI_RPL_MASTER
,
MYSQLI_RPL_SLAVE
或
MYSQLI_RPL_ADMIN
,具体的返回值取决于查询的类型。
INSERT,UPDATE 以及类似的操作属于
主机 查询,SELECT 属于
从机查询,FLUSH 和
REPAIR 以及类似的操作属于 管理 查询。
本函数还未编写文档,仅有参数列表。
Warning自 PHP 5.3.0 起,已经废弃并移除此函数。
User Contributed Notes 2 notes
up down 4 steohan at gobro dot de ¶8 years ago
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
}
up
down
0
technique-glamour at condenast dot fr ¶11 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;
}
add a note
官方地址:https://www.php.net/manual/en/mysqli.rpl-query-type.php