当前位置: 首页>>代码示例>>PHP>>正文


PHP PDOStatement::rowCount方法代码示例

本文整理汇总了PHP中PDOStatement::rowCount方法的典型用法代码示例。如果您正苦于以下问题:PHP PDOStatement::rowCount方法的具体用法?PHP PDOStatement::rowCount怎么用?PHP PDOStatement::rowCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PDOStatement的用法示例。


在下文中一共展示了PDOStatement::rowCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * @param \PDOStatement $pdoStatement
  * @param string $classname optional
  */
 public function __construct($pdoStatement, $classname = '\\StdClass')
 {
     $this->pdoStatement = $pdoStatement;
     $this->count = $this->pdoStatement->rowCount();
     $this->classname = $classname;
     $this->pdoStatement->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $this->classname);
 }
开发者ID:scandio,项目名称:troba,代码行数:11,代码来源:ResultSet.php

示例2: _fetchAll

 protected function _fetchAll()
 {
     switch ($this->_fetchMode) {
         case self::FETCH_DATAOBJECT:
             self::$_stmt->setFetchMode(PDO::FETCH_ASSOC);
             $rowset = new \SplFixedArray(self::$_stmt->rowCount());
             $rowClass = $this->_fetchArgument;
             foreach (self::$_stmt as $index => $data) {
                 $rowset[$index] = new $rowClass($data, true, $this->_ctorArgs);
             }
             return $rowset;
         case self::FETCH_CLASSFUNC:
             self::$_stmt->setFetchMode(PDO::FETCH_ASSOC);
             $rowset = new \SplFixedArray(self::$_stmt->rowCount());
             $classFunc = $this->_fetchArgument;
             foreach (self::$_stmt as $index => $data) {
                 $rowClass = $classFunc($data);
                 $rowset[$index] = new $rowClass($data, true, $this->_ctorArgs);
             }
             return $rowset;
         default:
             if (isset($this->_ctorArgs)) {
                 return self::$_stmt->fetchAll($this->_fetchMode, $this->_fetchArgument, $this->_ctorArgs);
             }
             if (isset($this->_fetchArgument)) {
                 return self::$_stmt->fetchAll($this->_fetchMode, $this->_fetchArgument);
             }
             if (isset($this->_fetchMode)) {
                 return self::$_stmt->fetchAll($this->_fetchMode);
             }
     }
 }
开发者ID:shen2,项目名称:mypdo,代码行数:32,代码来源:Statement.php

示例3: treat_success

 /**
  * @param PDOStatement $query_result
  */
 private function treat_success($query_result)
 {
     if ($query_result->rowCount() > 1) {
         parent::set_error(1, "Mais de um item foi removido, assim, a remoção foi cancelada.");
         TTransaction::rollback();
     } elseif ($query_result->rowCount() == 0) {
         parent::set_error(1, "Nenhum item foi removido.");
     }
 }
开发者ID:thalelinh,项目名称:MoneyManager,代码行数:12,代码来源:Delete_user.class.php

示例4: getResultList

 /**
  * @param $entityClass
  * @return array
  */
 public function getResultList($entityClass)
 {
     $this->sqlStatement->execute($this->params);
     if ($this->sqlStatement->rowCount() > 0) {
         $entities = array();
         $rows = $this->sqlStatement->fetchAll();
         foreach ($rows as $row) {
             /** @var Entity $entity */
             $entity = new $entityClass($this);
             $entity->init($row);
             array_push($entities, $entity);
         }
         return $entities;
     }
     return array();
 }
开发者ID:abelduarte,项目名称:PHP-EntityManager,代码行数:20,代码来源:EntityQuery.class.php

示例5: affectedRows

 public function affectedRows()
 {
     if (empty($this->lastStatement)) {
         return 0;
     }
     return $this->lastStatement->rowCount();
 }
开发者ID:congaaids,项目名称:silverstripe-framework,代码行数:7,代码来源:PDOConnector.php

