@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Defining Interface for class GetData. |
|
| 4 | - * |
|
| 5 | - * @package Ibonly\PotatoORM\ModelInterface |
|
| 6 | - * @author Ibraheem ADENIYI <[email protected]> |
|
| 7 | - * @license MIT <https://opensource.org/licenses/MIT> |
|
| 8 | - */ |
|
| 3 | + * Defining Interface for class GetData. |
|
| 4 | + * |
|
| 5 | + * @package Ibonly\PotatoORM\ModelInterface |
|
| 6 | + * @author Ibraheem ADENIYI <[email protected]> |
|
| 7 | + * @license MIT <https://opensource.org/licenses/MIT> |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | namespace Ibonly\PotatoORM; |
| 11 | 11 | |
@@ -9,17 +9,12 @@ |
||
| 9 | 9 | |
| 10 | 10 | namespace Ibonly\PotatoORM; |
| 11 | 11 | |
| 12 | -use PDO; |
|
| 13 | -use Exception; |
|
| 14 | -use PDOException; |
|
| 15 | 12 | use Ibonly\PotatoORM\GetData; |
| 16 | 13 | use Ibonly\PotatoORM\DatabaseQuery; |
| 17 | 14 | use Ibonly\PotatoORM\ModelInterface; |
| 18 | 15 | use Ibonly\PotatoORM\UserNotFoundException; |
| 19 | 16 | use Ibonly\PotatoORM\EmptyDatabaseException; |
| 20 | 17 | use Ibonly\PotatoORM\SaveUserExistException; |
| 21 | -use Ibonly\PotatoORM\ColumnNotExistExeption; |
|
| 22 | -use Ibonly\PotatoORM\InvalidConnectionException; |
|
| 23 | 18 | |
| 24 | 19 | class Model extends DatabaseQuery implements ModelInterface |
| 25 | 20 | { |
@@ -51,6 +51,7 @@ discard block |
||
| 51 | 51 | /** |
| 52 | 52 | * getTableName() |
| 53 | 53 | * |
| 54 | + * @param string $connection |
|
| 54 | 55 | * @return string |
| 55 | 56 | */ |
| 56 | 57 | public static function getTableName($connection) |
@@ -62,7 +63,7 @@ discard block |
||
| 62 | 63 | * getALL() |
| 63 | 64 | * Get all record from the database |
| 64 | 65 | * |
| 65 | - * @return object |
|
| 66 | + * @return GetData |
|
| 66 | 67 | */ |
| 67 | 68 | public function getALL($dbConnection = NULL) |
| 68 | 69 | { |
@@ -82,7 +83,7 @@ discard block |
||
| 82 | 83 | * where($data, $condition) |
| 83 | 84 | * Get data from database where $data = $condition |
| 84 | 85 | * |
| 85 | - * @return object |
|
| 86 | + * @return GetData |
|
| 86 | 87 | */ |
| 87 | 88 | public function where($data, $condition = NULL, $dbConnection = NULL) |
| 88 | 89 | { |
@@ -103,7 +104,7 @@ discard block |
||
| 103 | 104 | * find($value) |
| 104 | 105 | * Find data from database where id = $value |
| 105 | 106 | * |
| 106 | - * @return array |
|
| 107 | + * @return Model |
|
| 107 | 108 | */ |
| 108 | 109 | public static function find($value, $dbConnection = NULL) |
| 109 | 110 | { |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $sqlQuery = DatabaseQuery::selectAllQuery(self::getTableName($connection)); |
| 72 | 72 | $query = $connection->prepare($sqlQuery); |
| 73 | 73 | $query->execute(); |
| 74 | - if ( $query->rowCount() ) |
|
| 74 | + if ($query->rowCount()) |
|
| 75 | 75 | { |
| 76 | 76 | return new GetData($query->fetchAll($connection::FETCH_ASSOC)); |
| 77 | 77 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $sqlQuery = $databaseQuery->selectQuery(self::getTableName($connection), $data, $condition, $connection); |
| 93 | 93 | $query = $connection->prepare($sqlQuery); |
| 94 | 94 | $query->execute(); |
| 95 | - if ( $query->rowCount() ) |
|
| 95 | + if ($query->rowCount()) |
|
| 96 | 96 | { |
| 97 | 97 | return new GetData($query->fetchAll($connection::FETCH_ASSOC)); |
| 98 | 98 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $sqlQuery = DatabaseQuery::selectQuery(self::getTableName($connection), ['id' => $value], NULL, $connection); |
| 113 | 113 | $query = $connection->prepare($sqlQuery); |
| 114 | 114 | $query->execute(); |
| 115 | - if ( $query->rowCount() ) |
|
| 115 | + if ($query->rowCount()) |
|
| 116 | 116 | { |
| 117 | 117 | $found = new static; |
| 118 | 118 | $found->id = $value; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | $query = $this->insertQuery(self::getTableName($connection)); |
| 136 | 136 | $statement = $connection->prepare($query); |
| 137 | - if( $statement->execute() ) |
|
| 137 | + if ($statement->execute()) |
|
| 138 | 138 | { |
| 139 | 139 | return true; |
| 140 | 140 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | $updateQuery = $this->updateQuery(self::getTableName($connection)); |
| 156 | 156 | $statement = $connection->prepare($updateQuery); |
| 157 | - if( $statement->execute() ) |
|
| 157 | + if ($statement->execute()) |
|
| 158 | 158 | { |
| 159 | 159 | return true; |
| 160 | 160 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | { |
| 172 | 172 | $connection = DatabaseQuery::checkConnection($dbConnection); |
| 173 | 173 | |
| 174 | - $query = $connection->prepare('DELETE FROM ' . self::getTableName($connection) . ' WHERE id = '.$value); |
|
| 174 | + $query = $connection->prepare('DELETE FROM '.self::getTableName($connection).' WHERE id = '.$value); |
|
| 175 | 175 | $query->execute(); |
| 176 | 176 | $check = $query->rowCount(); |
| 177 | 177 | if ($check) |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Defining Interface for class SchemaInterface. |
|
| 4 | - * |
|
| 5 | - * @package Ibonly\PotatoORM\DatabaseQueryInterface |
|
| 6 | - * @author Ibraheem ADENIYI <[email protected]> |
|
| 7 | - * @license MIT <https://opensource.org/licenses/MIT> |
|
| 8 | - */ |
|
| 3 | + * Defining Interface for class SchemaInterface. |
|
| 4 | + * |
|
| 5 | + * @package Ibonly\PotatoORM\DatabaseQueryInterface |
|
| 6 | + * @author Ibraheem ADENIYI <[email protected]> |
|
| 7 | + * @license MIT <https://opensource.org/licenses/MIT> |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | namespace Ibonly\PotatoORM; |
| 11 | 11 | |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Exception for user already exist |
|
| 4 | - * |
|
| 5 | - * @package Ibonly\PotatoORM\DataAlreadyExistException |
|
| 6 | - * @author Ibraheem ADENIYI <[email protected]> |
|
| 7 | - * @license MIT <https://opensource.org/licenses/MIT> |
|
| 8 | - */ |
|
| 3 | + * Exception for user already exist |
|
| 4 | + * |
|
| 5 | + * @package Ibonly\PotatoORM\DataAlreadyExistException |
|
| 6 | + * @author Ibraheem ADENIYI <[email protected]> |
|
| 7 | + * @license MIT <https://opensource.org/licenses/MIT> |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | namespace Ibonly\PotatoORM; |
| 11 | 11 | |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function errorMessage() |
| 27 | 27 | { |
| 28 | - return "Error: " . $this->getMessage(); |
|
| 28 | + return "Error: ".$this->getMessage(); |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Exception for user not found |
|
| 4 | - * |
|
| 5 | - * @package Ibonly\PotatoORM\DataNotFoundException |
|
| 6 | - * @author Ibraheem ADENIYI <[email protected]> |
|
| 7 | - * @license MIT <https://opensource.org/licenses/MIT> |
|
| 8 | - */ |
|
| 3 | + * Exception for user not found |
|
| 4 | + * |
|
| 5 | + * @package Ibonly\PotatoORM\DataNotFoundException |
|
| 6 | + * @author Ibraheem ADENIYI <[email protected]> |
|
| 7 | + * @license MIT <https://opensource.org/licenses/MIT> |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | namespace Ibonly\PotatoORM; |
| 11 | 11 | |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function errorMessage() |
| 27 | 27 | { |
| 28 | - return "Error: " . $this->getMessage(); |
|
| 28 | + return "Error: ".$this->getMessage(); |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -53,8 +53,8 @@ |
||
| 53 | 53 | /** |
| 54 | 54 | * Get the count of the fetch element |
| 55 | 55 | */ |
| 56 | - public function getCount() |
|
| 57 | - { |
|
| 56 | + public function getCount() |
|
| 57 | + { |
|
| 58 | 58 | return sizeof($this->value); |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | } |
| 61 | 61 | \ No newline at end of file |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | public function all() |
| 25 | 25 | { |
| 26 | - return json_decode( json_encode( $this->getAllData() ) ); |
|
| 26 | + return json_decode(json_encode($this->getAllData())); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function first() |
| 49 | 49 | { |
| 50 | - return json_decode( $this->toJson() ); |
|
| 50 | + return json_decode($this->toJson()); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |