@@ -1,52 +1,52 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | requireComponents("Adapters"); |
| 3 | 3 | class Connection { |
| 4 | - public $database; |
|
| 5 | - public $info; |
|
| 6 | - public function __construct( $_object ) { |
|
| 7 | - if(!is_object($_object)) |
|
| 8 | - throw new JException("Parameter must be an object."); |
|
| 9 | - $this->setConnection( |
|
| 10 | - $_object->server, |
|
| 11 | - $_object->database, |
|
| 12 | - $_object->user, |
|
| 13 | - $_object->password, |
|
| 14 | - $this->getConnectionType($_object->engine) |
|
| 15 | - ); |
|
| 16 | - } |
|
| 17 | - protected function setConnection ( $_srv, $_db, $_usr, $_pass, $_type ) { |
|
| 18 | - switch ($_type) { |
|
| 19 | - case "mysqli": |
|
| 20 | - $this->database = new MysqliAdapter($_srv, $_db, $_usr, $_pass); |
|
| 21 | - break; |
|
| 22 | - case "postgresql": |
|
| 23 | - $this->database = new PostgresqlAdapter($_srv, $_db, $_usr, $_pass); |
|
| 24 | - break; |
|
| 25 | - case "pdo-sqlite-memory": |
|
| 26 | - $this->database = new PdoAdapterSqLiteMemory($_srv, $_db, $_usr, $_pass); |
|
| 27 | - break; |
|
| 28 | - case "pdo-sqlite-file": |
|
| 29 | - $this->database = new PdoAdapterSqLiteFile($_srv, $_db, $_usr, $_pass); |
|
| 30 | - break; |
|
| 31 | - case "pdo-mysql": |
|
| 32 | - default: |
|
| 33 | - $this->database = new PdoAdapterMysql($_srv, $_db, $_usr, $_pass); |
|
| 34 | - break; |
|
| 35 | - } |
|
| 36 | - $this->info = [ |
|
| 37 | - "srv" => $_srv, |
|
| 38 | - "db" => $_db, |
|
| 39 | - "usr" => $_usr, |
|
| 40 | - "pass" => $_pass, |
|
| 41 | - "type" => $_type |
|
| 42 | - ]; |
|
| 43 | - } |
|
| 44 | - protected function getConnectionType( $_type ) { |
|
| 45 | - $array = (array)$_type; |
|
| 46 | - foreach ($array as $key => $value) |
|
| 47 | - if($value) |
|
| 48 | - return $key; |
|
| 49 | - return "default"; |
|
| 50 | - } |
|
| 4 | + public $database; |
|
| 5 | + public $info; |
|
| 6 | + public function __construct( $_object ) { |
|
| 7 | + if(!is_object($_object)) |
|
| 8 | + throw new JException("Parameter must be an object."); |
|
| 9 | + $this->setConnection( |
|
| 10 | + $_object->server, |
|
| 11 | + $_object->database, |
|
| 12 | + $_object->user, |
|
| 13 | + $_object->password, |
|
| 14 | + $this->getConnectionType($_object->engine) |
|
| 15 | + ); |
|
| 16 | + } |
|
| 17 | + protected function setConnection ( $_srv, $_db, $_usr, $_pass, $_type ) { |
|
| 18 | + switch ($_type) { |
|
| 19 | + case "mysqli": |
|
| 20 | + $this->database = new MysqliAdapter($_srv, $_db, $_usr, $_pass); |
|
| 21 | + break; |
|
| 22 | + case "postgresql": |
|
| 23 | + $this->database = new PostgresqlAdapter($_srv, $_db, $_usr, $_pass); |
|
| 24 | + break; |
|
| 25 | + case "pdo-sqlite-memory": |
|
| 26 | + $this->database = new PdoAdapterSqLiteMemory($_srv, $_db, $_usr, $_pass); |
|
| 27 | + break; |
|
| 28 | + case "pdo-sqlite-file": |
|
| 29 | + $this->database = new PdoAdapterSqLiteFile($_srv, $_db, $_usr, $_pass); |
|
| 30 | + break; |
|
| 31 | + case "pdo-mysql": |
|
| 32 | + default: |
|
| 33 | + $this->database = new PdoAdapterMysql($_srv, $_db, $_usr, $_pass); |
|
| 34 | + break; |
|
| 35 | + } |
|
| 36 | + $this->info = [ |
|
| 37 | + "srv" => $_srv, |
|
| 38 | + "db" => $_db, |
|
| 39 | + "usr" => $_usr, |
|
| 40 | + "pass" => $_pass, |
|
| 41 | + "type" => $_type |
|
| 42 | + ]; |
|
| 43 | + } |
|
| 44 | + protected function getConnectionType( $_type ) { |
|
| 45 | + $array = (array)$_type; |
|
| 46 | + foreach ($array as $key => $value) |
|
| 47 | + if($value) |
|
| 48 | + return $key; |
|
| 49 | + return "default"; |
|
| 50 | + } |
|
| 51 | 51 | } |
| 52 | 52 | ?> |
@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | class Connection { |
| 4 | 4 | public $database; |
| 5 | 5 | public $info; |
| 6 | - public function __construct( $_object ) { |
|
| 7 | - if(!is_object($_object)) |
|
| 6 | + public function __construct($_object) { |
|
| 7 | + if (!is_object($_object)) |
|
| 8 | 8 | throw new JException("Parameter must be an object."); |
| 9 | 9 | $this->setConnection( |
| 10 | 10 | $_object->server, |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | $this->getConnectionType($_object->engine) |
| 15 | 15 | ); |
| 16 | 16 | } |
| 17 | - protected function setConnection ( $_srv, $_db, $_usr, $_pass, $_type ) { |
|
| 17 | + protected function setConnection($_srv, $_db, $_usr, $_pass, $_type) { |
|
| 18 | 18 | switch ($_type) { |
| 19 | 19 | case "mysqli": |
| 20 | 20 | $this->database = new MysqliAdapter($_srv, $_db, $_usr, $_pass); |
@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | "type" => $_type |
| 42 | 42 | ]; |
| 43 | 43 | } |
| 44 | - protected function getConnectionType( $_type ) { |
|
| 45 | - $array = (array)$_type; |
|
| 44 | + protected function getConnectionType($_type) { |
|
| 45 | + $array = (array) $_type; |
|
| 46 | 46 | foreach ($array as $key => $value) |
| 47 | - if($value) |
|
| 47 | + if ($value) |
|
| 48 | 48 | return $key; |
| 49 | 49 | return "default"; |
| 50 | 50 | } |
@@ -4,8 +4,9 @@ discard block |
||
| 4 | 4 | public $database; |
| 5 | 5 | public $info; |
| 6 | 6 | public function __construct( $_object ) { |
| 7 | - if(!is_object($_object)) |
|
| 8 | - throw new JException("Parameter must be an object."); |
|
| 7 | + if(!is_object($_object)) { |
|
| 8 | + throw new JException("Parameter must be an object."); |
|
| 9 | + } |
|
| 9 | 10 | $this->setConnection( |
| 10 | 11 | $_object->server, |
| 11 | 12 | $_object->database, |
@@ -43,9 +44,10 @@ discard block |
||
| 43 | 44 | } |
| 44 | 45 | protected function getConnectionType( $_type ) { |
| 45 | 46 | $array = (array)$_type; |
| 46 | - foreach ($array as $key => $value) |
|
| 47 | - if($value) |
|
| 47 | + foreach ($array as $key => $value) { |
|
| 48 | + if($value) |
|
| 48 | 49 | return $key; |
| 50 | + } |
|
| 49 | 51 | return "default"; |
| 50 | 52 | } |
| 51 | 53 | } |
@@ -2,44 +2,44 @@ |
||
| 2 | 2 | jRequire("../Query/Query.php"); |
| 3 | 3 | jRequire("../File/File.php"); |
| 4 | 4 | class Module { |
| 5 | - use Query { |
|
| 6 | - Query::__construct as private __queryConstruct; |
|
| 7 | - } |
|
| 8 | - use File { |
|
| 9 | - File::__construct as private __fileConstruct; |
|
| 10 | - } |
|
| 11 | - public $name; |
|
| 12 | - public $modules; |
|
| 13 | - public function __construct() { |
|
| 14 | - $this->name = get_class($this); |
|
| 15 | - $this->modules = []; |
|
| 16 | - $this->__queryConstruct(); |
|
| 17 | - $this->__fileConstruct(); |
|
| 18 | - } |
|
| 19 | - public function addModules( $_modules ) { |
|
| 20 | - if(!is_array($_modules)) |
|
| 21 | - throw new JException("Parameter must be an array."); |
|
| 22 | - foreach ($_modules as $value) |
|
| 23 | - $this->addModule($value); |
|
| 24 | - } |
|
| 25 | - public function addModule( $_module ) { |
|
| 26 | - if(!is_object($_module)) |
|
| 27 | - throw new JException("Parameter must be a object."); |
|
| 28 | - if(! is_subclass_of ($_module, "Module")) |
|
| 29 | - throw new JException("Parameter must be a object inherited from Module object."); |
|
| 30 | - $this->modules[$_module->name] = $_module; |
|
| 31 | - if($this->currentConnection) |
|
| 32 | - $this->modules[$_module->name]->addConnectionMan($this->currentConnection); |
|
| 33 | - } |
|
| 34 | - public function addConnectionMan( $_connection, $_name = "default") { |
|
| 35 | - try { |
|
| 36 | - parent::addConnectionMan($_connection, $_name); |
|
| 37 | - foreach ($this->modules as &$module) |
|
| 38 | - if(isset($this->currentConnection)) |
|
| 39 | - $module->addConnectionMan($this->currentConnection, $_name); |
|
| 40 | - } catch (Exception $e) { |
|
| 41 | - throw new JException($e->getMessage(), 1); |
|
| 42 | - } |
|
| 43 | - } |
|
| 5 | + use Query { |
|
| 6 | + Query::__construct as private __queryConstruct; |
|
| 7 | + } |
|
| 8 | + use File { |
|
| 9 | + File::__construct as private __fileConstruct; |
|
| 10 | + } |
|
| 11 | + public $name; |
|
| 12 | + public $modules; |
|
| 13 | + public function __construct() { |
|
| 14 | + $this->name = get_class($this); |
|
| 15 | + $this->modules = []; |
|
| 16 | + $this->__queryConstruct(); |
|
| 17 | + $this->__fileConstruct(); |
|
| 18 | + } |
|
| 19 | + public function addModules( $_modules ) { |
|
| 20 | + if(!is_array($_modules)) |
|
| 21 | + throw new JException("Parameter must be an array."); |
|
| 22 | + foreach ($_modules as $value) |
|
| 23 | + $this->addModule($value); |
|
| 24 | + } |
|
| 25 | + public function addModule( $_module ) { |
|
| 26 | + if(!is_object($_module)) |
|
| 27 | + throw new JException("Parameter must be a object."); |
|
| 28 | + if(! is_subclass_of ($_module, "Module")) |
|
| 29 | + throw new JException("Parameter must be a object inherited from Module object."); |
|
| 30 | + $this->modules[$_module->name] = $_module; |
|
| 31 | + if($this->currentConnection) |
|
| 32 | + $this->modules[$_module->name]->addConnectionMan($this->currentConnection); |
|
| 33 | + } |
|
| 34 | + public function addConnectionMan( $_connection, $_name = "default") { |
|
| 35 | + try { |
|
| 36 | + parent::addConnectionMan($_connection, $_name); |
|
| 37 | + foreach ($this->modules as &$module) |
|
| 38 | + if(isset($this->currentConnection)) |
|
| 39 | + $module->addConnectionMan($this->currentConnection, $_name); |
|
| 40 | + } catch (Exception $e) { |
|
| 41 | + throw new JException($e->getMessage(), 1); |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | } |
| 45 | 45 | ?> |
@@ -16,26 +16,26 @@ |
||
| 16 | 16 | $this->__queryConstruct(); |
| 17 | 17 | $this->__fileConstruct(); |
| 18 | 18 | } |
| 19 | - public function addModules( $_modules ) { |
|
| 20 | - if(!is_array($_modules)) |
|
| 19 | + public function addModules($_modules) { |
|
| 20 | + if (!is_array($_modules)) |
|
| 21 | 21 | throw new JException("Parameter must be an array."); |
| 22 | 22 | foreach ($_modules as $value) |
| 23 | 23 | $this->addModule($value); |
| 24 | 24 | } |
| 25 | - public function addModule( $_module ) { |
|
| 26 | - if(!is_object($_module)) |
|
| 25 | + public function addModule($_module) { |
|
| 26 | + if (!is_object($_module)) |
|
| 27 | 27 | throw new JException("Parameter must be a object."); |
| 28 | - if(! is_subclass_of ($_module, "Module")) |
|
| 28 | + if (!is_subclass_of($_module, "Module")) |
|
| 29 | 29 | throw new JException("Parameter must be a object inherited from Module object."); |
| 30 | 30 | $this->modules[$_module->name] = $_module; |
| 31 | - if($this->currentConnection) |
|
| 31 | + if ($this->currentConnection) |
|
| 32 | 32 | $this->modules[$_module->name]->addConnectionMan($this->currentConnection); |
| 33 | 33 | } |
| 34 | - public function addConnectionMan( $_connection, $_name = "default") { |
|
| 34 | + public function addConnectionMan($_connection, $_name = "default") { |
|
| 35 | 35 | try { |
| 36 | 36 | parent::addConnectionMan($_connection, $_name); |
| 37 | 37 | foreach ($this->modules as &$module) |
| 38 | - if(isset($this->currentConnection)) |
|
| 38 | + if (isset($this->currentConnection)) |
|
| 39 | 39 | $module->addConnectionMan($this->currentConnection, $_name); |
| 40 | 40 | } catch (Exception $e) { |
| 41 | 41 | throw new JException($e->getMessage(), 1); |
@@ -17,26 +17,32 @@ |
||
| 17 | 17 | $this->__fileConstruct(); |
| 18 | 18 | } |
| 19 | 19 | public function addModules( $_modules ) { |
| 20 | - if(!is_array($_modules)) |
|
| 21 | - throw new JException("Parameter must be an array."); |
|
| 22 | - foreach ($_modules as $value) |
|
| 23 | - $this->addModule($value); |
|
| 20 | + if(!is_array($_modules)) { |
|
| 21 | + throw new JException("Parameter must be an array."); |
|
| 22 | + } |
|
| 23 | + foreach ($_modules as $value) { |
|
| 24 | + $this->addModule($value); |
|
| 25 | + } |
|
| 24 | 26 | } |
| 25 | 27 | public function addModule( $_module ) { |
| 26 | - if(!is_object($_module)) |
|
| 27 | - throw new JException("Parameter must be a object."); |
|
| 28 | - if(! is_subclass_of ($_module, "Module")) |
|
| 29 | - throw new JException("Parameter must be a object inherited from Module object."); |
|
| 28 | + if(!is_object($_module)) { |
|
| 29 | + throw new JException("Parameter must be a object."); |
|
| 30 | + } |
|
| 31 | + if(! is_subclass_of ($_module, "Module")) { |
|
| 32 | + throw new JException("Parameter must be a object inherited from Module object."); |
|
| 33 | + } |
|
| 30 | 34 | $this->modules[$_module->name] = $_module; |
| 31 | - if($this->currentConnection) |
|
| 32 | - $this->modules[$_module->name]->addConnectionMan($this->currentConnection); |
|
| 35 | + if($this->currentConnection) { |
|
| 36 | + $this->modules[$_module->name]->addConnectionMan($this->currentConnection); |
|
| 37 | + } |
|
| 33 | 38 | } |
| 34 | 39 | public function addConnectionMan( $_connection, $_name = "default") { |
| 35 | 40 | try { |
| 36 | 41 | parent::addConnectionMan($_connection, $_name); |
| 37 | - foreach ($this->modules as &$module) |
|
| 38 | - if(isset($this->currentConnection)) |
|
| 42 | + foreach ($this->modules as &$module) { |
|
| 43 | + if(isset($this->currentConnection)) |
|
| 39 | 44 | $module->addConnectionMan($this->currentConnection, $_name); |
| 45 | + } |
|
| 40 | 46 | } catch (Exception $e) { |
| 41 | 47 | throw new JException($e->getMessage(), 1); |
| 42 | 48 | } |
@@ -3,101 +3,101 @@ |
||
| 3 | 3 | jRequire("../JConfig/JConfig.php"); |
| 4 | 4 | jRequire("../Connection/Connection.php"); |
| 5 | 5 | trait Query { |
| 6 | - public $connection; |
|
| 7 | - public $currentConnection; |
|
| 8 | - public function __construct() { |
|
| 9 | - $this->connection = []; |
|
| 10 | - $this->currentConnection = null; |
|
| 11 | - } |
|
| 12 | - public function addConnection( $_path, $_name = "default" ) { |
|
| 13 | - if(!is_string($_path)) |
|
| 14 | - throw new JException("Parameter must be a string.", 1); |
|
| 15 | - try { |
|
| 16 | - $jConfig = new JConfig($_path); |
|
| 17 | - if($jConfig->enable) { |
|
| 18 | - $connection = new Connection($jConfig); |
|
| 19 | - $this->addConnectionMan($connection, $_name); |
|
| 20 | - } |
|
| 21 | - } catch (Exception $e) { |
|
| 22 | - throw new JException($e->getMessage(), 1); |
|
| 23 | - } |
|
| 24 | - } |
|
| 25 | - public function addConnectionMan( $_connection, $_name = "default") { |
|
| 26 | - if(!is_object($_connection) || !is_a($_connection, "Connection")) |
|
| 27 | - throw new JException("Parameter must be a Connection object.", 1); |
|
| 28 | - try { |
|
| 29 | - $this->connection["$_name"] = $_connection; |
|
| 30 | - $this->currentConnection = $_connection; |
|
| 31 | - } catch (Exception $e) { |
|
| 32 | - throw new JException($e->getMessage(), 1); |
|
| 33 | - } |
|
| 34 | - } |
|
| 35 | - public function setConnection( $_name = "default" ) { |
|
| 36 | - if(!is_string($_name)) |
|
| 37 | - throw new JException("Parameter must be a string.", 1); |
|
| 38 | - if(!isset($this->connection["$_name"])) |
|
| 39 | - throw new JException("This connection name does not exist.", 1); |
|
| 40 | - $this->currentConnection = $this->connection["$_name"]; |
|
| 41 | - } |
|
| 42 | - public function query( $_query ) { |
|
| 43 | - if(!is_string($_query)) |
|
| 44 | - throw new JException("Parameter must be a string.", 1); |
|
| 45 | - if($this->currentConnection == null) |
|
| 46 | - throw new JException("No connection selected.", 1); |
|
| 47 | - try { |
|
| 48 | - $temp = $this->currentConnection->database->query($_query); |
|
| 49 | - } catch (Exception $e) { |
|
| 50 | - throw new JException($e->getMessage(), 1); |
|
| 51 | - } |
|
| 52 | - return $temp; |
|
| 53 | - } |
|
| 54 | - public function queryInsert( $_query ) { |
|
| 55 | - if(!is_string($_query)) |
|
| 56 | - throw new JException("Parameter must be a string.", 1); |
|
| 57 | - if($this->currentConnection == null) |
|
| 58 | - throw new JException("No connection selected.", 1); |
|
| 59 | - try { |
|
| 60 | - $temp = $this->currentConnection->database->queryInsert($_query); |
|
| 61 | - } catch (Exception $e) { |
|
| 62 | - throw new JException($e->getMessage(), 1); |
|
| 63 | - } |
|
| 64 | - return $temp; |
|
| 65 | - } |
|
| 66 | - public function queryFetch( $_query ) { |
|
| 67 | - if(!is_string($_query)) |
|
| 68 | - throw new JException("Parameter must be a string.", 1); |
|
| 69 | - if($this->currentConnection == null) |
|
| 70 | - throw new JException("No connection selected.", 1); |
|
| 71 | - try { |
|
| 72 | - $temp = $this->currentConnection->database->queryFetch($_query); |
|
| 73 | - } catch (Exception $e) { |
|
| 74 | - throw new JException($e->getMessage(), 1); |
|
| 75 | - } |
|
| 76 | - return $temp; |
|
| 77 | - } |
|
| 78 | - public function queryArray( $_query ) { |
|
| 79 | - if(!is_string($_query)) |
|
| 80 | - throw new JException("Parameter must be a string.", 1); |
|
| 81 | - if($this->currentConnection == null) |
|
| 82 | - throw new JException("No connection selected.", 1); |
|
| 83 | - try { |
|
| 84 | - $temp = $this->currentConnection->database->queryArray($_query); |
|
| 85 | - } catch (Exception $e) { |
|
| 86 | - throw new JException($e->getMessage(), 1); |
|
| 87 | - } |
|
| 88 | - return $temp; |
|
| 89 | - } |
|
| 90 | - public function newTable( $_query ) { |
|
| 91 | - if(!is_string($_query)) |
|
| 92 | - throw new JException("Parameter must be a string.", 1); |
|
| 93 | - if($this->currentConnection == null) |
|
| 94 | - throw new JException("No connection selected.", 1); |
|
| 95 | - try { |
|
| 96 | - $temp = $this->currentConnection->database->newTable($_query); |
|
| 97 | - } catch (Exception $e) { |
|
| 98 | - throw new JException($e->getMessage(), 1); |
|
| 99 | - } |
|
| 100 | - return $temp; |
|
| 101 | - } |
|
| 6 | + public $connection; |
|
| 7 | + public $currentConnection; |
|
| 8 | + public function __construct() { |
|
| 9 | + $this->connection = []; |
|
| 10 | + $this->currentConnection = null; |
|
| 11 | + } |
|
| 12 | + public function addConnection( $_path, $_name = "default" ) { |
|
| 13 | + if(!is_string($_path)) |
|
| 14 | + throw new JException("Parameter must be a string.", 1); |
|
| 15 | + try { |
|
| 16 | + $jConfig = new JConfig($_path); |
|
| 17 | + if($jConfig->enable) { |
|
| 18 | + $connection = new Connection($jConfig); |
|
| 19 | + $this->addConnectionMan($connection, $_name); |
|
| 20 | + } |
|
| 21 | + } catch (Exception $e) { |
|
| 22 | + throw new JException($e->getMessage(), 1); |
|
| 23 | + } |
|
| 24 | + } |
|
| 25 | + public function addConnectionMan( $_connection, $_name = "default") { |
|
| 26 | + if(!is_object($_connection) || !is_a($_connection, "Connection")) |
|
| 27 | + throw new JException("Parameter must be a Connection object.", 1); |
|
| 28 | + try { |
|
| 29 | + $this->connection["$_name"] = $_connection; |
|
| 30 | + $this->currentConnection = $_connection; |
|
| 31 | + } catch (Exception $e) { |
|
| 32 | + throw new JException($e->getMessage(), 1); |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | + public function setConnection( $_name = "default" ) { |
|
| 36 | + if(!is_string($_name)) |
|
| 37 | + throw new JException("Parameter must be a string.", 1); |
|
| 38 | + if(!isset($this->connection["$_name"])) |
|
| 39 | + throw new JException("This connection name does not exist.", 1); |
|
| 40 | + $this->currentConnection = $this->connection["$_name"]; |
|
| 41 | + } |
|
| 42 | + public function query( $_query ) { |
|
| 43 | + if(!is_string($_query)) |
|
| 44 | + throw new JException("Parameter must be a string.", 1); |
|
| 45 | + if($this->currentConnection == null) |
|
| 46 | + throw new JException("No connection selected.", 1); |
|
| 47 | + try { |
|
| 48 | + $temp = $this->currentConnection->database->query($_query); |
|
| 49 | + } catch (Exception $e) { |
|
| 50 | + throw new JException($e->getMessage(), 1); |
|
| 51 | + } |
|
| 52 | + return $temp; |
|
| 53 | + } |
|
| 54 | + public function queryInsert( $_query ) { |
|
| 55 | + if(!is_string($_query)) |
|
| 56 | + throw new JException("Parameter must be a string.", 1); |
|
| 57 | + if($this->currentConnection == null) |
|
| 58 | + throw new JException("No connection selected.", 1); |
|
| 59 | + try { |
|
| 60 | + $temp = $this->currentConnection->database->queryInsert($_query); |
|
| 61 | + } catch (Exception $e) { |
|
| 62 | + throw new JException($e->getMessage(), 1); |
|
| 63 | + } |
|
| 64 | + return $temp; |
|
| 65 | + } |
|
| 66 | + public function queryFetch( $_query ) { |
|
| 67 | + if(!is_string($_query)) |
|
| 68 | + throw new JException("Parameter must be a string.", 1); |
|
| 69 | + if($this->currentConnection == null) |
|
| 70 | + throw new JException("No connection selected.", 1); |
|
| 71 | + try { |
|
| 72 | + $temp = $this->currentConnection->database->queryFetch($_query); |
|
| 73 | + } catch (Exception $e) { |
|
| 74 | + throw new JException($e->getMessage(), 1); |
|
| 75 | + } |
|
| 76 | + return $temp; |
|
| 77 | + } |
|
| 78 | + public function queryArray( $_query ) { |
|
| 79 | + if(!is_string($_query)) |
|
| 80 | + throw new JException("Parameter must be a string.", 1); |
|
| 81 | + if($this->currentConnection == null) |
|
| 82 | + throw new JException("No connection selected.", 1); |
|
| 83 | + try { |
|
| 84 | + $temp = $this->currentConnection->database->queryArray($_query); |
|
| 85 | + } catch (Exception $e) { |
|
| 86 | + throw new JException($e->getMessage(), 1); |
|
| 87 | + } |
|
| 88 | + return $temp; |
|
| 89 | + } |
|
| 90 | + public function newTable( $_query ) { |
|
| 91 | + if(!is_string($_query)) |
|
| 92 | + throw new JException("Parameter must be a string.", 1); |
|
| 93 | + if($this->currentConnection == null) |
|
| 94 | + throw new JException("No connection selected.", 1); |
|
| 95 | + try { |
|
| 96 | + $temp = $this->currentConnection->database->newTable($_query); |
|
| 97 | + } catch (Exception $e) { |
|
| 98 | + throw new JException($e->getMessage(), 1); |
|
| 99 | + } |
|
| 100 | + return $temp; |
|
| 101 | + } |
|
| 102 | 102 | } |
| 103 | 103 | ?> |
@@ -9,12 +9,12 @@ discard block |
||
| 9 | 9 | $this->connection = []; |
| 10 | 10 | $this->currentConnection = null; |
| 11 | 11 | } |
| 12 | - public function addConnection( $_path, $_name = "default" ) { |
|
| 13 | - if(!is_string($_path)) |
|
| 12 | + public function addConnection($_path, $_name = "default") { |
|
| 13 | + if (!is_string($_path)) |
|
| 14 | 14 | throw new JException("Parameter must be a string.", 1); |
| 15 | 15 | try { |
| 16 | 16 | $jConfig = new JConfig($_path); |
| 17 | - if($jConfig->enable) { |
|
| 17 | + if ($jConfig->enable) { |
|
| 18 | 18 | $connection = new Connection($jConfig); |
| 19 | 19 | $this->addConnectionMan($connection, $_name); |
| 20 | 20 | } |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | throw new JException($e->getMessage(), 1); |
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | - public function addConnectionMan( $_connection, $_name = "default") { |
|
| 26 | - if(!is_object($_connection) || !is_a($_connection, "Connection")) |
|
| 25 | + public function addConnectionMan($_connection, $_name = "default") { |
|
| 26 | + if (!is_object($_connection) || !is_a($_connection, "Connection")) |
|
| 27 | 27 | throw new JException("Parameter must be a Connection object.", 1); |
| 28 | 28 | try { |
| 29 | 29 | $this->connection["$_name"] = $_connection; |
@@ -32,17 +32,17 @@ discard block |
||
| 32 | 32 | throw new JException($e->getMessage(), 1); |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | - public function setConnection( $_name = "default" ) { |
|
| 36 | - if(!is_string($_name)) |
|
| 35 | + public function setConnection($_name = "default") { |
|
| 36 | + if (!is_string($_name)) |
|
| 37 | 37 | throw new JException("Parameter must be a string.", 1); |
| 38 | - if(!isset($this->connection["$_name"])) |
|
| 38 | + if (!isset($this->connection["$_name"])) |
|
| 39 | 39 | throw new JException("This connection name does not exist.", 1); |
| 40 | 40 | $this->currentConnection = $this->connection["$_name"]; |
| 41 | 41 | } |
| 42 | - public function query( $_query ) { |
|
| 43 | - if(!is_string($_query)) |
|
| 42 | + public function query($_query) { |
|
| 43 | + if (!is_string($_query)) |
|
| 44 | 44 | throw new JException("Parameter must be a string.", 1); |
| 45 | - if($this->currentConnection == null) |
|
| 45 | + if ($this->currentConnection == null) |
|
| 46 | 46 | throw new JException("No connection selected.", 1); |
| 47 | 47 | try { |
| 48 | 48 | $temp = $this->currentConnection->database->query($_query); |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | return $temp; |
| 53 | 53 | } |
| 54 | - public function queryInsert( $_query ) { |
|
| 55 | - if(!is_string($_query)) |
|
| 54 | + public function queryInsert($_query) { |
|
| 55 | + if (!is_string($_query)) |
|
| 56 | 56 | throw new JException("Parameter must be a string.", 1); |
| 57 | - if($this->currentConnection == null) |
|
| 57 | + if ($this->currentConnection == null) |
|
| 58 | 58 | throw new JException("No connection selected.", 1); |
| 59 | 59 | try { |
| 60 | 60 | $temp = $this->currentConnection->database->queryInsert($_query); |
@@ -63,10 +63,10 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | return $temp; |
| 65 | 65 | } |
| 66 | - public function queryFetch( $_query ) { |
|
| 67 | - if(!is_string($_query)) |
|
| 66 | + public function queryFetch($_query) { |
|
| 67 | + if (!is_string($_query)) |
|
| 68 | 68 | throw new JException("Parameter must be a string.", 1); |
| 69 | - if($this->currentConnection == null) |
|
| 69 | + if ($this->currentConnection == null) |
|
| 70 | 70 | throw new JException("No connection selected.", 1); |
| 71 | 71 | try { |
| 72 | 72 | $temp = $this->currentConnection->database->queryFetch($_query); |
@@ -75,10 +75,10 @@ discard block |
||
| 75 | 75 | } |
| 76 | 76 | return $temp; |
| 77 | 77 | } |
| 78 | - public function queryArray( $_query ) { |
|
| 79 | - if(!is_string($_query)) |
|
| 78 | + public function queryArray($_query) { |
|
| 79 | + if (!is_string($_query)) |
|
| 80 | 80 | throw new JException("Parameter must be a string.", 1); |
| 81 | - if($this->currentConnection == null) |
|
| 81 | + if ($this->currentConnection == null) |
|
| 82 | 82 | throw new JException("No connection selected.", 1); |
| 83 | 83 | try { |
| 84 | 84 | $temp = $this->currentConnection->database->queryArray($_query); |
@@ -87,10 +87,10 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | return $temp; |
| 89 | 89 | } |
| 90 | - public function newTable( $_query ) { |
|
| 91 | - if(!is_string($_query)) |
|
| 90 | + public function newTable($_query) { |
|
| 91 | + if (!is_string($_query)) |
|
| 92 | 92 | throw new JException("Parameter must be a string.", 1); |
| 93 | - if($this->currentConnection == null) |
|
| 93 | + if ($this->currentConnection == null) |
|
| 94 | 94 | throw new JException("No connection selected.", 1); |
| 95 | 95 | try { |
| 96 | 96 | $temp = $this->currentConnection->database->newTable($_query); |
@@ -10,8 +10,9 @@ discard block |
||
| 10 | 10 | $this->currentConnection = null; |
| 11 | 11 | } |
| 12 | 12 | public function addConnection( $_path, $_name = "default" ) { |
| 13 | - if(!is_string($_path)) |
|
| 14 | - throw new JException("Parameter must be a string.", 1); |
|
| 13 | + if(!is_string($_path)) { |
|
| 14 | + throw new JException("Parameter must be a string.", 1); |
|
| 15 | + } |
|
| 15 | 16 | try { |
| 16 | 17 | $jConfig = new JConfig($_path); |
| 17 | 18 | if($jConfig->enable) { |
@@ -23,8 +24,9 @@ discard block |
||
| 23 | 24 | } |
| 24 | 25 | } |
| 25 | 26 | public function addConnectionMan( $_connection, $_name = "default") { |
| 26 | - if(!is_object($_connection) || !is_a($_connection, "Connection")) |
|
| 27 | - throw new JException("Parameter must be a Connection object.", 1); |
|
| 27 | + if(!is_object($_connection) || !is_a($_connection, "Connection")) { |
|
| 28 | + throw new JException("Parameter must be a Connection object.", 1); |
|
| 29 | + } |
|
| 28 | 30 | try { |
| 29 | 31 | $this->connection["$_name"] = $_connection; |
| 30 | 32 | $this->currentConnection = $_connection; |
@@ -33,17 +35,21 @@ discard block |
||
| 33 | 35 | } |
| 34 | 36 | } |
| 35 | 37 | public function setConnection( $_name = "default" ) { |
| 36 | - if(!is_string($_name)) |
|
| 37 | - throw new JException("Parameter must be a string.", 1); |
|
| 38 | - if(!isset($this->connection["$_name"])) |
|
| 39 | - throw new JException("This connection name does not exist.", 1); |
|
| 38 | + if(!is_string($_name)) { |
|
| 39 | + throw new JException("Parameter must be a string.", 1); |
|
| 40 | + } |
|
| 41 | + if(!isset($this->connection["$_name"])) { |
|
| 42 | + throw new JException("This connection name does not exist.", 1); |
|
| 43 | + } |
|
| 40 | 44 | $this->currentConnection = $this->connection["$_name"]; |
| 41 | 45 | } |
| 42 | 46 | public function query( $_query ) { |
| 43 | - if(!is_string($_query)) |
|
| 44 | - throw new JException("Parameter must be a string.", 1); |
|
| 45 | - if($this->currentConnection == null) |
|
| 46 | - throw new JException("No connection selected.", 1); |
|
| 47 | + if(!is_string($_query)) { |
|
| 48 | + throw new JException("Parameter must be a string.", 1); |
|
| 49 | + } |
|
| 50 | + if($this->currentConnection == null) { |
|
| 51 | + throw new JException("No connection selected.", 1); |
|
| 52 | + } |
|
| 47 | 53 | try { |
| 48 | 54 | $temp = $this->currentConnection->database->query($_query); |
| 49 | 55 | } catch (Exception $e) { |
@@ -52,10 +58,12 @@ discard block |
||
| 52 | 58 | return $temp; |
| 53 | 59 | } |
| 54 | 60 | public function queryInsert( $_query ) { |
| 55 | - if(!is_string($_query)) |
|
| 56 | - throw new JException("Parameter must be a string.", 1); |
|
| 57 | - if($this->currentConnection == null) |
|
| 58 | - throw new JException("No connection selected.", 1); |
|
| 61 | + if(!is_string($_query)) { |
|
| 62 | + throw new JException("Parameter must be a string.", 1); |
|
| 63 | + } |
|
| 64 | + if($this->currentConnection == null) { |
|
| 65 | + throw new JException("No connection selected.", 1); |
|
| 66 | + } |
|
| 59 | 67 | try { |
| 60 | 68 | $temp = $this->currentConnection->database->queryInsert($_query); |
| 61 | 69 | } catch (Exception $e) { |
@@ -64,10 +72,12 @@ discard block |
||
| 64 | 72 | return $temp; |
| 65 | 73 | } |
| 66 | 74 | public function queryFetch( $_query ) { |
| 67 | - if(!is_string($_query)) |
|
| 68 | - throw new JException("Parameter must be a string.", 1); |
|
| 69 | - if($this->currentConnection == null) |
|
| 70 | - throw new JException("No connection selected.", 1); |
|
| 75 | + if(!is_string($_query)) { |
|
| 76 | + throw new JException("Parameter must be a string.", 1); |
|
| 77 | + } |
|
| 78 | + if($this->currentConnection == null) { |
|
| 79 | + throw new JException("No connection selected.", 1); |
|
| 80 | + } |
|
| 71 | 81 | try { |
| 72 | 82 | $temp = $this->currentConnection->database->queryFetch($_query); |
| 73 | 83 | } catch (Exception $e) { |
@@ -76,10 +86,12 @@ discard block |
||
| 76 | 86 | return $temp; |
| 77 | 87 | } |
| 78 | 88 | public function queryArray( $_query ) { |
| 79 | - if(!is_string($_query)) |
|
| 80 | - throw new JException("Parameter must be a string.", 1); |
|
| 81 | - if($this->currentConnection == null) |
|
| 82 | - throw new JException("No connection selected.", 1); |
|
| 89 | + if(!is_string($_query)) { |
|
| 90 | + throw new JException("Parameter must be a string.", 1); |
|
| 91 | + } |
|
| 92 | + if($this->currentConnection == null) { |
|
| 93 | + throw new JException("No connection selected.", 1); |
|
| 94 | + } |
|
| 83 | 95 | try { |
| 84 | 96 | $temp = $this->currentConnection->database->queryArray($_query); |
| 85 | 97 | } catch (Exception $e) { |
@@ -88,10 +100,12 @@ discard block |
||
| 88 | 100 | return $temp; |
| 89 | 101 | } |
| 90 | 102 | public function newTable( $_query ) { |
| 91 | - if(!is_string($_query)) |
|
| 92 | - throw new JException("Parameter must be a string.", 1); |
|
| 93 | - if($this->currentConnection == null) |
|
| 94 | - throw new JException("No connection selected.", 1); |
|
| 103 | + if(!is_string($_query)) { |
|
| 104 | + throw new JException("Parameter must be a string.", 1); |
|
| 105 | + } |
|
| 106 | + if($this->currentConnection == null) { |
|
| 107 | + throw new JException("No connection selected.", 1); |
|
| 108 | + } |
|
| 95 | 109 | try { |
| 96 | 110 | $temp = $this->currentConnection->database->newTable($_query); |
| 97 | 111 | } catch (Exception $e) { |