CC-4346: Prepared statements - part 2
- CRLF - adding include in bootstrap
This commit is contained in:
parent
15b9d09991
commit
326ba012c1
|
@ -19,6 +19,7 @@ require_once __DIR__."/configs/constants.php";
|
||||||
require_once 'Preference.php';
|
require_once 'Preference.php';
|
||||||
require_once "DateHelper.php";
|
require_once "DateHelper.php";
|
||||||
require_once "OsPath.php";
|
require_once "OsPath.php";
|
||||||
|
require_once "Database.php";
|
||||||
require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php';
|
require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php';
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
class Application_Common_Database{
|
class Application_Common_Database{
|
||||||
public static function prepareAndExcute($sql, $paramValueMap, $type='all'){
|
public static function prepareAndExcute($sql, $paramValueMap, $type='all'){
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$stmt = $con->prepare($sql);
|
$stmt = $con->prepare($sql);
|
||||||
foreach ($paramValueMap as $param => $v) {
|
foreach ($paramValueMap as $param => $v) {
|
||||||
$stmt->bindValue($param, $v);
|
$stmt->bindValue($param, $v);
|
||||||
}
|
}
|
||||||
$rows = array();
|
$rows = array();
|
||||||
if ($stmt->execute()) {
|
if ($stmt->execute()) {
|
||||||
if ($type == 'single') {
|
if ($type == 'single') {
|
||||||
$rows = $stmt->fetch(PDO::FETCH_ASSOC);
|
$rows = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
@ -14,10 +14,10 @@ class Application_Common_Database{
|
||||||
$rows = $stmt->fetchColumn();
|
$rows = $stmt->fetchColumn();
|
||||||
} else {
|
} else {
|
||||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$msg = implode(',', $stmt->errorInfo());
|
$msg = implode(',', $stmt->errorInfo());
|
||||||
throw new Exception("Error: $msg");
|
throw new Exception("Error: $msg");
|
||||||
}
|
}
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue