• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • mysqli::rpl_query_type()

    (PHP 5, PHP 7)

    返回 RPL 查询类型

    说明

    面向对象风格
    mysqli::rpl_query_type(string $query): int
    过程化风格
    mysqli_rpl_query_type(mysqli$link,string $query): int

    返回MYSQLI_RPL_MASTERMYSQLI_RPL_SLAVEMYSQLI_RPL_ADMIN,具体的返回值取决于查询的类型。INSERTUPDATE以及类似的操作属于主机查询,SELECT属于从机查询,FLUSHREPAIR以及类似的操作属于管理查询。

    Warning

    本函数还未编写文档,仅有参数列表。

    Warning

    自 PHP 5.3.0起,已经废弃移除此函数。

    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
    }
    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;
    }