should constants instead of literals - only in function for now...
This commit is contained in:
parent
17c3eb1407
commit
92c7c9c951
|
@ -1,6 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
class Application_Common_Database
|
class Application_Common_Database
|
||||||
{
|
{
|
||||||
|
const SINGLE = 'single';
|
||||||
|
const COLUMN = 'column';
|
||||||
|
const ALL = 'all';
|
||||||
|
const EXECUTE = 'execute';
|
||||||
|
|
||||||
public static function prepareAndExecute($sql, array $paramValueMap,
|
public static function prepareAndExecute($sql, array $paramValueMap,
|
||||||
$type='all', $fetchType=PDO::FETCH_ASSOC, $con=null)
|
$type='all', $fetchType=PDO::FETCH_ASSOC, $con=null)
|
||||||
{
|
{
|
||||||
|
@ -13,13 +18,13 @@ class Application_Common_Database
|
||||||
}
|
}
|
||||||
$rows = array();
|
$rows = array();
|
||||||
if ($stmt->execute()) {
|
if ($stmt->execute()) {
|
||||||
if ($type == 'single') {
|
if ($type == self::SINGLE) {
|
||||||
$rows = $stmt->fetch($fetchType);
|
$rows = $stmt->fetch($fetchType);
|
||||||
} else if ($type == 'column'){
|
} else if ($type == self::COLUMN){
|
||||||
$rows = $stmt->fetchColumn();
|
$rows = $stmt->fetchColumn();
|
||||||
} else if ($type == 'all') {
|
} else if ($type == self::ALL) {
|
||||||
$rows = $stmt->fetchAll($fetchType);
|
$rows = $stmt->fetchAll($fetchType);
|
||||||
} else if ($type == 'execute') {
|
} else if ($type == self::EXECUTE) {
|
||||||
$rows = null;
|
$rows = null;
|
||||||
} else {
|
} else {
|
||||||
$msg = "bad type passed: type($type)";
|
$msg = "bad type passed: type($type)";
|
||||||
|
|
Loading…
Reference in New Issue