First commit of updated forums management panel - crossing fingers

git-svn-id: file:///svn/phpbb/trunk@2888 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Ludovic Arnaud 2002-09-15 16:14:35 +00:00
parent 0226e8602a
commit 8d6c391d48
2 changed files with 912 additions and 857 deletions

File diff suppressed because it is too large Load diff

View file

@ -167,32 +167,55 @@ class sql_db
// Idea for this from Ikonboard
function sql_query_array($query = '', $assoc_ary = false, $transaction = false)
{
if ( !is_array($assoc_ary) )
if (!is_array($assoc_ary))
{
return false;
}
if ( strpos(' ' . $query, 'INSERT') == 1 )
if (preg_match('/^INSERT/', $query))
{
$fields = '';
$values = '';
foreach ( $assoc_ary as $key => $var )
$fields = array();
$values = array();
foreach ($assoc_ary as $key => $var)
{
$fields .= ( ( $fields != '' ) ? ', ' : '' ) . $key;
$values .= ( ( $values != '' ) ? ', ' : '' ) . ( ( is_string($var) ) ? '\'' . str_replace('\'', '\'\'', $var) . '\'' : $var );
}
$fields[] = $key;
$query = $query . ' (' . $fields . ') VALUES (' . $values . ')';
if (is_null($var))
{
$values[] = 'NULL';
}
elseif (is_string($var))
{
$values[] = str_replace("'", "''", $var);
}
else
{
$values = '';
foreach ( $assoc_ary as $key => $var )
{
$values .= ( ( $values != '' ) ? ', ' : '' ) . $key . ' = ' . ( ( is_string($var) ) ? '\'' . str_replace('\'', '\'\'', $var) . '\'' : $var );
$values[] = $var;
}
}
$query = preg_replace('/^(.*? SET )(.*?)$/is', '\1' . $values . ' \2', $query);
$query = $query . ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')';
}
else
{
$values = array();
foreach ($assoc_ary as $key => $var)
{
if ($var == NULL)
{
$values[] = "$key = NULL";
}
elseif (is_string($var))
{
$values[] = "$key = '" . str_replace("'", "''", $var) . "'";
}
else
{
$values[] = "$key = $var";
}
}
$query = preg_replace('/^(.*? SET )(.*?)$/is', '\1' . implode(', ', $values) . ' \2', $query);
}
return $this->sql_query($query);