@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @param $tablename |
| 63 | 63 | * @param $con |
| 64 | 64 | * |
| 65 | - * @return bool |
|
| 65 | + * @return boolean|null |
|
| 66 | 66 | */ |
| 67 | 67 | public function checkTableExist($table, $con=NULL) |
| 68 | 68 | { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | /** |
| 78 | 78 | * checkTableName Return the table name |
| 79 | 79 | * |
| 80 | - * @param $tablename |
|
| 80 | + * @param string|false $tablename |
|
| 81 | 81 | * @param $con |
| 82 | 82 | * |
| 83 | 83 | * @return string |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * checkColumn Check if column exist in table |
| 102 | 102 | * |
| 103 | 103 | * @param $tableName |
| 104 | - * @param $columnName |
|
| 104 | + * @param string $columnName |
|
| 105 | 105 | * @param $con |
| 106 | 106 | * |
| 107 | 107 | * @return string |
@@ -194,6 +194,7 @@ discard block |
||
| 194 | 194 | /** |
| 195 | 195 | * selectAllQuery |
| 196 | 196 | * |
| 197 | + * @param string $tableName |
|
| 197 | 198 | * @return string |
| 198 | 199 | */ |
| 199 | 200 | public static function selectAllQuery($tableName) |
@@ -229,6 +230,8 @@ discard block |
||
| 229 | 230 | /** |
| 230 | 231 | * selectQuery |
| 231 | 232 | * |
| 233 | + * @param string $tableName |
|
| 234 | + * @param string $connection |
|
| 232 | 235 | * @return string |
| 233 | 236 | */ |
| 234 | 237 | public static function selectQuery($tableName, $data, $condition, $connection) |
@@ -256,6 +259,7 @@ discard block |
||
| 256 | 259 | /** |
| 257 | 260 | * insertQuery |
| 258 | 261 | * |
| 262 | + * @param string $tableName |
|
| 259 | 263 | * @return string |
| 260 | 264 | */ |
| 261 | 265 | public function insertQuery($tableName) |
@@ -273,6 +277,7 @@ discard block |
||
| 273 | 277 | /** |
| 274 | 278 | * updateQuery |
| 275 | 279 | * |
| 280 | + * @param string $tableName |
|
| 276 | 281 | * @return string |
| 277 | 282 | */ |
| 278 | 283 | public function updateQuery($tableName) |
@@ -13,7 +13,6 @@ |
||
| 13 | 13 | use PDOException; |
| 14 | 14 | use Ibonly\PotatoORM\DatabaseQueryInterface; |
| 15 | 15 | use Ibonly\PotatoORM\ColumnNotExistExeption; |
| 16 | -use Ibonly\PotatoORM\InvalidConnectionException; |
|
| 17 | 16 | use Ibonly\PotatoORM\TableDoesNotExistException; |
| 18 | 17 | |
| 19 | 18 | class DatabaseQuery implements DatabaseQueryInterface |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * This class handles building sql query statement and check |
|
| 4 | - * that the table exist in the database. |
|
| 5 | - * |
|
| 6 | - * @package Ibonly\PotatoORM\DatabaseQuery |
|
| 7 | - * @author Ibraheem ADENIYI <[email protected]> |
|
| 8 | - * @license MIT <https://opensource.org/licenses/MIT> |
|
| 9 | - */ |
|
| 3 | + * This class handles building sql query statement and check |
|
| 4 | + * that the table exist in the database. |
|
| 5 | + * |
|
| 6 | + * @package Ibonly\PotatoORM\DatabaseQuery |
|
| 7 | + * @author Ibraheem ADENIYI <[email protected]> |
|
| 8 | + * @license MIT <https://opensource.org/licenses/MIT> |
|
| 9 | + */ |
|
| 10 | 10 | |
| 11 | 11 | namespace Ibonly\PotatoORM; |
| 12 | 12 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | protected static function checkConnection($con) |
| 51 | 51 | { |
| 52 | - if( is_null($con) ) |
|
| 52 | + if (is_null($con)) |
|
| 53 | 53 | { |
| 54 | 54 | $con = self::connect(); |
| 55 | 55 | } |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @return bool |
| 66 | 66 | */ |
| 67 | - public function checkTableExist($table, $con=NULL) |
|
| 67 | + public function checkTableExist($table, $con = NULL) |
|
| 68 | 68 | { |
| 69 | 69 | $connection = $this->checkConnection($con); |
| 70 | 70 | $query = $connection->query("SELECT 1 FROM {$table} LIMIT 1"); |
| 71 | - if( $query !== false ) |
|
| 71 | + if ($query !== false) |
|
| 72 | 72 | { |
| 73 | 73 | return true; |
| 74 | 74 | } |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | - public static function checkTableName($tableName, $con=NULL) |
|
| 85 | + public static function checkTableName($tableName, $con = NULL) |
|
| 86 | 86 | { |
| 87 | 87 | $connection = self::checkConnection($con); |
| 88 | 88 | // if( ! is_null($connection) ) |
| 89 | 89 | // { |
| 90 | 90 | $query = $connection->query("SELECT 1 FROM {$tableName} LIMIT 1"); |
| 91 | - if( $query !== false ) |
|
| 91 | + if ($query !== false) |
|
| 92 | 92 | { |
| 93 | 93 | return $tableName; |
| 94 | 94 | } |
@@ -106,13 +106,13 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @return string |
| 108 | 108 | */ |
| 109 | - protected static function checkColumn($tableName, $columnName, $con=NULL) |
|
| 109 | + protected static function checkColumn($tableName, $columnName, $con = NULL) |
|
| 110 | 110 | { |
| 111 | 111 | $connection = self::checkConnection($con); |
| 112 | 112 | |
| 113 | 113 | $result = $connection->prepare("SELECT {$columnName} FROM {$tableName}"); |
| 114 | 114 | $result->execute(); |
| 115 | - if ( ! $result->columnCount() ) |
|
| 115 | + if ( ! $result->columnCount()) |
|
| 116 | 116 | { |
| 117 | 117 | throw new ColumnNotExistExeption(); |
| 118 | 118 | } |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | $insertQuery = ""; |
| 133 | 133 | $arraySize = sizeof($data); |
| 134 | 134 | |
| 135 | - foreach ( $data as $key => $value ) |
|
| 135 | + foreach ($data as $key => $value) |
|
| 136 | 136 | { |
| 137 | 137 | $counter++; |
| 138 | 138 | $insertQuery .= self::sanitize($key); |
| 139 | - if( $arraySize > $counter ) |
|
| 139 | + if ($arraySize > $counter) |
|
| 140 | 140 | $insertQuery .= ", "; |
| 141 | 141 | } |
| 142 | 142 | return $insertQuery; |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | $insertQuery = ""; |
| 156 | 156 | $arraySize = sizeof($data); |
| 157 | 157 | |
| 158 | - foreach ( $data as $key => $value ) |
|
| 158 | + foreach ($data as $key => $value) |
|
| 159 | 159 | { |
| 160 | 160 | $counter++; |
| 161 | - $insertQuery .= "'".self::sanitize($value) ."'"; |
|
| 162 | - if( $arraySize > $counter ) |
|
| 161 | + $insertQuery .= "'".self::sanitize($value)."'"; |
|
| 162 | + if ($arraySize > $counter) |
|
| 163 | 163 | $insertQuery .= ", "; |
| 164 | 164 | } |
| 165 | 165 | return $insertQuery; |
@@ -178,12 +178,12 @@ discard block |
||
| 178 | 178 | $updateQuery = ""; |
| 179 | 179 | $arraySize = sizeof($data); |
| 180 | 180 | |
| 181 | - foreach ( $data as $key => $value ) |
|
| 181 | + foreach ($data as $key => $value) |
|
| 182 | 182 | { |
| 183 | 183 | $counter++; |
| 184 | 184 | $columnName = self::checkColumn($tableName, self::sanitize($key)); |
| 185 | - $updateQuery .= $columnName ." = '".self::sanitize($value)."'"; |
|
| 186 | - if ( $arraySize > $counter ) |
|
| 185 | + $updateQuery .= $columnName." = '".self::sanitize($value)."'"; |
|
| 186 | + if ($arraySize > $counter) |
|
| 187 | 187 | { |
| 188 | 188 | $updateQuery .= ", "; |
| 189 | 189 | } |
@@ -212,14 +212,14 @@ discard block |
||
| 212 | 212 | $counter = 0; |
| 213 | 213 | $arraySize = sizeof($data); |
| 214 | 214 | |
| 215 | - foreach ( $data as $key => $value ) |
|
| 215 | + foreach ($data as $key => $value) |
|
| 216 | 216 | { |
| 217 | 217 | $counter++; |
| 218 | 218 | $columnName = self::checkColumn($tableName, self::sanitize($key)); |
| 219 | - $where .= $columnName ." = '".self::sanitize($value)."'"; |
|
| 220 | - if ( $arraySize > $counter ) |
|
| 219 | + $where .= $columnName." = '".self::sanitize($value)."'"; |
|
| 220 | + if ($arraySize > $counter) |
|
| 221 | 221 | { |
| 222 | - $where .= " " . $condition . " "; |
|
| 222 | + $where .= " ".$condition." "; |
|
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | |
@@ -237,16 +237,16 @@ discard block |
||
| 237 | 237 | try |
| 238 | 238 | { |
| 239 | 239 | $arraySize = sizeof($data); |
| 240 | - if( $arraySize > 1 && $condition == NULL) |
|
| 240 | + if ($arraySize > 1 && $condition == NULL) |
|
| 241 | 241 | { |
| 242 | 242 | $query = "Please Supply the condition"; |
| 243 | 243 | } |
| 244 | 244 | else |
| 245 | 245 | { |
| 246 | 246 | $columnName = self::whereAndClause($tableName, $data, $condition); |
| 247 | - $query = "SELECT * FROM $tableName WHERE $columnName"; |
|
| 247 | + $query = "SELECT * FROM $tableName WHERE $columnName"; |
|
| 248 | 248 | } |
| 249 | - } catch ( PDOException $e ) { |
|
| 249 | + } catch (PDOException $e) { |
|
| 250 | 250 | $query = $e->getMessage(); |
| 251 | 251 | } |
| 252 | 252 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | public function insertQuery($tableName) |
| 262 | 262 | { |
| 263 | - $data = ( array )$this; |
|
| 263 | + $data = (array)$this; |
|
| 264 | 264 | array_shift($data); |
| 265 | 265 | |
| 266 | 266 | $columnNames = self::buildColumn($data); |
@@ -277,11 +277,11 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | public function updateQuery($tableName) |
| 279 | 279 | { |
| 280 | - $data = ( array ) $this; |
|
| 281 | - $data = array_slice ($data, 2); |
|
| 280 | + $data = (array)$this; |
|
| 281 | + $data = array_slice($data, 2); |
|
| 282 | 282 | |
| 283 | 283 | $values = self::buildClause($tableName, $data); |
| 284 | - $updateQuery = "UPDATE $tableName SET {$values} WHERE id = ". self::sanitize($this->id); |
|
| 284 | + $updateQuery = "UPDATE $tableName SET {$values} WHERE id = ".self::sanitize($this->id); |
|
| 285 | 285 | |
| 286 | 286 | return $updateQuery; |
| 287 | 287 | } |
@@ -136,8 +136,9 @@ discard block |
||
| 136 | 136 | { |
| 137 | 137 | $counter++; |
| 138 | 138 | $insertQuery .= self::sanitize($key); |
| 139 | - if( $arraySize > $counter ) |
|
| 140 | - $insertQuery .= ", "; |
|
| 139 | + if( $arraySize > $counter ) { |
|
| 140 | + $insertQuery .= ", "; |
|
| 141 | + } |
|
| 141 | 142 | } |
| 142 | 143 | return $insertQuery; |
| 143 | 144 | } |
@@ -159,8 +160,9 @@ discard block |
||
| 159 | 160 | { |
| 160 | 161 | $counter++; |
| 161 | 162 | $insertQuery .= "'".self::sanitize($value) ."'"; |
| 162 | - if( $arraySize > $counter ) |
|
| 163 | - $insertQuery .= ", "; |
|
| 163 | + if( $arraySize > $counter ) { |
|
| 164 | + $insertQuery .= ", "; |
|
| 165 | + } |
|
| 164 | 166 | } |
| 165 | 167 | return $insertQuery; |
| 166 | 168 | } |
@@ -240,8 +242,7 @@ discard block |
||
| 240 | 242 | if( $arraySize > 1 && $condition == NULL) |
| 241 | 243 | { |
| 242 | 244 | $query = "Please Supply the condition"; |
| 243 | - } |
|
| 244 | - else |
|
| 245 | + } else |
|
| 245 | 246 | { |
| 246 | 247 | $columnName = self::whereAndClause($tableName, $data, $condition); |
| 247 | 248 | $query = "SELECT * FROM $tableName WHERE $columnName"; |
@@ -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|null |
|
| 66 | 67 | */ |
| 67 | 68 | public function getALL($dbConnection = NULL) |
| 68 | 69 | { |
@@ -90,7 +91,7 @@ discard block |
||
| 90 | 91 | * where($data, $condition) |
| 91 | 92 | * Get data from database where $data = $condition |
| 92 | 93 | * |
| 93 | - * @return object |
|
| 94 | + * @return GetData|null |
|
| 94 | 95 | */ |
| 95 | 96 | public function where($data, $condition = NULL, $dbConnection = NULL) |
| 96 | 97 | { |
@@ -121,7 +122,7 @@ discard block |
||
| 121 | 122 | * find($value) |
| 122 | 123 | * Find data from database where id = $value |
| 123 | 124 | * |
| 124 | - * @return array |
|
| 125 | + * @return Model|null |
|
| 125 | 126 | */ |
| 126 | 127 | public static function find($value, $dbConnection = NULL) |
| 127 | 128 | { |
@@ -9,8 +9,6 @@ |
||
| 9 | 9 | |
| 10 | 10 | namespace Ibonly\PotatoORM; |
| 11 | 11 | |
| 12 | -use PDO; |
|
| 13 | -use Exception; |
|
| 14 | 12 | use PDOException; |
| 15 | 13 | use Ibonly\PotatoORM\GetData; |
| 16 | 14 | use Ibonly\PotatoORM\DatabaseQuery; |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * PotatoORM manages the persistence of database CRUD operations. |
|
| 4 | - * |
|
| 5 | - * @package Ibonly\PotatoORM\Model |
|
| 6 | - * @author Ibraheem ADENIYI <[email protected]> |
|
| 7 | - * @license MIT <https://opensource.org/licenses/MIT> |
|
| 8 | - */ |
|
| 3 | + * PotatoORM manages the persistence of database CRUD operations. |
|
| 4 | + * |
|
| 5 | + * @package Ibonly\PotatoORM\Model |
|
| 6 | + * @author Ibraheem ADENIYI <[email protected]> |
|
| 7 | + * @license MIT <https://opensource.org/licenses/MIT> |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | namespace Ibonly\PotatoORM; |
| 11 | 11 | |
@@ -72,16 +72,16 @@ discard block |
||
| 72 | 72 | $sqlQuery = DatabaseQuery::selectAllQuery(self::getTableName($connection)); |
| 73 | 73 | $query = $connection->prepare($sqlQuery); |
| 74 | 74 | $query->execute(); |
| 75 | - if ( $query->rowCount() ) |
|
| 75 | + if ($query->rowCount()) |
|
| 76 | 76 | { |
| 77 | 77 | return new GetData($query->fetchAll($connection::FETCH_ASSOC)); |
| 78 | 78 | } |
| 79 | 79 | throw new EmptyDatabaseException(); |
| 80 | - } catch ( EmptyDatabaseException $e ){ |
|
| 80 | + } catch (EmptyDatabaseException $e) { |
|
| 81 | 81 | echo $e->errorMessage(); |
| 82 | - } catch ( TableDoesNotExistException $e ){ |
|
| 82 | + } catch (TableDoesNotExistException $e) { |
|
| 83 | 83 | echo $e->errorMessage(); |
| 84 | - } catch ( InvalidConnectionException $e ){ |
|
| 84 | + } catch (InvalidConnectionException $e) { |
|
| 85 | 85 | echo $e->errorMessage(); |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -101,18 +101,18 @@ discard block |
||
| 101 | 101 | $sqlQuery = $databaseQuery->selectQuery(self::getTableName($connection), $data, $condition, $connection); |
| 102 | 102 | $query = $connection->prepare($sqlQuery); |
| 103 | 103 | $query->execute(); |
| 104 | - if ( $query->rowCount() ) |
|
| 104 | + if ($query->rowCount()) |
|
| 105 | 105 | { |
| 106 | 106 | return new GetData($query->fetchAll($connection::FETCH_ASSOC)); |
| 107 | 107 | } |
| 108 | 108 | throw new UserNotFoundException(); |
| 109 | - } catch ( UserNotFoundException $e ){ |
|
| 109 | + } catch (UserNotFoundException $e) { |
|
| 110 | 110 | echo $e->errorMessage(); |
| 111 | - } catch ( TableDoesNotExistException $e ){ |
|
| 111 | + } catch (TableDoesNotExistException $e) { |
|
| 112 | 112 | echo $e->errorMessage(); |
| 113 | - } catch ( InvalidConnectionException $e ){ |
|
| 113 | + } catch (InvalidConnectionException $e) { |
|
| 114 | 114 | echo $e->errorMessage(); |
| 115 | - } catch ( ColumnNotExistExeption $e ){ |
|
| 115 | + } catch (ColumnNotExistExeption $e) { |
|
| 116 | 116 | echo $e->errorMessage(); |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $sqlQuery = DatabaseQuery::selectQuery(self::getTableName($connection), 'id', $value, $connection); |
| 132 | 132 | $query = $connection->prepare($sqlQuery); |
| 133 | 133 | $query->execute(); |
| 134 | - if ( $query->rowCount() ) |
|
| 134 | + if ($query->rowCount()) |
|
| 135 | 135 | { |
| 136 | 136 | $found = new static; |
| 137 | 137 | $found->id = $value; |
@@ -139,13 +139,13 @@ discard block |
||
| 139 | 139 | return $found; |
| 140 | 140 | } |
| 141 | 141 | throw new UserNotFoundException(); |
| 142 | - } catch ( UserNotFoundException $e ){ |
|
| 142 | + } catch (UserNotFoundException $e) { |
|
| 143 | 143 | echo $e->errorMessage(); |
| 144 | - } catch ( TableDoesNotExistException $e ){ |
|
| 144 | + } catch (TableDoesNotExistException $e) { |
|
| 145 | 145 | echo $e->errorMessage(); |
| 146 | - } catch ( InvalidConnectionException $e ){ |
|
| 146 | + } catch (InvalidConnectionException $e) { |
|
| 147 | 147 | echo $e->errorMessage(); |
| 148 | - } catch ( ColumnNotExistExeption $e ){ |
|
| 148 | + } catch (ColumnNotExistExeption $e) { |
|
| 149 | 149 | echo $e->errorMessage(); |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -163,21 +163,21 @@ discard block |
||
| 163 | 163 | { |
| 164 | 164 | $query = $this->insertQuery(self::getTableName($connection)); |
| 165 | 165 | $statement = $connection->prepare($query); |
| 166 | - if( $statement->execute() ) |
|
| 166 | + if ($statement->execute()) |
|
| 167 | 167 | { |
| 168 | 168 | return true; |
| 169 | 169 | } |
| 170 | 170 | throw new SaveUserExistException(); |
| 171 | 171 | |
| 172 | - } catch ( PDOException $e ){ |
|
| 172 | + } catch (PDOException $e) { |
|
| 173 | 173 | throw new SaveUserExistException($e->getMessage()); |
| 174 | - } catch( SaveUserExistException $e ) { |
|
| 174 | + } catch (SaveUserExistException $e) { |
|
| 175 | 175 | return $e->getMessage(); |
| 176 | - } catch ( TableDoesNotExistException $e ){ |
|
| 176 | + } catch (TableDoesNotExistException $e) { |
|
| 177 | 177 | echo $e->errorMessage(); |
| 178 | - } catch ( InvalidConnectionException $e ){ |
|
| 178 | + } catch (InvalidConnectionException $e) { |
|
| 179 | 179 | echo $e->errorMessage(); |
| 180 | - } catch ( ColumnNotExistExeption $e ){ |
|
| 180 | + } catch (ColumnNotExistExeption $e) { |
|
| 181 | 181 | echo $e->errorMessage(); |
| 182 | 182 | } |
| 183 | 183 | } |
@@ -195,21 +195,21 @@ discard block |
||
| 195 | 195 | { |
| 196 | 196 | $updateQuery = $this->updateQuery(self::getTableName($connection)); |
| 197 | 197 | $statement = $connection->prepare($updateQuery); |
| 198 | - if( $statement->execute() ) |
|
| 198 | + if ($statement->execute()) |
|
| 199 | 199 | { |
| 200 | 200 | return true; |
| 201 | 201 | } |
| 202 | 202 | throw new SaveUserExistException(); |
| 203 | 203 | |
| 204 | - } catch ( PDOException $e ){ |
|
| 204 | + } catch (PDOException $e) { |
|
| 205 | 205 | throw new SaveUserExistException($e->getMessage()); |
| 206 | - } catch( SaveUserExistException $e ) { |
|
| 206 | + } catch (SaveUserExistException $e) { |
|
| 207 | 207 | return $e->getMessage(); |
| 208 | - } catch ( TableDoesNotExistException $e ){ |
|
| 208 | + } catch (TableDoesNotExistException $e) { |
|
| 209 | 209 | echo $e->errorMessage(); |
| 210 | - } catch ( InvalidConnectionException $e ){ |
|
| 210 | + } catch (InvalidConnectionException $e) { |
|
| 211 | 211 | echo $e->errorMessage(); |
| 212 | - } catch ( ColumnNotExistExeption $e ){ |
|
| 212 | + } catch (ColumnNotExistExeption $e) { |
|
| 213 | 213 | echo $e->errorMessage(); |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | $connection = DatabaseQuery::checkConnection($dbConnection); |
| 226 | 226 | try |
| 227 | 227 | { |
| 228 | - $query = $connection->prepare('DELETE FROM ' . self::getTableName($connection) . ' WHERE id = '.$value); |
|
| 228 | + $query = $connection->prepare('DELETE FROM '.self::getTableName($connection).' WHERE id = '.$value); |
|
| 229 | 229 | $query->execute(); |
| 230 | 230 | $check = $query->rowCount(); |
| 231 | 231 | if ($check) |
@@ -233,13 +233,13 @@ discard block |
||
| 233 | 233 | return true; |
| 234 | 234 | } |
| 235 | 235 | throw new UserNotFoundException; |
| 236 | - } catch ( UserNotFoundException $e ) { |
|
| 236 | + } catch (UserNotFoundException $e) { |
|
| 237 | 237 | return $e->errorMessage(); |
| 238 | - } catch ( TableDoesNotExistException $e ){ |
|
| 238 | + } catch (TableDoesNotExistException $e) { |
|
| 239 | 239 | echo $e->errorMessage(); |
| 240 | - } catch ( InvalidConnectionException $e ){ |
|
| 240 | + } catch (InvalidConnectionException $e) { |
|
| 241 | 241 | echo $e->errorMessage(); |
| 242 | - } catch ( ColumnNotExistExeption $e ){ |
|
| 242 | + } catch (ColumnNotExistExeption $e) { |
|
| 243 | 243 | echo $e->errorMessage(); |
| 244 | 244 | } |
| 245 | 245 | } |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | echo $e->errorMessage(); |
| 111 | 111 | } catch ( TableDoesNotExistException $e ){ |
| 112 | 112 | echo $e->errorMessage(); |
| 113 | - } catch ( InvalidConnectionException $e ){ |
|
| 113 | + } catch ( InvalidConnectionException $e ){ |
|
| 114 | 114 | echo $e->errorMessage(); |
| 115 | - } catch ( ColumnNotExistExeption $e ){ |
|
| 115 | + } catch ( ColumnNotExistExeption $e ){ |
|
| 116 | 116 | echo $e->errorMessage(); |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | echo $e->errorMessage(); |
| 144 | 144 | } catch ( TableDoesNotExistException $e ){ |
| 145 | 145 | echo $e->errorMessage(); |
| 146 | - } catch ( InvalidConnectionException $e ){ |
|
| 146 | + } catch ( InvalidConnectionException $e ){ |
|
| 147 | 147 | echo $e->errorMessage(); |
| 148 | - } catch ( ColumnNotExistExeption $e ){ |
|
| 148 | + } catch ( ColumnNotExistExeption $e ){ |
|
| 149 | 149 | echo $e->errorMessage(); |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -175,9 +175,9 @@ discard block |
||
| 175 | 175 | return $e->getMessage(); |
| 176 | 176 | } catch ( TableDoesNotExistException $e ){ |
| 177 | 177 | echo $e->errorMessage(); |
| 178 | - } catch ( InvalidConnectionException $e ){ |
|
| 178 | + } catch ( InvalidConnectionException $e ){ |
|
| 179 | 179 | echo $e->errorMessage(); |
| 180 | - } catch ( ColumnNotExistExeption $e ){ |
|
| 180 | + } catch ( ColumnNotExistExeption $e ){ |
|
| 181 | 181 | echo $e->errorMessage(); |
| 182 | 182 | } |
| 183 | 183 | } |
@@ -207,9 +207,9 @@ discard block |
||
| 207 | 207 | return $e->getMessage(); |
| 208 | 208 | } catch ( TableDoesNotExistException $e ){ |
| 209 | 209 | echo $e->errorMessage(); |
| 210 | - } catch ( InvalidConnectionException $e ){ |
|
| 210 | + } catch ( InvalidConnectionException $e ){ |
|
| 211 | 211 | echo $e->errorMessage(); |
| 212 | - } catch ( ColumnNotExistExeption $e ){ |
|
| 212 | + } catch ( ColumnNotExistExeption $e ){ |
|
| 213 | 213 | echo $e->errorMessage(); |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -237,9 +237,9 @@ discard block |
||
| 237 | 237 | return $e->errorMessage(); |
| 238 | 238 | } catch ( TableDoesNotExistException $e ){ |
| 239 | 239 | echo $e->errorMessage(); |
| 240 | - } catch ( InvalidConnectionException $e ){ |
|
| 240 | + } catch ( InvalidConnectionException $e ){ |
|
| 241 | 241 | echo $e->errorMessage(); |
| 242 | - } catch ( ColumnNotExistExeption $e ){ |
|
| 242 | + } catch ( ColumnNotExistExeption $e ){ |
|
| 243 | 243 | echo $e->errorMessage(); |
| 244 | 244 | } |
| 245 | 245 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | parent::__construct($this->mysqlConnectionString(), $this->user, $this->password); |
| 49 | 49 | } |
| 50 | - elseif($this->driver === 'sqlite') |
|
| 50 | + elseif ($this->driver === 'sqlite') |
|
| 51 | 51 | { |
| 52 | 52 | parent::__construct($this->sqlitConnectionString()); |
| 53 | 53 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | protected function pgsqlConnectionString() |
| 65 | 65 | { |
| 66 | - return $this->driver . ':host=' . $this->host . ';port=' . $this->port . ';dbname=' . $this->dbname . ';user=' . $this->user . ';password=' . $this->password; |
|
| 66 | + return $this->driver.':host='.$this->host.';port='.$this->port.';dbname='.$this->dbname.';user='.$this->user.';password='.$this->password; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | protected function mysqlConnectionString() |
| 75 | 75 | { |
| 76 | - return $this->driver . ':host=' . $this->host . ';dbname=' . $this->dbname . ';charset=utf8mb4'; |
|
| 76 | + return $this->driver.':host='.$this->host.';dbname='.$this->dbname.';charset=utf8mb4'; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | protected function sqlitConnectionString() |
| 85 | 85 | { |
| 86 | - return $this->driver . ':' . $this->sqlitePath; |
|
| 86 | + return $this->driver.':'.$this->sqlitePath; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | protected function loadEnv() |
| 93 | 93 | { |
| 94 | - if( ! getenv("APP_ENV" !== "production")) |
|
| 94 | + if ( ! getenv("APP_ENV" !== "production")) |
|
| 95 | 95 | { |
| 96 | - $dotenv = new Dotenv(__DIR__ . "/../../"); |
|
| 96 | + $dotenv = new Dotenv(__DIR__."/../../"); |
|
| 97 | 97 | $dotenv->load(); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -42,12 +42,10 @@ |
||
| 42 | 42 | if ($this->driver === 'pgsql' || $this->driver === 'postgres') |
| 43 | 43 | { |
| 44 | 44 | parent::__construct($this->pgsqlConnectionString()); |
| 45 | - } |
|
| 46 | - elseif ($this->driver === 'mysql') |
|
| 45 | + } elseif ($this->driver === 'mysql') |
|
| 47 | 46 | { |
| 48 | 47 | parent::__construct($this->mysqlConnectionString(), $this->user, $this->password); |
| 49 | - } |
|
| 50 | - elseif($this->driver === 'sqlite') |
|
| 48 | + } elseif($this->driver === 'sqlite') |
|
| 51 | 49 | { |
| 52 | 50 | parent::__construct($this->sqlitConnectionString()); |
| 53 | 51 | } |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Exception for user not found |
|
| 4 | - * |
|
| 5 | - * @package Ibonly\PotatoORM\ColumnNotExistExeption |
|
| 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\ColumnNotExistExeption |
|
| 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 no records in database |
|
| 4 | - * |
|
| 5 | - * @package Ibonly\PotatoORM\EmptyDatabaseException |
|
| 6 | - * @author Ibraheem ADENIYI <[email protected]> |
|
| 7 | - * @license MIT <https://opensource.org/licenses/MIT> |
|
| 8 | - */ |
|
| 3 | + * Exception for no records in database |
|
| 4 | + * |
|
| 5 | + * @package Ibonly\PotatoORM\EmptyDatabaseException |
|
| 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 already exist |
|
| 4 | - * |
|
| 5 | - * @package Ibonly\PotatoORM\ErrorInsertingException |
|
| 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\ErrorInsertingException |
|
| 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\InvalidConnectionException |
|
| 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\InvalidConnectionException |
|
| 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\SaveUserExistException |
|
| 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\SaveUserExistException |
|
| 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\TableDoesNotExistException |
|
| 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\TableDoesNotExistException |
|
| 6 | + * @author Ibraheem ADENIYI <[email protected]> |
|
| 7 | + * @license MIT <https://opensource.org/licenses/MIT> |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | namespace Ibonly\PotatoORM; |
| 11 | 11 | |