first commit

This commit is contained in:
2026-04-30 14:38:11 +02:00
commit e22bbde336
1994 changed files with 613950 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
class Database extends Database_Core
{
public function __construct($config = array())
{
parent::__construct($config);
}
/**
* Selects the column names for a database query.
*
* @param string string or array of column names to select
* @return Database_Core This Database object.
*/
public function select($sql = '*')
{
if (func_num_args() > 1)
{
$sql = func_get_args();
}
elseif (is_string($sql))
{
$sql = explode(',', $sql);
}
else
{
$sql = (array) $sql;
}
foreach ($sql as $val)
{
if (($val = trim($val)) === '') continue;
if (strpos($val, '(') === FALSE AND $val !== '*')
{
if (preg_match('/^DISTINCT\s++(.+)$/i', $val, $matches))
{
// Only prepend with table prefix if table name is specified
$val = (strpos($matches[1], '.') !== FALSE) ? $this->config['table_prefix'].$matches[1] : $matches[1];
$this->distinct = TRUE;
}
else
{
$val = (strpos($val, '.') !== FALSE) ? $this->config['table_prefix'].$val : $val;
}
$val = $this->driver->escape_column($val);
}
# RK: table_prefix & escape_column for COUNT($value) AS $alias
if (stripos($val, 'count(') !== FALSE AND stripos($val, 'count(*)') === FALSE)
{
$val = preg_replace('/(count|COUNT)\((.+)\)/','$2', $val);
$val = (strpos($val, '.') !== FALSE) ? $this->config['table_prefix'].$val : $val;
$val = $this->driver->escape_column($val);
if(stripos($val, ' AS ') !== FALSE)
{
list($column, $alias) = explode(' AS ', $val);
$val = "COUNT($column) AS $alias";
}
else
{
$val = "COUNT($val)";
}
}
$this->select[] = $val;
}
return $this;
}
}