CC-5121: fix some SQL statements not being escaped/prepared
This commit is contained in:
parent
3ed106af56
commit
21df9013ee
|
@ -5,9 +5,13 @@ class Application_Common_Database
|
||||||
const COLUMN = 'column';
|
const COLUMN = 'column';
|
||||||
const ALL = 'all';
|
const ALL = 'all';
|
||||||
const EXECUTE = 'execute';
|
const EXECUTE = 'execute';
|
||||||
|
const ROW_COUNT = 'row_count';
|
||||||
|
|
||||||
public static function prepareAndExecute($sql, array $paramValueMap,
|
public static function prepareAndExecute($sql,
|
||||||
$type='all', $fetchType=PDO::FETCH_ASSOC, $con=null)
|
array $paramValueMap = array(),
|
||||||
|
$type=self::ALL,
|
||||||
|
$fetchType=PDO::FETCH_ASSOC,
|
||||||
|
$con=null)
|
||||||
{
|
{
|
||||||
if (is_null($con)) {
|
if (is_null($con)) {
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
|
@ -26,6 +30,8 @@ class Application_Common_Database
|
||||||
$rows = $stmt->fetchAll($fetchType);
|
$rows = $stmt->fetchAll($fetchType);
|
||||||
} else if ($type == self::EXECUTE) {
|
} else if ($type == self::EXECUTE) {
|
||||||
$rows = null;
|
$rows = null;
|
||||||
|
} else if ($type == self::ROW_COUNT) {
|
||||||
|
$rows = $stmt->rowCount();
|
||||||
} else {
|
} else {
|
||||||
$msg = "bad type passed: type($type)";
|
$msg = "bad type passed: type($type)";
|
||||||
throw new Exception("Error: $msg");
|
throw new Exception("Error: $msg");
|
||||||
|
|
Loading…
Reference in New Issue