// added list of tables and attributes in AdminRequestSqlController + change export request

This commit is contained in:
lLefevre
2011-11-30 13:24:43 +00:00
parent 885701b27a
commit db3feb8df4
3 changed files with 98 additions and 21 deletions
+9 -5
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -138,14 +138,13 @@ class RequestSqlCore extends ObjectModel
if (!$this->checkedLimit($tab['LIMIT']))
return false;
}
if (empty($this->_errors))
if (!Db::getInstance()->executeS($sql))
return false;
return true;
}
public function showTables()
public function getTables()
{
$results = Db::getInstance()->executeS('SHOW TABLES');
foreach ($results as $result)
@@ -156,6 +155,11 @@ class RequestSqlCore extends ObjectModel
return $tables;
}
public function getAttributesByTable($table)
{
return Db::getInstance()->executeS(sprintf('DESCRIBE `%s`', $table));
}
public function cutJoin($attrs, $from)
{
$attrs = explode('=', str_replace(' ', '', $attrs));
@@ -223,7 +227,7 @@ class RequestSqlCore extends ObjectModel
{
if (is_array($table) && (count($table) == 1))
$table = $table[0];
$attributs = Db::getInstance()->executeS(sprintf('DESCRIBE `%s`', $table));
$attributs = $this->getAttributesByTable($table);
foreach ($attributs as $attribut)
if ($attribut['Field'] == trim($attr))
return true;
@@ -258,7 +262,7 @@ class RequestSqlCore extends ObjectModel
for ($i = 0; $i < $nb; $i++)
{
$table = $from[$i];
if (!in_array(str_replace('`', '', $table['table']), $this->showTables()))
if (!in_array(str_replace('`', '', $table['table']), $this->getTables()))
{
$this->error_sql['checkedFrom']['table'] = $table['table'];
return false;