Version 4.0.13.1
This commit is contained in:
1 parent
f9e857d255
commit
c6a86f0d9b
7517 files changed
+597400
-668041
No files matched your search
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Binding Class for Prepared Statements
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Db;
|
||||
|
||||
if( !defined( 'IPS\\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
die( "Unauthorized Access" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Binding Class for Prepared Statements
|
||||
*/
|
||||
class _Bind
|
||||
{
|
||||
/**
|
||||
* @brief Values
|
||||
*/
|
||||
public $values = array();
|
||||
|
||||
/**
|
||||
* @brief Types
|
||||
*/
|
||||
protected $types = '';
|
||||
|
||||
/**
|
||||
* Add value
|
||||
*
|
||||
* @param string $type Type
|
||||
* @param mixed $value Value
|
||||
* @return void
|
||||
*/
|
||||
public function add( $type, $value )
|
||||
{
|
||||
$this->values[] = $value;
|
||||
$this->types .= $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do we have any bound values?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function haveBinds()
|
||||
{
|
||||
return !( empty( $this->values ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array to pass to mysqli_stmt::bind_param
|
||||
*
|
||||
* @see <a href='http://php.net/manual/en/mysqli-stmt.bind-param.php'>mysqli_stmt::bind_param</a>
|
||||
* @return array
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
$values = array();
|
||||
foreach ( $this->values as $k => $v )
|
||||
{
|
||||
$values[ $k ] = &$this->values[ $k ];
|
||||
}
|
||||
|
||||
return array_merge( array( $this->types ), $values );
|
||||
}
|
||||
}
|
||||
+2196
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Exception class for database errors
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Db;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception class for database errors
|
||||
*/
|
||||
class _Exception extends \RuntimeException
|
||||
{
|
||||
/**
|
||||
* @brief Query
|
||||
*/
|
||||
public $query;
|
||||
|
||||
/**
|
||||
* @brief Binds
|
||||
*/
|
||||
public $binds = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $message MySQL Error message
|
||||
* @param int $code MySQL Error Code
|
||||
* @param \Exception|NULL $previous Previous Exception
|
||||
* @param string|NULL $query MySQL Query that caused exception
|
||||
* @param array $binds Binds for query
|
||||
* @return void
|
||||
* @see <a href='https://bugs.php.net/bug.php?id=30471'>Recursion "bug" with var_export()</a>
|
||||
*/
|
||||
public function __construct( $message = null, $code = 0, $previous = null, $query=NULL, $binds=array() )
|
||||
{
|
||||
$this->query = $query;
|
||||
$this->binds = $binds;
|
||||
|
||||
if ( \IPS\Dispatcher::hasInstance() and \IPS\Dispatcher::i()->controllerLocation !== 'setup' )
|
||||
{
|
||||
$log = array( $message );
|
||||
|
||||
if ( ! empty( $query ) )
|
||||
{
|
||||
$log[] = $query;
|
||||
}
|
||||
|
||||
if ( count( $binds ) )
|
||||
{
|
||||
$log[] = print_r( $binds, TRUE );
|
||||
}
|
||||
|
||||
$backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS );
|
||||
$_error_string = '';
|
||||
|
||||
if ( count( $backtrace ) )
|
||||
{
|
||||
$_error_string = "\n | File | Function | Line No. |";
|
||||
$_error_string .= "\n |----------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------|";
|
||||
|
||||
foreach( $backtrace as $i => $data )
|
||||
{
|
||||
if ( !isset( $data['file'] ) )
|
||||
{
|
||||
$data['file'] = '';
|
||||
}
|
||||
|
||||
if ( !isset( $data['line'] ) )
|
||||
{
|
||||
$data['line'] = '';
|
||||
}
|
||||
|
||||
if ( !isset( $data['class'] ) )
|
||||
{
|
||||
$data['class'] = '';
|
||||
}
|
||||
|
||||
if ( defined('IPS\\ROOT_PATH') )
|
||||
{
|
||||
$data['file'] = str_replace( \IPS\ROOT_PATH, '', $data['file'] );
|
||||
}
|
||||
|
||||
/* Reset */
|
||||
$data['func'] = "[" . $data['class'] . '].' . $data['function'];
|
||||
|
||||
/* Pad right */
|
||||
$data['file'] = str_pad( $data['file'], 75 );
|
||||
$data['func'] = str_pad( $data['func'], 78 );
|
||||
$data['line'] = str_pad( $data['line'], 18 );
|
||||
|
||||
$_error_string .= "\n | " . $data['file'] . "| " . $data['func'] . '| ' . $data['line'] . '|';
|
||||
$_error_string .= "\n '----------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------'";
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( ( $this->isServerError() ? LOG_EMERG : LOG_ERR ) )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( implode( "\n", $log ) . $_error_string, 'sql' );
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
}
|
||||
|
||||
return parent::__construct( $message, $code, $previous );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a server issue?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isServerError()
|
||||
{
|
||||
/* Low-end server errors */
|
||||
if ( $this->getCode() < 1046 or in_array( $this->getCode(), array( 1129, 1130, 1194, 1195, 1203 ) ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Low-end client errors */
|
||||
if ( $this->getCode() >= 2000 and $this->getCode() < 2029 )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,545 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Database SELECT Statement
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 28 Aug 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Db;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Database SELECT Statement
|
||||
*/
|
||||
class _Select implements \Iterator, \Countable
|
||||
{
|
||||
/**
|
||||
* @brief The query
|
||||
*/
|
||||
public $query;
|
||||
|
||||
/**
|
||||
* @brief Non-JOIN Binds
|
||||
*/
|
||||
public $binds = array();
|
||||
|
||||
/**
|
||||
* @brief JOIN Binds (need to separate them because the JOIN clauses come before the WHERE clause)
|
||||
*/
|
||||
protected $joinBinds = array();
|
||||
|
||||
/**
|
||||
* @brief The database object
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* @brief The statement
|
||||
*/
|
||||
protected $stmt;
|
||||
|
||||
/**
|
||||
* @brief If TRUE, will return the result as a multidimensional array, with each joined table separately
|
||||
*/
|
||||
protected $multiDimensional = FALSE;
|
||||
|
||||
/**
|
||||
* Constuctor
|
||||
*
|
||||
* @param string $query The query
|
||||
* @param array $binds Binds
|
||||
* @param \IPS\Db $db The database object
|
||||
* @param bool $multiDimensional If TRUE, will return the result as a multidimensional array, with each joined table separately
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $query, array $binds, \IPS\Db $db, $multiDimensional = FALSE )
|
||||
{
|
||||
$this->query = $query;
|
||||
$this->binds = $binds;
|
||||
$this->db = $db;
|
||||
$this->multiDimensional = $multiDimensional;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the query
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force an index
|
||||
*
|
||||
* @param string $index Index name to force
|
||||
* @return \IPS\Db\Select
|
||||
*/
|
||||
public function forceIndex( $index )
|
||||
{
|
||||
$this->query = preg_replace( '/(FROM `(.+?)`( AS `(.+?)`)?)/', "$1 FORCE INDEX(`" . $index . "`)", $this->query );
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Join
|
||||
*
|
||||
* @param array|string|\IPS\Db\Select $table The table to select from. Either (string) table_name or (array) ( name, alias ) or \IPS\Db\Select object
|
||||
* @param mixed $on The on clause for the join
|
||||
* @param string $type Type of join (left, right, inner, cross, straight_join)
|
||||
* @param bool $using Whether to append the using clause for the join
|
||||
* @return \IPS\Db\Select
|
||||
*/
|
||||
public function join( $table, $on, $type='LEFT', $using=FALSE )
|
||||
{
|
||||
$query = '';
|
||||
$joinConditionIsOptional = TRUE;
|
||||
|
||||
switch ( $type )
|
||||
{
|
||||
case 'INNER':
|
||||
case 'CROSS':
|
||||
$query .= 'INNER JOIN ';
|
||||
break;
|
||||
|
||||
case 'STRAIGHT_JOIN':
|
||||
$query .= 'STRAIGHT_JOIN';
|
||||
if ( $using )
|
||||
{
|
||||
throw new \InvalidArgumentException; // USING cannot be used with STRAIGHT_JOIN
|
||||
}
|
||||
break;
|
||||
|
||||
case 'LEFT':
|
||||
case 'RIGHT':
|
||||
$query .= $type . ' JOIN';
|
||||
$joinConditionIsOptional = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $table instanceof \IPS\Db\Select )
|
||||
{
|
||||
$tableQuery = $table->query;
|
||||
preg_match( '/FROM `(.+?)`( AS `(.+?)`)?/', $tableQuery, $matches );
|
||||
|
||||
if ( isset( $matches[2] ) )
|
||||
{
|
||||
$query .= "( " . str_replace( $matches[2], '', $tableQuery ) . " ) AS `{$matches[3]}`";
|
||||
}
|
||||
else
|
||||
{
|
||||
$query .= "( {$tableQuery} ) AS `{$matches[1]}`";
|
||||
}
|
||||
}
|
||||
elseif ( is_array( $table ) )
|
||||
{
|
||||
$query .= " `{$this->db->prefix}{$table[0]}` AS `{$table[1]}`";
|
||||
}
|
||||
else
|
||||
{
|
||||
$query .= $this->db->prefix ? " `{$this->db->prefix}{$table}` AS `{$table}`" : " `{$table}`";
|
||||
}
|
||||
|
||||
if ( $on )
|
||||
{
|
||||
if ( $using )
|
||||
{
|
||||
$query .= ' USING ( ' . implode( ', ', array_map( function( $col )
|
||||
{
|
||||
return '`' . $col . '`';
|
||||
}, $on ) ) . ' ) ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = $this->db->compileWhereClause( $on );
|
||||
$query .= ' ON ' . $where['clause'];
|
||||
foreach ( $where['binds'] as $bind )
|
||||
{
|
||||
$this->joinBinds[] = $bind;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ( !$joinConditionIsOptional )
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
}
|
||||
|
||||
if ( mb_strstr( $this->query, 'UNION' ) )
|
||||
{
|
||||
$this->query = str_replace( 'derivedTable', "derivedTable {$query}", $this->query );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->query = preg_replace( '/(WHERE|GROUP BY|HAVING|LIMIT|ORDER BY|$)/', $query . ' $1', $this->query, 1 );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Columns in the resultset
|
||||
*/
|
||||
protected $columns = array();
|
||||
|
||||
/**
|
||||
* @brief Key Field
|
||||
*/
|
||||
protected $keyField = NULL;
|
||||
|
||||
/**
|
||||
* @brief Key Table
|
||||
*/
|
||||
protected $keyTable = NULL;
|
||||
|
||||
/**
|
||||
* @brief Value Field
|
||||
*/
|
||||
protected $valueField = NULL;
|
||||
|
||||
/**
|
||||
* @brief Value Table
|
||||
*/
|
||||
protected $valueTable = NULL;
|
||||
|
||||
/**
|
||||
* @brief Are we at the beginning?
|
||||
*/
|
||||
protected $rewound = FALSE;
|
||||
|
||||
/**
|
||||
* Set key field
|
||||
*
|
||||
* @param string $column Column to treat as the key
|
||||
* @param string|NULL $table The table, if this is a multidimensional select
|
||||
* @return \IPS\Db\Select
|
||||
*/
|
||||
public function setKeyField( $column, $table=NULL )
|
||||
{
|
||||
if ( !$this->stmt )
|
||||
{
|
||||
$this->runQuery();
|
||||
}
|
||||
|
||||
if ( is_string( $column ) )
|
||||
{
|
||||
if ( $this->multiDimensional )
|
||||
{
|
||||
if ( !isset( $this->columns[ $table ] ) or !in_array( $column, $this->columns[ $table ] ) )
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !in_array( $column, $this->columns ) )
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->keyField = $column;
|
||||
$this->keyTable = $table;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value field
|
||||
*
|
||||
* @param string|callback $column Column to treat as the value. Callback to determine on a per-row basis.
|
||||
* @param string|NULL $table The table, if this is a multidimensional select
|
||||
* @return \IPS\Db\Select
|
||||
*/
|
||||
public function setValueField( $column, $table=NULL )
|
||||
{
|
||||
if ( !$this->stmt )
|
||||
{
|
||||
$this->runQuery();
|
||||
}
|
||||
|
||||
if ( is_string( $column ) )
|
||||
{
|
||||
if ( $this->multiDimensional )
|
||||
{
|
||||
if ( !isset( $this->columns[ $table ] ) or !in_array( $column, $this->columns[ $table ] ) )
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !in_array( $column, $this->columns ) )
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->valueField = $column;
|
||||
$this->valueTable = $table;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The current row
|
||||
*/
|
||||
protected $row;
|
||||
|
||||
/**
|
||||
* @brief The current key
|
||||
*/
|
||||
protected $key;
|
||||
|
||||
/**
|
||||
* Get first record
|
||||
*
|
||||
* @return array
|
||||
* @throws \OutOfRangeException
|
||||
*/
|
||||
public function first()
|
||||
{
|
||||
if ( !$this->rewound )
|
||||
{
|
||||
$this->rewind();
|
||||
}
|
||||
if ( !$this->valid() )
|
||||
{
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
return $this->current();
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the query
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function runQuery()
|
||||
{
|
||||
/* Run the query */
|
||||
$this->stmt = $this->db->preparedQuery( $this->query, array_merge( $this->joinBinds, $this->binds ) );
|
||||
|
||||
/* Populate $this->row which we read into */
|
||||
$this->row = array();
|
||||
$params = array();
|
||||
$meta = $this->stmt->result_metadata();
|
||||
while ( $field = $meta->fetch_field() )
|
||||
{
|
||||
if ( $this->multiDimensional )
|
||||
{
|
||||
$params[] = &$this->row[ $field->table ][ $field->name ];
|
||||
}
|
||||
else
|
||||
{
|
||||
$params[] = &$this->row[ $field->name ];
|
||||
}
|
||||
}
|
||||
|
||||
$meta->free_result();
|
||||
|
||||
if ( $this->multiDimensional )
|
||||
{
|
||||
foreach ( $this->row as $table => $columns )
|
||||
{
|
||||
$this->columns[ $table ] = array_keys( $columns );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->columns = array_keys( $this->row );
|
||||
}
|
||||
|
||||
call_user_func_array( array( $this->stmt, 'bind_result' ), $params );
|
||||
|
||||
/* Set counts */
|
||||
if ( mb_strpos( $this->query, 'SQL_CALC_FOUND_ROWS' ) !== FALSE )
|
||||
{
|
||||
$count = $this->db->query( 'SELECT FOUND_ROWS() AS count;' )->fetch_assoc();
|
||||
$this->totalCount = $count['count'];
|
||||
}
|
||||
$this->count = $this->stmt->num_rows;
|
||||
|
||||
/* Note that the query has just been ran */
|
||||
$this->rewound = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Iterator] Rewind - will (re-)execute statement
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
/* Run the query */
|
||||
if ( !$this->rewound )
|
||||
{
|
||||
$this->runQuery();
|
||||
}
|
||||
|
||||
/* Get the first result */
|
||||
$this->key = -1;
|
||||
$this->next();
|
||||
}
|
||||
|
||||
/**
|
||||
* [Iterator] Get current row
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
if ( $this->valueField )
|
||||
{
|
||||
if ( !is_string( $this->valueField ) and is_callable( $this->valueField ) )
|
||||
{
|
||||
return call_user_func( $this->valueField, $this->row );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $this->valueTable )
|
||||
{
|
||||
return $this->row[ $this->valueTable ][ $this->valueField ];
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->row[ $this->valueField ];
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ( count( $this->row ) === 1 )
|
||||
{
|
||||
foreach ( $this->row as $v )
|
||||
{
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$row = array();
|
||||
foreach ( $this->row as $k => $v )
|
||||
{
|
||||
if ( is_array( $v ) )
|
||||
{
|
||||
foreach ( $v as $k2 => $v2 )
|
||||
{
|
||||
$row[ $k ][ $k2 ] = $v2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$row[ $k ] = $v;
|
||||
}
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [Iterator] Get current key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
if ( $this->keyField )
|
||||
{
|
||||
if ( is_string( $this->keyField ) )
|
||||
{
|
||||
if ( $this->keyTable )
|
||||
{
|
||||
return $this->row[ $this->keyTable ][ $this->keyField ];
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->row[ $this->keyField ];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return call_user_func( $this->keyField, $this->row );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [Iterator] Fetch next result
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
$this->rewound = FALSE;
|
||||
|
||||
$fetch = $this->stmt->fetch();
|
||||
if ( $fetch === NULL )
|
||||
{
|
||||
$this->row = NULL;
|
||||
}
|
||||
$this->key++;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Iterator] Is the current row valid?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return ( $this->row !== NULL );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Number of rows in this set
|
||||
*/
|
||||
protected $count;
|
||||
|
||||
/**
|
||||
* @brief Number of rows in total, ignoring LIMIT
|
||||
*/
|
||||
protected $totalCount;
|
||||
|
||||
/**
|
||||
* [Countable] Get number of rows
|
||||
*
|
||||
* @param bool $allRows If TRUE, will get the number of rows ignoring the limit. In order for this to work, the query must have been ran with SQL_CALC_FOUND_ROWS
|
||||
* @return int
|
||||
*/
|
||||
public function count( $allRows = FALSE )
|
||||
{
|
||||
if ( !$this->stmt )
|
||||
{
|
||||
$this->runQuery();
|
||||
}
|
||||
|
||||
if ( $allRows )
|
||||
{
|
||||
if ( $this->totalCount === NULL )
|
||||
{
|
||||
throw new \IPS\Db\Exception( "Total count attempted on a query not ran with SQL_CALC_FOUND_ROWS", -100, NULL, $this->query, array_merge( $this->joinBinds, $this->binds ) );
|
||||
}
|
||||
return $this->totalCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->count;
|
||||
}
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
Reference in new issue
Block a user