Now search methods accept static calls
This commit is contained in:
+27
-14
@@ -1,33 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace BBOrm;
|
||||
//namespace BBOrm;
|
||||
|
||||
class DBInstance {
|
||||
|
||||
public static function execute($sql, $intance = 'default') {
|
||||
$con = Connections::get_connection('default');
|
||||
$con->exec($sql);
|
||||
public static function execute($sql, $intance = 'default', $data = null) {
|
||||
if ($data) {
|
||||
self::query_prepare($sql, $data, $instance);
|
||||
} else {
|
||||
$con = Connections::get_connection('default');
|
||||
$con->exec($sql);
|
||||
}
|
||||
}
|
||||
|
||||
public static function last_insert($intance = 'default') {
|
||||
$con = Connections::get_connection($intance);
|
||||
return $con->lastInsertId();
|
||||
return $con->lastInsertId();
|
||||
}
|
||||
|
||||
public static function query($sql, $instance = 'default') {
|
||||
$con = Connections::get_connection('default');
|
||||
return $con->query($sql, \PDO::FETCH_OBJ);
|
||||
}
|
||||
|
||||
public static function query_one($sql, $instance = 'default') {
|
||||
$con = Connections::get_connection('default');
|
||||
return $con->query($sql, \PDO::FETCH_OBJ)->fetch();
|
||||
public static function query($sql, $instance = 'default', $data = null) {
|
||||
if ($data) {
|
||||
return self::query_prepare($sql, $data, $instance);
|
||||
} else {
|
||||
$con = Connections::get_connection('default');
|
||||
return $con->query($sql, \PDO::FETCH_OBJ);
|
||||
}
|
||||
}
|
||||
|
||||
public static function query_prepare($sql, $arguments, $instance = 'default'){
|
||||
public static function query_one($sql, $instance = 'default', $data = null) {
|
||||
if ($data) {
|
||||
return self::query_prepare($sql, $data, $instance);
|
||||
} else {
|
||||
$con = Connections::get_connection('default');
|
||||
return $con->query($sql, \PDO::FETCH_OBJ)->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
public static function query_prepare($sql, $arguments, $instance = 'default') {
|
||||
$con = Connections::get_connection('default');
|
||||
$statement = $con->prepare($sql);
|
||||
$statement->execute($arguments);
|
||||
return $statement->fetchAll(\PDO::FETCH_OBJ);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user