CC-4345: Prepared statements - part 1
-added extra parameter to prepareAndExecute()
This commit is contained in:
parent
0ae1b9fea6
commit
26c2c2c0d1
|
@ -1,9 +1,8 @@
|
|||
<?php
|
||||
class Application_Common_Database
|
||||
{
|
||||
public static function prepareAndExecute($sql, $paramValueMap, $type='all', $fetchType=PDO::FETCH_ASSOC){
|
||||
|
||||
public static function prepareAndExecute($sql, $paramValueMap, $type='all')
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
$stmt = $con->prepare($sql);
|
||||
foreach ($paramValueMap as $param => $v) {
|
||||
|
@ -12,11 +11,11 @@ class Application_Common_Database
|
|||
$rows = array();
|
||||
if ($stmt->execute()) {
|
||||
if ($type == 'single') {
|
||||
$rows = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
} elseif ($type == 'column'){
|
||||
$rows = $stmt->fetch($fetchType);
|
||||
} else if ($type == 'column'){
|
||||
$rows = $stmt->fetchColumn();
|
||||
} else {
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$rows = $stmt->fetchAll($fetchType);
|
||||
}
|
||||
} else {
|
||||
$msg = implode(',', $stmt->errorInfo());
|
||||
|
|
Loading…
Reference in New Issue