【问题标题】:How can I count the numbers of rows that a phalcon query returned?如何计算 phalcon 查询返回的行数?
【发布时间】:2015-03-30 10:29:14
【问题描述】:

如何计算 mysql 查询返回的行数?使用 PHP Phalcon 框架 ..

我的查询

$result = $connection->query("SELECT * FROM robots ORDER BY name");

【问题讨论】:

    标签: php phalcon


    【解决方案1】:

    你可以试试Documentation Here

    $result = $connection->query("SELECT * FROM robots ORDER BY name");
    echo 'There are ', $result->numRows(), ' rows in the resulset';
    

    【讨论】:

      【解决方案2】:
        $result = $connection->query("SELECT * FROM robots ORDER BY name");
        $result->setFetchMode(Phalcon\Db::FETCH_NUM);
      

      参考: http://docs.phalconphp.com/en/latest/api/Phalcon_Db.html

      【讨论】:

        【解决方案3】:
         echo $result->numRows();
         print_r($result->fetchAll());
        

        【讨论】:

          【解决方案4】:

          计算结果集的替代方法

          $result->count();
          

          count($result);
          

          【讨论】:

            【解决方案5】:

            试试

            $result = $connection->query("SELECT * FROM robots ORDER BY name");
            echo $result->numRows();
            

            【讨论】:

              猜你喜欢
              • 2011-07-22
              • 2010-10-11
              • 1970-01-01
              • 1970-01-01
              • 2013-10-03
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多