示例6: execute

 /**
  * @method execute
  * @param $query|string
  * @return DataBase
  */
 public function execute($query)
 {
     $this->error = false;
     if ($query) {
         if ($this->query = $this->pdo->prepare($this->escapeDoubleSpaces($query))) {
             if (count($this->paramArray)) {
                 foreach ($this->paramArray as $param => $val) {
                     if (is_null($val)) {
                         $var = PDO::PARAM_NULL;
                     } elseif (is_int($val)) {
                         $var = PDO::PARAM_INT;
                     } elseif (is_bool($val)) {
                         $var = PDO::PARAM_BOOL;
                     } else {
                         $var = PDO::PARAM_STR;
                         if ($this->queryType === self::QUERY_TYPE_UPDATE) {
                             $val = $this->wrapInSingleQuotes($val);
                         }
                     }
                     $this->query->bindValue($param, $val, $var);
                 }
                 #End Foreach
             }
             if ($this->query->execute()) {
                 $this->results = $this->query->fetchAll(PDO::FETCH_OBJ);
                 $this->count = $this->query->rowCount();
             } else {
                 $this->error = true;
             }
         }
     }
     $this->reset();
     return $this;
 }
开发者ID:ecne,项目名称:ecne-framework,代码行数:39,代码来源:DataBase.php

示例7: num_rows

 /**
  * Devolvemos la cantidad de filas afectadas por la consulta
  *
  * @todo Ver resultado en algunos tipos de base de datos que no retornan
  * el resultado esperado.
  *
  * @author Ignacio Daniel Rostagno <ignaciorostagno@vijona.com.ar>
  * @return int
  */
 public function num_rows()
 {
     if ($this->cant === NULL) {
         $this->cant = $this->query->rowCount();
     }
     return $this->cant;
 }
开发者ID:4bs4,项目名称:marifa,代码行数:16,代码来源:query.php

示例8: getLastRowCount

 /**
  * @return int
  */
 public function getLastRowCount()
 {
     if (!$this->lastPdoStatement) {
         return null;
     }
     return $this->lastPdoStatement->rowCount();
 }
开发者ID:Jouy,项目名称:domain-model-mapper,代码行数:10,代码来源:DbAdapter.php

示例9: debugger

 private function debugger()
 {
     if ($this->fpdo->debug) {
         if (!is_callable($this->fpdo->debug)) {
             $backtrace = '';
             $query = $this->getQuery();
             $parameters = $this->getParameters();
             $debug = '';
             if ($parameters) {
                 $debug = "# parameters: " . implode(", ", array_map(array($this, 'quote'), $parameters)) . "\n";
             }
             $debug .= $query;
             $pattern = '(^' . preg_quote(dirname(__FILE__)) . '(\\.php$|[/\\\\]))';
             // can be static
             foreach (debug_backtrace() as $backtrace) {
                 if (isset($backtrace["file"]) && !preg_match($pattern, $backtrace["file"])) {
                     // stop on first file outside FluentPDO source codes
                     break;
                 }
             }
             $time = sprintf('%0.3f', $this->time * 1000) . ' ms';
             $rows = $this->result ? $this->result->rowCount() : 0;
             fwrite(STDERR, "# {$backtrace['file']}:{$backtrace['line']} ({$time}; rows = {$rows})\n{$debug}\n\n");
         } else {
             call_user_func($this->fpdo->debug, $this);
         }
     }
 }
开发者ID:peter23,项目名称:fluentpdo,代码行数:28,代码来源:BaseQuery.php

示例10: debugger

 /**
  * Echo/pass a debug string
  */
 private function debugger()
 {
     if ($this->fpdo->debug) {
         if (!is_callable($this->fpdo->debug)) {
             $backtrace = '';
             $query = $this->getQuery();
             $parameters = $this->getParameters();
             $debug = '';
             if ($parameters) {
                 $debug = '# parameters: ' . implode(', ', array_map(array($this, 'quote'), $parameters)) . "\n";
             }
             $debug .= $query;
             $pattern = '(^' . preg_quote(__DIR__) . '(\\.php$|[/\\\\]))';
             // can be static
             foreach (debug_backtrace() as $backtrace) {
                 if (isset($backtrace['file']) && !preg_match($pattern, $backtrace['file'])) {
                     // stop on first file outside FluentPDO source codes
                     break;
                 }
             }
             $time = sprintf('%0.3f', $this->time * 1000) . ' ms';
             $rows = $this->result ? $this->result->rowCount() : 0;
             $finalString = "# {$backtrace['file']}:{$backtrace['line']} ({$time}; rows = {$rows})\n{$debug}\n\n";
             if (is_resource(STDERR)) {
                 // if STDERR is set, send there, otherwise just output the string
                 fwrite(STDERR, $finalString);
             } else {
                 echo $finalString;
             }
         } else {
             call_user_func($this->fpdo->debug, $this);
         }
     }
 }
