|
@@ -4,17 +4,17 @@ namespace BBOrm;
|
|
|
|
|
|
|
|
class DBInstance {
|
|
class DBInstance {
|
|
|
|
|
|
|
|
- public static function execute($sql, $data = null, $intance = 'default') {
|
|
|
|
|
|
|
+ public static function execute($sql, $data = null, $instance = 'default') {
|
|
|
if ($data) {
|
|
if ($data) {
|
|
|
self::query_prepare($sql, $data, $instance);
|
|
self::query_prepare($sql, $data, $instance);
|
|
|
} else {
|
|
} else {
|
|
|
- $con = Connections::get_connection($intance);
|
|
|
|
|
|
|
+ $con = Connections::get_connection($instance);
|
|
|
$con->exec($sql);
|
|
$con->exec($sql);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static function last_insert($intance = 'default') {
|
|
|
|
|
- $con = Connections::get_connection($intance);
|
|
|
|
|
|
|
+ public static function last_insert($instance = 'default') {
|
|
|
|
|
+ $con = Connections::get_connection($instance);
|
|
|
return $con->lastInsertId();
|
|
return $con->lastInsertId();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -22,7 +22,7 @@ class DBInstance {
|
|
|
if ($data) {
|
|
if ($data) {
|
|
|
return self::query_prepare($sql, $data, $instance);
|
|
return self::query_prepare($sql, $data, $instance);
|
|
|
} else {
|
|
} else {
|
|
|
- $con = Connections::get_connection($intance);
|
|
|
|
|
|
|
+ $con = Connections::get_connection($instance);
|
|
|
return $con->query($sql, \PDO::FETCH_OBJ);
|
|
return $con->query($sql, \PDO::FETCH_OBJ);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -31,13 +31,13 @@ class DBInstance {
|
|
|
if ($data) {
|
|
if ($data) {
|
|
|
return self::query_prepare($sql, $data, $instance);
|
|
return self::query_prepare($sql, $data, $instance);
|
|
|
} else {
|
|
} else {
|
|
|
- $con = Connections::get_connection($intance);
|
|
|
|
|
|
|
+ $con = Connections::get_connection($instance);
|
|
|
return $con->query($sql, \PDO::FETCH_OBJ)->fetch();
|
|
return $con->query($sql, \PDO::FETCH_OBJ)->fetch();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static function query_prepare($sql, $data = Array(), $instance = 'default') {
|
|
public static function query_prepare($sql, $data = Array(), $instance = 'default') {
|
|
|
- $con = Connections::get_connection($intance);
|
|
|
|
|
|
|
+ $con = Connections::get_connection($instance);
|
|
|
$statement = $con->prepare($sql);
|
|
$statement = $con->prepare($sql);
|
|
|
$statement->execute($data);
|
|
$statement->execute($data);
|
|
|
return $statement->fetchAll(\PDO::FETCH_OBJ);
|
|
return $statement->fetchAll(\PDO::FETCH_OBJ);
|