1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-20 07:21:30 +02:00

I hope nothing broke!

- Added a query builder, it is currently only used for complex queries that involve a FROM clause with two tables and a left join
- Changed some function calls in the DBAL
- Made the viewtopic queries nicer


git-svn-id: file:///svn/phpbb/trunk@5885 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
David M
2006-05-05 22:06:17 +00:00
parent b6ffae82b9
commit 3d2a45ab04
19 changed files with 529 additions and 173 deletions

View File

@@ -191,6 +191,67 @@ class dbal
return $query;
}
/**
* Build sql statement from array for select and select distinct statements
*
* Possible query values: SELECT, SELECT_DISTINCT
*/
function sql_build_query($query, $array)
{
$sql = '';
switch ($query)
{
case 'SELECT':
case 'SELECT_DISTINCT';
if ($query == 'SELECT_DISTINCT')
{
$sql .= 'SELECT DISTINCT';
}
else
{
$sql .= 'SELECT';
}
$sql .= ' ' . $array['SELECT'];
$sql .= ' FROM ';
$table_array = array();
foreach ($array['FROM'] as $table_name => $alias)
{
$table_array[] = $table_name . ' ' . $alias;
}
$sql .= $this->_sql_custom_build('FROM', implode(', ', $table_array));
if (!empty($array['LEFT_JOIN']))
{
foreach ($array['LEFT_JOIN'] as $join)
{
$sql .= ' LEFT JOIN ' . key($join['FROM']) . ' ' . current($join['FROM']) . ' ON (' . $join['ON'] . ')';
}
}
if (!empty($array['WHERE']))
{
$sql .= ' WHERE ' . $this->_sql_custom_build('WHERE', $array['WHERE']);
}
if (!empty($array['GROUP_BY']))
{
$sql .= ' GROUP BY ' . $array['GROUP_BY'];
}
if (!empty($array['ORDER_BY']))
{
$sql .= ' ORDER BY ' . $array['ORDER_BY'];
}
break;
}
return $sql;
}
/**
* display sql error page
*/