Make table and column aliases be quoted identifiers. This
is needed for MSSQL (rowcount is a reserved word), and is
generally just a good idea.
I have tested this on MySql and SQLite. I don't have
MSSQL installed to test on.
Bug: T158766
Change-Id: Ic63f63d208ba6ad15e77eb634e94855ee2728d05
) {
$rows = 0;
$sql = $this->selectSQLText( $tables, '1', $conds, $fname, $options, $join_conds );
- $res = $this->query( "SELECT COUNT(*) AS rowcount FROM ($sql) tmp_count", $fname );
+ // The identifier quotes is primarily for MSSQL.
+ $rowCountCol = $this->addIdentifierQuotes( "rowcount" );
+ $tableName = $this->addIdentifierQuotes( "tmp_count" );
+ $res = $this->query( "SELECT COUNT(*) AS $rowCountCol FROM ($sql) $tableName", $fname );
if ( $res ) {
$row = $this->fetchRow( $res );