phpBB

Code Changes

File: phpbb/search/fulltext_native.php

  Unmodified   Added   Modified   Removed
Line 253Line 253
						$keywords[$i] = ' ';
break;
case '-':

						$keywords[$i] = ' ';
break;
case '-':

 
						// Ignore hyphen if followed by a space
if (isset($keywords[$i + 1]) && $keywords[$i + 1] == ' ')
{
$keywords[$i] = ' ';
}
else
{
$space = $keywords[$i];
}
break;

					case '+':
$space = $keywords[$i];
break;

					case '+':
$space = $keywords[$i];
break;

Line 898Line 908
			switch ($this->db->get_sql_layer())
{
case 'mysqli':

			switch ($this->db->get_sql_layer())
{
case 'mysqli':


// 3.x does not support SQL_CALC_FOUND_ROWS
// $sql_array['SELECT'] = 'SQL_CALC_FOUND_ROWS ' . $sql_array['SELECT'];

 
					$is_mysql = true;

break;

					$is_mysql = true;

break;

Line 956Line 963
				'FROM'	=> array(TOPICS_TABLE => 't'),
'ON' => 'p.topic_id = t.topic_id'
);

				'FROM'	=> array(TOPICS_TABLE => 't'),
'ON' => 'p.topic_id = t.topic_id'
);

		}

// if using mysql and the total result count is not calculated yet, get it from the db
if (!$total_results && $is_mysql)
{
// Also count rows for the query as if there was not LIMIT. Add SQL_CALC_FOUND_ROWS to SQL
$sql_array['SELECT'] = 'SQL_CALC_FOUND_ROWS ' . $sql_array['SELECT'];

 
		}

$sql_array['WHERE'] = implode(' AND ', $sql_where);
$sql_array['GROUP_BY'] = ($group_by) ? (($type == 'posts') ? 'p.post_id' : 'p.topic_id') . ', ' . $sort_by_sql[$sort_key] : '';
$sql_array['ORDER_BY'] = $sql_sort;

		}

$sql_array['WHERE'] = implode(' AND ', $sql_where);
$sql_array['GROUP_BY'] = ($group_by) ? (($type == 'posts') ? 'p.post_id' : 'p.topic_id') . ', ' . $sort_by_sql[$sort_key] : '';
$sql_array['ORDER_BY'] = $sql_sort;

 
		$sql_array['SELECT'] .= $sort_by_sql[$sort_key] ? ", {$sort_by_sql[$sort_key]}" : '';


unset($sql_where, $sql_sort, $group_by);



unset($sql_where, $sql_sort, $group_by);


Line 980Line 981
		}
$this->db->sql_freeresult($result);


		}
$this->db->sql_freeresult($result);


 
		// If using mysql and the total result count is not calculated yet, get it from the db

		if (!$total_results && $is_mysql)
{

		if (!$total_results && $is_mysql)
{

			// Get the number of results as calculated by MySQL
$sql_count = 'SELECT FOUND_ROWS() as total_results';

			$sql_count = str_replace("SELECT {$sql_array['SELECT']}", "SELECT COUNT(DISTINCT {$sql_array['SELECT']}) as total_results", $sql);


			$result = $this->db->sql_query($sql_count);
$total_results = (int) $this->db->sql_fetchfield('total_results');
$this->db->sql_freeresult($result);

			$result = $this->db->sql_query($sql_count);
$total_results = (int) $this->db->sql_fetchfield('total_results');
$this->db->sql_freeresult($result);

Line 1005Line 1006
				$id_ary[] = (int) $row[(($type == 'posts') ? 'post_id' : 'topic_id')];
}
$this->db->sql_freeresult($result);

				$id_ary[] = (int) $row[(($type == 'posts') ? 'post_id' : 'topic_id')];
}
$this->db->sql_freeresult($result);



 
		}

// store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page

		}

// store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page

Line 1137Line 1137
		}

$select = ($type == 'posts') ? 'p.post_id' : 't.topic_id';

		}

$select = ($type == 'posts') ? 'p.post_id' : 't.topic_id';

 
		$select .= $sort_by_sql[$sort_key] ? ", {$sort_by_sql[$sort_key]}" : '';

		$is_mysql = false;

/**

		$is_mysql = false;

/**

Line 1192Line 1193
			switch ($this->db->get_sql_layer())
{
case 'mysqli':

			switch ($this->db->get_sql_layer())
{
case 'mysqli':

//					$select = 'SQL_CALC_FOUND_ROWS ' . $select;

 
					$is_mysql = true;
break;


					$is_mysql = true;
break;


Line 1285Line 1285

if (!$total_results && $is_mysql)
{


if (!$total_results && $is_mysql)
{

			// Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it.
$sql_calc = str_replace('SELECT ' . $select, 'SELECT SQL_CALC_FOUND_ROWS ' . $select, $sql);

$result = $this->db->sql_query($sql_calc);
$this->db->sql_freeresult($result);

$sql_count = 'SELECT FOUND_ROWS() as total_results';

			$sql_count = str_replace("SELECT $select", "SELECT COUNT(*) as total_results", $sql);







			$result = $this->db->sql_query($sql_count);

			$result = $this->db->sql_query($sql_count);

			$total_results = (int) $this->db->sql_fetchfield('total_results');

			$total_results = ($type == 'posts') ? (int) $this->db->sql_fetchfield('total_results') : count($this->db->sql_fetchrowset($result));

			$this->db->sql_freeresult($result);

if (!$total_results)

			$this->db->sql_freeresult($result);

if (!$total_results)