@@ -1,44 +1,44 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | jRequire("ConnectionInterface.php"); |
| 3 | 3 | class PdoAdapter implements ConnectionAdapterInterface { |
| 4 | - public $connection; |
|
| 5 | - public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
| 6 | - try { |
|
| 7 | - $connection = "mysql:host=$_srv;dbname=$_db"; |
|
| 8 | - $this->connection = new PDO( $connection, $_usr, $_pass, [PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"] ); |
|
| 9 | - } catch( Exception $e ) { |
|
| 10 | - throw new JException($e->getMessage()); |
|
| 11 | - } |
|
| 12 | - } |
|
| 13 | - public function query( $_query ) { |
|
| 14 | - $this->stdQuery($_query); |
|
| 15 | - return true; |
|
| 16 | - } |
|
| 17 | - public function queryInsert( $_query ) { |
|
| 18 | - $this->stdQuery($_query); |
|
| 19 | - return $this->connection->lastInsertId(); |
|
| 20 | - } |
|
| 21 | - public function queryFetch( $_query ) { |
|
| 22 | - $temp = $this->stdQuery($_query); |
|
| 23 | - return $temp->fetchAll(PDO::FETCH_ASSOC); |
|
| 24 | - } |
|
| 25 | - public function queryArray( $_query ) { |
|
| 26 | - $temp = $this->stdQuery($_query); |
|
| 27 | - return $temp->fetchAll(PDO::FETCH_COLUMN, 0); |
|
| 28 | - } |
|
| 29 | - protected function stdQuery( $_query ) { |
|
| 30 | - $database = $this->connection; |
|
| 31 | - $query = $database->prepare($_query); |
|
| 32 | - $result = $query->execute(); |
|
| 33 | - if(!$result) |
|
| 34 | - throw new JException(json_encode([ |
|
| 35 | - "query" => $_query, |
|
| 36 | - "error" => [ |
|
| 37 | - $query->errorInfo(), |
|
| 38 | - $database->errorInfo() |
|
| 39 | - ] |
|
| 40 | - ])); |
|
| 41 | - return $query; |
|
| 42 | - } |
|
| 4 | + public $connection; |
|
| 5 | + public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
| 6 | + try { |
|
| 7 | + $connection = "mysql:host=$_srv;dbname=$_db"; |
|
| 8 | + $this->connection = new PDO( $connection, $_usr, $_pass, [PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"] ); |
|
| 9 | + } catch( Exception $e ) { |
|
| 10 | + throw new JException($e->getMessage()); |
|
| 11 | + } |
|
| 12 | + } |
|
| 13 | + public function query( $_query ) { |
|
| 14 | + $this->stdQuery($_query); |
|
| 15 | + return true; |
|
| 16 | + } |
|
| 17 | + public function queryInsert( $_query ) { |
|
| 18 | + $this->stdQuery($_query); |
|
| 19 | + return $this->connection->lastInsertId(); |
|
| 20 | + } |
|
| 21 | + public function queryFetch( $_query ) { |
|
| 22 | + $temp = $this->stdQuery($_query); |
|
| 23 | + return $temp->fetchAll(PDO::FETCH_ASSOC); |
|
| 24 | + } |
|
| 25 | + public function queryArray( $_query ) { |
|
| 26 | + $temp = $this->stdQuery($_query); |
|
| 27 | + return $temp->fetchAll(PDO::FETCH_COLUMN, 0); |
|
| 28 | + } |
|
| 29 | + protected function stdQuery( $_query ) { |
|
| 30 | + $database = $this->connection; |
|
| 31 | + $query = $database->prepare($_query); |
|
| 32 | + $result = $query->execute(); |
|
| 33 | + if(!$result) |
|
| 34 | + throw new JException(json_encode([ |
|
| 35 | + "query" => $_query, |
|
| 36 | + "error" => [ |
|
| 37 | + $query->errorInfo(), |
|
| 38 | + $database->errorInfo() |
|
| 39 | + ] |
|
| 40 | + ])); |
|
| 41 | + return $query; |
|
| 42 | + } |
|
| 43 | 43 | } |
| 44 | 44 | ?> |
@@ -2,35 +2,35 @@ |
||
| 2 | 2 | jRequire("ConnectionInterface.php"); |
| 3 | 3 | class PdoAdapter implements ConnectionAdapterInterface { |
| 4 | 4 | public $connection; |
| 5 | - public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
| 5 | + public function __construct($_srv, $_db, $_usr, $_pass) { |
|
| 6 | 6 | try { |
| 7 | 7 | $connection = "mysql:host=$_srv;dbname=$_db"; |
| 8 | - $this->connection = new PDO( $connection, $_usr, $_pass, [PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"] ); |
|
| 9 | - } catch( Exception $e ) { |
|
| 8 | + $this->connection = new PDO($connection, $_usr, $_pass, [PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"]); |
|
| 9 | + } catch (Exception $e) { |
|
| 10 | 10 | throw new JException($e->getMessage()); |
| 11 | 11 | } |
| 12 | 12 | } |
| 13 | - public function query( $_query ) { |
|
| 13 | + public function query($_query) { |
|
| 14 | 14 | $this->stdQuery($_query); |
| 15 | 15 | return true; |
| 16 | 16 | } |
| 17 | - public function queryInsert( $_query ) { |
|
| 17 | + public function queryInsert($_query) { |
|
| 18 | 18 | $this->stdQuery($_query); |
| 19 | 19 | return $this->connection->lastInsertId(); |
| 20 | 20 | } |
| 21 | - public function queryFetch( $_query ) { |
|
| 21 | + public function queryFetch($_query) { |
|
| 22 | 22 | $temp = $this->stdQuery($_query); |
| 23 | 23 | return $temp->fetchAll(PDO::FETCH_ASSOC); |
| 24 | 24 | } |
| 25 | - public function queryArray( $_query ) { |
|
| 25 | + public function queryArray($_query) { |
|
| 26 | 26 | $temp = $this->stdQuery($_query); |
| 27 | 27 | return $temp->fetchAll(PDO::FETCH_COLUMN, 0); |
| 28 | 28 | } |
| 29 | - protected function stdQuery( $_query ) { |
|
| 29 | + protected function stdQuery($_query) { |
|
| 30 | 30 | $database = $this->connection; |
| 31 | 31 | $query = $database->prepare($_query); |
| 32 | 32 | $result = $query->execute(); |
| 33 | - if(!$result) |
|
| 33 | + if (!$result) |
|
| 34 | 34 | throw new JException(json_encode([ |
| 35 | 35 | "query" => $_query, |
| 36 | 36 | "error" => [ |
@@ -30,14 +30,15 @@ |
||
| 30 | 30 | $database = $this->connection; |
| 31 | 31 | $query = $database->prepare($_query); |
| 32 | 32 | $result = $query->execute(); |
| 33 | - if(!$result) |
|
| 34 | - throw new JException(json_encode([ |
|
| 33 | + if(!$result) { |
|
| 34 | + throw new JException(json_encode([ |
|
| 35 | 35 | "query" => $_query, |
| 36 | 36 | "error" => [ |
| 37 | 37 | $query->errorInfo(), |
| 38 | 38 | $database->errorInfo() |
| 39 | 39 | ] |
| 40 | 40 | ])); |
| 41 | + } |
|
| 41 | 42 | return $query; |
| 42 | 43 | } |
| 43 | 44 | } |
@@ -1,45 +1,45 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | jRequire("ConnectionInterface.php"); |
| 3 | 3 | class MysqliAdapter implements ConnectionAdapterInterface { |
| 4 | - public $connection; |
|
| 5 | - public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
| 6 | - try { |
|
| 7 | - $this->connection = new mysqli( $_srv, $_usr, $_pass, $_db ); |
|
| 8 | - } catch( Exception $e ) { |
|
| 9 | - throw new JException($e->getMessage()); |
|
| 10 | - } |
|
| 11 | - } |
|
| 12 | - public function query( $_query ) { |
|
| 13 | - $this->stdQuery($_query); |
|
| 14 | - return true; |
|
| 15 | - } |
|
| 16 | - public function queryInsert( $_query ) { |
|
| 17 | - $this->stdQuery($_query); |
|
| 18 | - return $this->connection->insert_id; |
|
| 19 | - } |
|
| 20 | - public function queryFetch( $_query ) { |
|
| 21 | - $result = $this->stdQuery($_query); |
|
| 22 | - $rows = []; |
|
| 23 | - while($row = $result->fetch_assoc()) |
|
| 24 | - $rows[] = $row; |
|
| 25 | - return $rows; |
|
| 26 | - } |
|
| 27 | - public function queryArray( $_query ) { |
|
| 28 | - $result = $this->stdQuery($_query); |
|
| 29 | - $rows = []; |
|
| 30 | - while($row = $result->fetch_array()) |
|
| 31 | - $rows[] = $row; |
|
| 32 | - return $rows; |
|
| 33 | - } |
|
| 34 | - protected function stdQuery( $_query ) { |
|
| 35 | - $database = $this->connection; |
|
| 36 | - $result = $database->query($_query); |
|
| 37 | - if(!$result) |
|
| 38 | - throw new JException(json_encode([ |
|
| 39 | - "query" => $_query, |
|
| 40 | - "error" => $database->error |
|
| 41 | - ])); |
|
| 42 | - return $result; |
|
| 43 | - } |
|
| 4 | + public $connection; |
|
| 5 | + public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
| 6 | + try { |
|
| 7 | + $this->connection = new mysqli( $_srv, $_usr, $_pass, $_db ); |
|
| 8 | + } catch( Exception $e ) { |
|
| 9 | + throw new JException($e->getMessage()); |
|
| 10 | + } |
|
| 11 | + } |
|
| 12 | + public function query( $_query ) { |
|
| 13 | + $this->stdQuery($_query); |
|
| 14 | + return true; |
|
| 15 | + } |
|
| 16 | + public function queryInsert( $_query ) { |
|
| 17 | + $this->stdQuery($_query); |
|
| 18 | + return $this->connection->insert_id; |
|
| 19 | + } |
|
| 20 | + public function queryFetch( $_query ) { |
|
| 21 | + $result = $this->stdQuery($_query); |
|
| 22 | + $rows = []; |
|
| 23 | + while($row = $result->fetch_assoc()) |
|
| 24 | + $rows[] = $row; |
|
| 25 | + return $rows; |
|
| 26 | + } |
|
| 27 | + public function queryArray( $_query ) { |
|
| 28 | + $result = $this->stdQuery($_query); |
|
| 29 | + $rows = []; |
|
| 30 | + while($row = $result->fetch_array()) |
|
| 31 | + $rows[] = $row; |
|
| 32 | + return $rows; |
|
| 33 | + } |
|
| 34 | + protected function stdQuery( $_query ) { |
|
| 35 | + $database = $this->connection; |
|
| 36 | + $result = $database->query($_query); |
|
| 37 | + if(!$result) |
|
| 38 | + throw new JException(json_encode([ |
|
| 39 | + "query" => $_query, |
|
| 40 | + "error" => $database->error |
|
| 41 | + ])); |
|
| 42 | + return $result; |
|
| 43 | + } |
|
| 44 | 44 | } |
| 45 | 45 | ?> |
@@ -2,39 +2,39 @@ |
||
| 2 | 2 | jRequire("ConnectionInterface.php"); |
| 3 | 3 | class MysqliAdapter implements ConnectionAdapterInterface { |
| 4 | 4 | public $connection; |
| 5 | - public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
| 5 | + public function __construct($_srv, $_db, $_usr, $_pass) { |
|
| 6 | 6 | try { |
| 7 | - $this->connection = new mysqli( $_srv, $_usr, $_pass, $_db ); |
|
| 8 | - } catch( Exception $e ) { |
|
| 7 | + $this->connection = new mysqli($_srv, $_usr, $_pass, $_db); |
|
| 8 | + } catch (Exception $e) { |
|
| 9 | 9 | throw new JException($e->getMessage()); |
| 10 | 10 | } |
| 11 | 11 | } |
| 12 | - public function query( $_query ) { |
|
| 12 | + public function query($_query) { |
|
| 13 | 13 | $this->stdQuery($_query); |
| 14 | 14 | return true; |
| 15 | 15 | } |
| 16 | - public function queryInsert( $_query ) { |
|
| 16 | + public function queryInsert($_query) { |
|
| 17 | 17 | $this->stdQuery($_query); |
| 18 | 18 | return $this->connection->insert_id; |
| 19 | 19 | } |
| 20 | - public function queryFetch( $_query ) { |
|
| 20 | + public function queryFetch($_query) { |
|
| 21 | 21 | $result = $this->stdQuery($_query); |
| 22 | 22 | $rows = []; |
| 23 | - while($row = $result->fetch_assoc()) |
|
| 23 | + while ($row = $result->fetch_assoc()) |
|
| 24 | 24 | $rows[] = $row; |
| 25 | 25 | return $rows; |
| 26 | 26 | } |
| 27 | - public function queryArray( $_query ) { |
|
| 27 | + public function queryArray($_query) { |
|
| 28 | 28 | $result = $this->stdQuery($_query); |
| 29 | 29 | $rows = []; |
| 30 | - while($row = $result->fetch_array()) |
|
| 30 | + while ($row = $result->fetch_array()) |
|
| 31 | 31 | $rows[] = $row; |
| 32 | 32 | return $rows; |
| 33 | 33 | } |
| 34 | - protected function stdQuery( $_query ) { |
|
| 34 | + protected function stdQuery($_query) { |
|
| 35 | 35 | $database = $this->connection; |
| 36 | 36 | $result = $database->query($_query); |
| 37 | - if(!$result) |
|
| 37 | + if (!$result) |
|
| 38 | 38 | throw new JException(json_encode([ |
| 39 | 39 | "query" => $_query, |
| 40 | 40 | "error" => $database->error |
@@ -20,25 +20,28 @@ |
||
| 20 | 20 | public function queryFetch( $_query ) { |
| 21 | 21 | $result = $this->stdQuery($_query); |
| 22 | 22 | $rows = []; |
| 23 | - while($row = $result->fetch_assoc()) |
|
| 24 | - $rows[] = $row; |
|
| 23 | + while($row = $result->fetch_assoc()) { |
|
| 24 | + $rows[] = $row; |
|
| 25 | + } |
|
| 25 | 26 | return $rows; |
| 26 | 27 | } |
| 27 | 28 | public function queryArray( $_query ) { |
| 28 | 29 | $result = $this->stdQuery($_query); |
| 29 | 30 | $rows = []; |
| 30 | - while($row = $result->fetch_array()) |
|
| 31 | - $rows[] = $row; |
|
| 31 | + while($row = $result->fetch_array()) { |
|
| 32 | + $rows[] = $row; |
|
| 33 | + } |
|
| 32 | 34 | return $rows; |
| 33 | 35 | } |
| 34 | 36 | protected function stdQuery( $_query ) { |
| 35 | 37 | $database = $this->connection; |
| 36 | 38 | $result = $database->query($_query); |
| 37 | - if(!$result) |
|
| 38 | - throw new JException(json_encode([ |
|
| 39 | + if(!$result) { |
|
| 40 | + throw new JException(json_encode([ |
|
| 39 | 41 | "query" => $_query, |
| 40 | 42 | "error" => $database->error |
| 41 | 43 | ])); |
| 44 | + } |
|
| 42 | 45 | return $result; |
| 43 | 46 | } |
| 44 | 47 | } |
@@ -1,48 +1,48 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | jRequire("ConnectionInterface.php"); |
| 3 | 3 | class PostgresqlAdapter implements ConnectionAdapterInterface { |
| 4 | - public $connection; |
|
| 5 | - public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
| 6 | - try { |
|
| 7 | - $this->connection = pg_connect("host=$_srv dbname=$_db user=$_usr password=$_pass") |
|
| 8 | - or die('Could not connect: '.pg_last_error()); |
|
| 9 | - } catch( Exception $e ) { |
|
| 10 | - throw new JException($e->getMessage()); |
|
| 11 | - } |
|
| 12 | - } |
|
| 13 | - public function query( $_query ) { |
|
| 14 | - $this->stdQuery($_query); |
|
| 15 | - return true; |
|
| 16 | - } |
|
| 17 | - public function queryInsert( $_query ) { |
|
| 18 | - $this->stdQuery($_query); |
|
| 19 | - return $this->stdQuery("SELECT lastval()"); |
|
| 20 | - } |
|
| 21 | - public function queryFetch( $_query ) { |
|
| 22 | - $result = $this->stdQuery($_query); |
|
| 23 | - $rows = []; |
|
| 24 | - while($row = pg_fetch_assoc($result)) |
|
| 25 | - $rows[] = $row; |
|
| 26 | - pg_free_result($result); |
|
| 27 | - return $rows; |
|
| 28 | - } |
|
| 29 | - public function queryArray( $_query ) { |
|
| 30 | - $result = $this->stdQuery($_query); |
|
| 31 | - $rows = []; |
|
| 32 | - while($row = pg_fetch_array($result)) |
|
| 33 | - $rows[] = $row; |
|
| 34 | - pg_free_result($result); |
|
| 35 | - return $rows; |
|
| 36 | - } |
|
| 37 | - protected function stdQuery( $_query ) { |
|
| 38 | - $database = $this->connection; |
|
| 39 | - $result = pg_query($database, $_query); |
|
| 40 | - if(!$result) |
|
| 41 | - throw new JException(json_encode([ |
|
| 42 | - "query" => $_query, |
|
| 43 | - "error" => pg_last_error() |
|
| 44 | - ])); |
|
| 45 | - return $result; |
|
| 46 | - } |
|
| 4 | + public $connection; |
|
| 5 | + public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
| 6 | + try { |
|
| 7 | + $this->connection = pg_connect("host=$_srv dbname=$_db user=$_usr password=$_pass") |
|
| 8 | + or die('Could not connect: '.pg_last_error()); |
|
| 9 | + } catch( Exception $e ) { |
|
| 10 | + throw new JException($e->getMessage()); |
|
| 11 | + } |
|
| 12 | + } |
|
| 13 | + public function query( $_query ) { |
|
| 14 | + $this->stdQuery($_query); |
|
| 15 | + return true; |
|
| 16 | + } |
|
| 17 | + public function queryInsert( $_query ) { |
|
| 18 | + $this->stdQuery($_query); |
|
| 19 | + return $this->stdQuery("SELECT lastval()"); |
|
| 20 | + } |
|
| 21 | + public function queryFetch( $_query ) { |
|
| 22 | + $result = $this->stdQuery($_query); |
|
| 23 | + $rows = []; |
|
| 24 | + while($row = pg_fetch_assoc($result)) |
|
| 25 | + $rows[] = $row; |
|
| 26 | + pg_free_result($result); |
|
| 27 | + return $rows; |
|
| 28 | + } |
|
| 29 | + public function queryArray( $_query ) { |
|
| 30 | + $result = $this->stdQuery($_query); |
|
| 31 | + $rows = []; |
|
| 32 | + while($row = pg_fetch_array($result)) |
|
| 33 | + $rows[] = $row; |
|
| 34 | + pg_free_result($result); |
|
| 35 | + return $rows; |
|
| 36 | + } |
|
| 37 | + protected function stdQuery( $_query ) { |
|
| 38 | + $database = $this->connection; |
|
| 39 | + $result = pg_query($database, $_query); |
|
| 40 | + if(!$result) |
|
| 41 | + throw new JException(json_encode([ |
|
| 42 | + "query" => $_query, |
|
| 43 | + "error" => pg_last_error() |
|
| 44 | + ])); |
|
| 45 | + return $result; |
|
| 46 | + } |
|
| 47 | 47 | } |
| 48 | 48 | ?> |
@@ -2,42 +2,42 @@ |
||
| 2 | 2 | jRequire("ConnectionInterface.php"); |
| 3 | 3 | class PostgresqlAdapter implements ConnectionAdapterInterface { |
| 4 | 4 | public $connection; |
| 5 | - public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
| 5 | + public function __construct($_srv, $_db, $_usr, $_pass) { |
|
| 6 | 6 | try { |
| 7 | 7 | $this->connection = pg_connect("host=$_srv dbname=$_db user=$_usr password=$_pass") |
| 8 | 8 | or die('Could not connect: '.pg_last_error()); |
| 9 | - } catch( Exception $e ) { |
|
| 9 | + } catch (Exception $e) { |
|
| 10 | 10 | throw new JException($e->getMessage()); |
| 11 | 11 | } |
| 12 | 12 | } |
| 13 | - public function query( $_query ) { |
|
| 13 | + public function query($_query) { |
|
| 14 | 14 | $this->stdQuery($_query); |
| 15 | 15 | return true; |
| 16 | 16 | } |
| 17 | - public function queryInsert( $_query ) { |
|
| 17 | + public function queryInsert($_query) { |
|
| 18 | 18 | $this->stdQuery($_query); |
| 19 | 19 | return $this->stdQuery("SELECT lastval()"); |
| 20 | 20 | } |
| 21 | - public function queryFetch( $_query ) { |
|
| 21 | + public function queryFetch($_query) { |
|
| 22 | 22 | $result = $this->stdQuery($_query); |
| 23 | 23 | $rows = []; |
| 24 | - while($row = pg_fetch_assoc($result)) |
|
| 24 | + while ($row = pg_fetch_assoc($result)) |
|
| 25 | 25 | $rows[] = $row; |
| 26 | 26 | pg_free_result($result); |
| 27 | 27 | return $rows; |
| 28 | 28 | } |
| 29 | - public function queryArray( $_query ) { |
|
| 29 | + public function queryArray($_query) { |
|
| 30 | 30 | $result = $this->stdQuery($_query); |
| 31 | 31 | $rows = []; |
| 32 | - while($row = pg_fetch_array($result)) |
|
| 32 | + while ($row = pg_fetch_array($result)) |
|
| 33 | 33 | $rows[] = $row; |
| 34 | 34 | pg_free_result($result); |
| 35 | 35 | return $rows; |
| 36 | 36 | } |
| 37 | - protected function stdQuery( $_query ) { |
|
| 37 | + protected function stdQuery($_query) { |
|
| 38 | 38 | $database = $this->connection; |
| 39 | 39 | $result = pg_query($database, $_query); |
| 40 | - if(!$result) |
|
| 40 | + if (!$result) |
|
| 41 | 41 | throw new JException(json_encode([ |
| 42 | 42 | "query" => $_query, |
| 43 | 43 | "error" => pg_last_error() |
@@ -21,27 +21,30 @@ |
||
| 21 | 21 | public function queryFetch( $_query ) { |
| 22 | 22 | $result = $this->stdQuery($_query); |
| 23 | 23 | $rows = []; |
| 24 | - while($row = pg_fetch_assoc($result)) |
|
| 25 | - $rows[] = $row; |
|
| 24 | + while($row = pg_fetch_assoc($result)) { |
|
| 25 | + $rows[] = $row; |
|
| 26 | + } |
|
| 26 | 27 | pg_free_result($result); |
| 27 | 28 | return $rows; |
| 28 | 29 | } |
| 29 | 30 | public function queryArray( $_query ) { |
| 30 | 31 | $result = $this->stdQuery($_query); |
| 31 | 32 | $rows = []; |
| 32 | - while($row = pg_fetch_array($result)) |
|
| 33 | - $rows[] = $row; |
|
| 33 | + while($row = pg_fetch_array($result)) { |
|
| 34 | + $rows[] = $row; |
|
| 35 | + } |
|
| 34 | 36 | pg_free_result($result); |
| 35 | 37 | return $rows; |
| 36 | 38 | } |
| 37 | 39 | protected function stdQuery( $_query ) { |
| 38 | 40 | $database = $this->connection; |
| 39 | 41 | $result = pg_query($database, $_query); |
| 40 | - if(!$result) |
|
| 41 | - throw new JException(json_encode([ |
|
| 42 | + if(!$result) { |
|
| 43 | + throw new JException(json_encode([ |
|
| 42 | 44 | "query" => $_query, |
| 43 | 45 | "error" => pg_last_error() |
| 44 | 46 | ])); |
| 47 | + } |
|
| 45 | 48 | return $result; |
| 46 | 49 | } |
| 47 | 50 | } |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | jRequire("PdoAdapter.php"); |
| 3 | 3 | class PdoMemoryAdapter extends PdoAdapter { |
| 4 | - public $connection; |
|
| 5 | - public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
| 6 | - try { |
|
| 7 | - $this->connection = new PDO("sqlite::memory:"); |
|
| 8 | - } catch( Exception $e ) { |
|
| 9 | - throw new JException($e->getMessage()); |
|
| 10 | - } |
|
| 11 | - } |
|
| 4 | + public $connection; |
|
| 5 | + public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
| 6 | + try { |
|
| 7 | + $this->connection = new PDO("sqlite::memory:"); |
|
| 8 | + } catch( Exception $e ) { |
|
| 9 | + throw new JException($e->getMessage()); |
|
| 10 | + } |
|
| 11 | + } |
|
| 12 | 12 | } |
| 13 | 13 | ?> |
@@ -2,10 +2,10 @@ |
||
| 2 | 2 | jRequire("PdoAdapter.php"); |
| 3 | 3 | class PdoMemoryAdapter extends PdoAdapter { |
| 4 | 4 | public $connection; |
| 5 | - public function __construct( $_srv, $_db, $_usr, $_pass ) { |
|
| 5 | + public function __construct($_srv, $_db, $_usr, $_pass) { |
|
| 6 | 6 | try { |
| 7 | 7 | $this->connection = new PDO("sqlite::memory:"); |
| 8 | - } catch( Exception $e ) { |
|
| 8 | + } catch (Exception $e) { |
|
| 9 | 9 | throw new JException($e->getMessage()); |
| 10 | 10 | } |
| 11 | 11 | } |
@@ -2,10 +2,10 @@ |
||
| 2 | 2 | use Pug as Pug; |
| 3 | 3 | jRequire("ParserAbstract.php"); |
| 4 | 4 | class PugAdapter extends ParserAbstract { |
| 5 | - public function draw( $_text, $_parameters = [] ) { |
|
| 6 | - $pug = new Pug\Pug(); |
|
| 7 | - $page = $pug->render($_text, $_parameters); |
|
| 8 | - return $page; |
|
| 9 | - } |
|
| 5 | + public function draw( $_text, $_parameters = [] ) { |
|
| 6 | + $pug = new Pug\Pug(); |
|
| 7 | + $page = $pug->render($_text, $_parameters); |
|
| 8 | + return $page; |
|
| 9 | + } |
|
| 10 | 10 | } |
| 11 | 11 | ?> |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | use Pug as Pug; |
| 3 | 3 | jRequire("ParserAbstract.php"); |
| 4 | 4 | class PugAdapter extends ParserAbstract { |
| 5 | - public function draw( $_text, $_parameters = [] ) { |
|
| 5 | + public function draw($_text, $_parameters = []) { |
|
| 6 | 6 | $pug = new Pug\Pug(); |
| 7 | 7 | $page = $pug->render($_text, $_parameters); |
| 8 | 8 | return $page; |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | jRequire("ParserAbstract.php"); |
| 3 | 3 | class JTagAdapter extends ParserAbstract { |
| 4 | - public function draw( $_text, $_parameters = [] ) { |
|
| 5 | - foreach($_parameters as $key => $value) |
|
| 6 | - if(!is_array($value)) |
|
| 7 | - $_text = str_replace("<_${key}_>", "$value", $_text); |
|
| 8 | - $_text = preg_replace('~<_[^_]+_>~', '', $_text); |
|
| 9 | - return $_text; |
|
| 10 | - } |
|
| 4 | + public function draw( $_text, $_parameters = [] ) { |
|
| 5 | + foreach($_parameters as $key => $value) |
|
| 6 | + if(!is_array($value)) |
|
| 7 | + $_text = str_replace("<_${key}_>", "$value", $_text); |
|
| 8 | + $_text = preg_replace('~<_[^_]+_>~', '', $_text); |
|
| 9 | + return $_text; |
|
| 10 | + } |
|
| 11 | 11 | } |
| 12 | 12 | ?> |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | jRequire("ParserAbstract.php"); |
| 3 | 3 | class JTagAdapter extends ParserAbstract { |
| 4 | - public function draw( $_text, $_parameters = [] ) { |
|
| 5 | - foreach($_parameters as $key => $value) |
|
| 6 | - if(!is_array($value)) |
|
| 4 | + public function draw($_text, $_parameters = []) { |
|
| 5 | + foreach ($_parameters as $key => $value) |
|
| 6 | + if (!is_array($value)) |
|
| 7 | 7 | $_text = str_replace("<_${key}_>", "$value", $_text); |
| 8 | 8 | $_text = preg_replace('~<_[^_]+_>~', '', $_text); |
| 9 | 9 | return $_text; |
@@ -2,9 +2,10 @@ |
||
| 2 | 2 | jRequire("ParserAbstract.php"); |
| 3 | 3 | class JTagAdapter extends ParserAbstract { |
| 4 | 4 | public function draw( $_text, $_parameters = [] ) { |
| 5 | - foreach($_parameters as $key => $value) |
|
| 6 | - if(!is_array($value)) |
|
| 5 | + foreach($_parameters as $key => $value) { |
|
| 6 | + if(!is_array($value)) |
|
| 7 | 7 | $_text = str_replace("<_${key}_>", "$value", $_text); |
| 8 | + } |
|
| 8 | 9 | $_text = preg_replace('~<_[^_]+_>~', '', $_text); |
| 9 | 10 | return $_text; |
| 10 | 11 | } |
@@ -2,13 +2,13 @@ |
||
| 2 | 2 | // use Twig as Twig; |
| 3 | 3 | jRequire("ParserAbstract.php"); |
| 4 | 4 | class TwigAdapter extends ParserAbstract { |
| 5 | - public function draw( $_text, $_parameters = [] ) { |
|
| 6 | - $loader = new Twig_Loader_Array([ |
|
| 7 | - 'index' => $_text |
|
| 8 | - ]); |
|
| 9 | - $twig = new Twig_Environment($loader); |
|
| 10 | - $page = $twig->render('index', $_parameters); |
|
| 11 | - return $page; |
|
| 12 | - } |
|
| 5 | + public function draw( $_text, $_parameters = [] ) { |
|
| 6 | + $loader = new Twig_Loader_Array([ |
|
| 7 | + 'index' => $_text |
|
| 8 | + ]); |
|
| 9 | + $twig = new Twig_Environment($loader); |
|
| 10 | + $page = $twig->render('index', $_parameters); |
|
| 11 | + return $page; |
|
| 12 | + } |
|
| 13 | 13 | } |
| 14 | 14 | ?> |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | // use Twig as Twig; |
| 3 | 3 | jRequire("ParserAbstract.php"); |
| 4 | 4 | class TwigAdapter extends ParserAbstract { |
| 5 | - public function draw( $_text, $_parameters = [] ) { |
|
| 5 | + public function draw($_text, $_parameters = []) { |
|
| 6 | 6 | $loader = new Twig_Loader_Array([ |
| 7 | 7 | 'index' => $_text |
| 8 | 8 | ]); |
@@ -3,11 +3,11 @@ |
||
| 3 | 3 | jRequire("../../ExternalModules/Parsedown/Parsedown.php"); |
| 4 | 4 | use Parsedown as Parsedown; |
| 5 | 5 | class ParsedownAdapter extends ParserAbstract { |
| 6 | - public function draw( $_text, $_parameters = [] ) { |
|
| 7 | - $Parsedown = new Parsedown\Parsedown(); |
|
| 8 | - $page = $Parsedown->text($_text); |
|
| 9 | - $page = preg_replace('/[ ](?=[^>]*(?:<|$))/', " ", $page); |
|
| 10 | - return $page; |
|
| 11 | - } |
|
| 6 | + public function draw( $_text, $_parameters = [] ) { |
|
| 7 | + $Parsedown = new Parsedown\Parsedown(); |
|
| 8 | + $page = $Parsedown->text($_text); |
|
| 9 | + $page = preg_replace('/[ ](?=[^>]*(?:<|$))/', " ", $page); |
|
| 10 | + return $page; |
|
| 11 | + } |
|
| 12 | 12 | } |
| 13 | 13 | ?> |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | jRequire("../../ExternalModules/Parsedown/Parsedown.php"); |
| 4 | 4 | use Parsedown as Parsedown; |
| 5 | 5 | class ParsedownAdapter extends ParserAbstract { |
| 6 | - public function draw( $_text, $_parameters = [] ) { |
|
| 6 | + public function draw($_text, $_parameters = []) { |
|
| 7 | 7 | $Parsedown = new Parsedown\Parsedown(); |
| 8 | 8 | $page = $Parsedown->text($_text); |
| 9 | 9 | $page = preg_replace('/[ ](?=[^>]*(?:<|$))/', " ", $page); |
@@ -1,31 +1,31 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class JException extends Exception { |
| 3 | - static protected $escapeString = "|jate|"; |
|
| 4 | - public function __construct($_message, $_level = 2, $_code = 0, Exception $_previous = null) { |
|
| 5 | - parent::__construct($_message, $_code, $_previous); |
|
| 6 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["file"])) |
|
| 7 | - $this->file = debug_backtrace()[$_level]["file"]; |
|
| 8 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["line"])) |
|
| 9 | - $this->line = debug_backtrace()[$_level]["line"]; |
|
| 10 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["function"])) |
|
| 11 | - $this->function = debug_backtrace()[$_level]["function"]; |
|
| 12 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["class"])) |
|
| 13 | - $this->class = debug_backtrace()[$_level]["class"]; |
|
| 14 | - } |
|
| 15 | - public function __toString() { |
|
| 16 | - return JException::encode(JException::decode($this->message)); |
|
| 17 | - } |
|
| 18 | - static public function decode( $_message ) { |
|
| 19 | - $messageSplitted = explode(JException::$escapeString, $_message); |
|
| 20 | - if(count($messageSplitted) == 3) |
|
| 21 | - return $messageSplitted[1]; |
|
| 22 | - else |
|
| 23 | - return $_message; |
|
| 24 | - } |
|
| 25 | - static public function encode( $_message ) { |
|
| 26 | - $escape = JException::$escapeString; |
|
| 27 | - return "$escape$_message$escape"; |
|
| 3 | + static protected $escapeString = "|jate|"; |
|
| 4 | + public function __construct($_message, $_level = 2, $_code = 0, Exception $_previous = null) { |
|
| 5 | + parent::__construct($_message, $_code, $_previous); |
|
| 6 | + if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["file"])) |
|
| 7 | + $this->file = debug_backtrace()[$_level]["file"]; |
|
| 8 | + if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["line"])) |
|
| 9 | + $this->line = debug_backtrace()[$_level]["line"]; |
|
| 10 | + if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["function"])) |
|
| 11 | + $this->function = debug_backtrace()[$_level]["function"]; |
|
| 12 | + if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["class"])) |
|
| 13 | + $this->class = debug_backtrace()[$_level]["class"]; |
|
| 14 | + } |
|
| 15 | + public function __toString() { |
|
| 16 | + return JException::encode(JException::decode($this->message)); |
|
| 17 | + } |
|
| 18 | + static public function decode( $_message ) { |
|
| 19 | + $messageSplitted = explode(JException::$escapeString, $_message); |
|
| 20 | + if(count($messageSplitted) == 3) |
|
| 21 | + return $messageSplitted[1]; |
|
| 22 | + else |
|
| 23 | + return $_message; |
|
| 24 | + } |
|
| 25 | + static public function encode( $_message ) { |
|
| 26 | + $escape = JException::$escapeString; |
|
| 27 | + return "$escape$_message$escape"; |
|
| 28 | 28 | |
| 29 | - } |
|
| 29 | + } |
|
| 30 | 30 | } |
| 31 | 31 | ?> |
@@ -3,26 +3,26 @@ |
||
| 3 | 3 | static protected $escapeString = "|jate|"; |
| 4 | 4 | public function __construct($_message, $_level = 2, $_code = 0, Exception $_previous = null) { |
| 5 | 5 | parent::__construct($_message, $_code, $_previous); |
| 6 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["file"])) |
|
| 6 | + if (isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["file"])) |
|
| 7 | 7 | $this->file = debug_backtrace()[$_level]["file"]; |
| 8 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["line"])) |
|
| 8 | + if (isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["line"])) |
|
| 9 | 9 | $this->line = debug_backtrace()[$_level]["line"]; |
| 10 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["function"])) |
|
| 10 | + if (isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["function"])) |
|
| 11 | 11 | $this->function = debug_backtrace()[$_level]["function"]; |
| 12 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["class"])) |
|
| 12 | + if (isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["class"])) |
|
| 13 | 13 | $this->class = debug_backtrace()[$_level]["class"]; |
| 14 | 14 | } |
| 15 | 15 | public function __toString() { |
| 16 | 16 | return JException::encode(JException::decode($this->message)); |
| 17 | 17 | } |
| 18 | - static public function decode( $_message ) { |
|
| 18 | + static public function decode($_message) { |
|
| 19 | 19 | $messageSplitted = explode(JException::$escapeString, $_message); |
| 20 | - if(count($messageSplitted) == 3) |
|
| 20 | + if (count($messageSplitted) == 3) |
|
| 21 | 21 | return $messageSplitted[1]; |
| 22 | 22 | else |
| 23 | 23 | return $_message; |
| 24 | 24 | } |
| 25 | - static public function encode( $_message ) { |
|
| 25 | + static public function encode($_message) { |
|
| 26 | 26 | $escape = JException::$escapeString; |
| 27 | 27 | return "$escape$_message$escape"; |
| 28 | 28 | |
@@ -3,24 +3,29 @@ |
||
| 3 | 3 | static protected $escapeString = "|jate|"; |
| 4 | 4 | public function __construct($_message, $_level = 2, $_code = 0, Exception $_previous = null) { |
| 5 | 5 | parent::__construct($_message, $_code, $_previous); |
| 6 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["file"])) |
|
| 7 | - $this->file = debug_backtrace()[$_level]["file"]; |
|
| 8 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["line"])) |
|
| 9 | - $this->line = debug_backtrace()[$_level]["line"]; |
|
| 10 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["function"])) |
|
| 11 | - $this->function = debug_backtrace()[$_level]["function"]; |
|
| 12 | - if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["class"])) |
|
| 13 | - $this->class = debug_backtrace()[$_level]["class"]; |
|
| 6 | + if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["file"])) { |
|
| 7 | + $this->file = debug_backtrace()[$_level]["file"]; |
|
| 8 | + } |
|
| 9 | + if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["line"])) { |
|
| 10 | + $this->line = debug_backtrace()[$_level]["line"]; |
|
| 11 | + } |
|
| 12 | + if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["function"])) { |
|
| 13 | + $this->function = debug_backtrace()[$_level]["function"]; |
|
| 14 | + } |
|
| 15 | + if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["class"])) { |
|
| 16 | + $this->class = debug_backtrace()[$_level]["class"]; |
|
| 17 | + } |
|
| 14 | 18 | } |
| 15 | 19 | public function __toString() { |
| 16 | 20 | return JException::encode(JException::decode($this->message)); |
| 17 | 21 | } |
| 18 | 22 | static public function decode( $_message ) { |
| 19 | 23 | $messageSplitted = explode(JException::$escapeString, $_message); |
| 20 | - if(count($messageSplitted) == 3) |
|
| 21 | - return $messageSplitted[1]; |
|
| 22 | - else |
|
| 23 | - return $_message; |
|
| 24 | + if(count($messageSplitted) == 3) { |
|
| 25 | + return $messageSplitted[1]; |
|
| 26 | + } else { |
|
| 27 | + return $_message; |
|
| 28 | + } |
|
| 24 | 29 | } |
| 25 | 30 | static public function encode( $_message ) { |
| 26 | 31 | $escape = JException::$escapeString; |