开发者ID:fpdo,项目名称:fluentpdo,代码行数:37,代码来源:BaseQuery.php

示例11: rowCount

 public function rowCount()
 {
     if ($this->_statement instanceof \PDOStatement) {
         return $this->_statement->rowCount();
     }
     return null;
 }
开发者ID:rtshome,项目名称:pgbabylon,代码行数:7,代码来源:PDOStatement.php

示例12: numRows

 /**
  * Gets number of rows returned by a resulset
  *
  *<code>
  *  $result = $connection->query("SELECT * FROM robots ORDER BY name");
  *  echo 'There are ', $result->numRows(), ' rows in the resulset';
  *</code>
  *
  * @return int
  */
 public function numRows()
 {
     $rowCount = $this->_rowCount;
     if ($rowCount === false) {
         switch ($this->_connection->getType()) {
             case 'mysql':
                 $rowCount = $this->_pdoStatement->rowCount();
                 break;
             case 'pgsql':
                 $rowCount = $this->_pdoStatement->rowCount();
                 break;
         }
         if ($rowCount === false) {
             //SQLite/Oracle/SQLServer returns resultsets that to the client eyes (PDO) has an
             //arbitrary number of rows, so we need to perform an extra count to know that
             $sqlStatement = $this->_sqlStatement;
             //If the sql_statement starts with SELECT COUNT(*) we don't make the count
             if (strpos($sqlStatement, 'SELECT COUNT(*) ') !== 0) {
                 $bindParams = $this->_bindParams;
                 $bindTypes = $this->_bindTypes;
                 $matches = null;
                 if (preg_match("/^SELECT\\s+(.*)\$/i", $sqlStatement, $matches) == true) {
                     $rowCount = $this->_connection->query("SELECT COUNT(*) \"numrows\" FROM (SELECT " . $matches[0] . ')', $bindParams, $bindTypes)->fetch()->numRows();
                 }
             } else {
                 $rowCount = 1;
             }
         }
         //Update the value to avoid further calculations
         $this->_rowCount = $rowCount;
     }
     return $rowCount;
 }
开发者ID:aisuhua,项目名称:phalcon-php,代码行数:43,代码来源:Pdo.php

示例13: getAffectedRows

 /**
  * Returns the number of rows affected by the last SQL statement
  *
  * @return int the number of rows.
  */
 public function getAffectedRows()
 {
     $affectedRows = 0;
     if (!is_null($this->resourceHandle)) {
         $affectedRows = $this->resourceHandle->rowCount();
     }
     return $affectedRows;
 }
开发者ID:clagiordano,项目名称:weblibs-dbabstraction,代码行数:13,代码来源:PDOAdapter.php

示例14:

 /**
  * Get affected rows from last SQL query
  * @return integer
  */
 function affected_rows()
 {
     if ($this->connected !== true || $this->res === null) {
         return false;
     } else {
         return $this->res->rowCount();
     }
 }
开发者ID:noumenia,项目名称:aetolos,代码行数:12,代码来源:databasemariadb.inc.php

示例15: getAffectedRows

	/**
	 * Counts number of affected rows by the last sql statement (INSERT, UPDATE or DELETE).
	 * 
	 * @return	integer		number of affected rows
	 */
	public function getAffectedRows() {
		try {
			return $this->pdoStatement->rowCount();
		}
		catch (\PDOException $e) {
			throw new DatabaseException("Can not fetch affected rows: ".$e->getMessage(), $this);
		}
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:13,代码来源:PreparedStatement.class.php


注:本文中的PDOStatement::rowCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。