@@ -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 | } |
@@ -39,13 +39,13 @@ discard block |
||
| 39 | 39 | trait Inflector |
| 40 | 40 | { |
| 41 | 41 | /** |
| 42 | - * Pluralizes English nouns. |
|
| 43 | - * |
|
| 44 | - * @access public |
|
| 45 | - * @static |
|
| 46 | - * @param string $word English noun to pluralize |
|
| 47 | - * @return string Plural noun |
|
| 48 | - */ |
|
| 42 | + * Pluralizes English nouns. |
|
| 43 | + * |
|
| 44 | + * @access public |
|
| 45 | + * @static |
|
| 46 | + * @param string $word English noun to pluralize |
|
| 47 | + * @return string Plural noun |
|
| 48 | + */ |
|
| 49 | 49 | public static function pluralize($word) |
| 50 | 50 | { |
| 51 | 51 | $plural = array( |
@@ -102,13 +102,13 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | - * Singularizes English nouns. |
|
| 106 | - * |
|
| 107 | - * @access public |
|
| 108 | - * @static |
|
| 109 | - * @param string $word English noun to singularize |
|
| 110 | - * @return string Singular noun. |
|
| 111 | - */ |
|
| 105 | + * Singularizes English nouns. |
|
| 106 | + * |
|
| 107 | + * @access public |
|
| 108 | + * @static |
|
| 109 | + * @param string $word English noun to singularize |
|
| 110 | + * @return string Singular noun. |
|
| 111 | + */ |
|
| 112 | 112 | public function singularize($word) |
| 113 | 113 | { |
| 114 | 114 | $singular = array ( |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | if(is_null($length)){ |
| 31 | 31 | $this->fieldDescription[] = $type ." ".$fieldName; |
| 32 | - }else |
|
| 32 | + } else |
|
| 33 | 33 | { |
| 34 | 34 | $this->fieldDescription[] = $type ." ".$fieldName." ".$length; |
| 35 | 35 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | if(sizeof($e) == 2) |
| 53 | 53 | { |
| 54 | 54 | $query .= $this->$e[0]($e[1], 20) .", ".PHP_EOL; |
| 55 | - }else |
|
| 55 | + } else |
|
| 56 | 56 | { |
| 57 | 57 | $query .= $this->$e[0]($e[1], $e[2]) .", ".PHP_EOL; |
| 58 | 58 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | { |
| 95 | 95 | return true; |
| 96 | 96 | } |
| 97 | - }catch(PDOException $e){ |
|
| 97 | + } catch(PDOException $e){ |
|
| 98 | 98 | return $e->getMessage(); |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -28,10 +28,10 @@ |
||
| 28 | 28 | public function field($type, $fieldName, $length=NULL) |
| 29 | 29 | { |
| 30 | 30 | if($length === null){ |
| 31 | - $this->fieldDescription[] = $type ." ".$fieldName; |
|
| 31 | + $this->fieldDescription[] = $type ." ".$fieldName; |
|
| 32 | 32 | }else |
| 33 | 33 | { |
| 34 | - $this->fieldDescription[] = $type ." ".$fieldName." ".$length; |
|
| 34 | + $this->fieldDescription[] = $type ." ".$fieldName." ".$length; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | } |
@@ -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 |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | interface GetDataInterface |
| 13 | 13 | { |
| 14 | - public function all(); |
|
| 14 | + public function all(); |
|
| 15 | 15 | |
| 16 | 16 | public function allDESC($limit); |
| 17 | 17 | |
@@ -23,5 +23,5 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | public function first(); |
| 25 | 25 | |
| 26 | - public function getCount(); |
|
| 26 | + public function getCount(); |
|
| 27 | 27 | } |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | |
| 12 | 12 | interface RelationshipsInterface |
| 13 | 13 | { |
| 14 | - public function joinClause(); |
|
| 14 | + public function joinClause(); |
|
| 15 | 15 | |
| 16 | 16 | public function whereClause($data, $condition); |
| 17 | 17 | } |
| 18 | 18 | \ No newline at end of file |
@@ -216,8 +216,9 @@ discard block |
||
| 216 | 216 | { |
| 217 | 217 | $counter++; |
| 218 | 218 | $insertQuery .= self::sanitize($key); |
| 219 | - if($arraySize > $counter) |
|
| 220 | - $insertQuery .= ", "; |
|
| 219 | + if($arraySize > $counter) { |
|
| 220 | + $insertQuery .= ", "; |
|
| 221 | + } |
|
| 221 | 222 | } |
| 222 | 223 | |
| 223 | 224 | return $insertQuery; |
@@ -241,8 +242,9 @@ discard block |
||
| 241 | 242 | { |
| 242 | 243 | $counter++; |
| 243 | 244 | $insertQuery .= "'".self::sanitize($value) ."'"; |
| 244 | - if($arraySize > $counter) |
|
| 245 | - $insertQuery .= ", "; |
|
| 245 | + if($arraySize > $counter) { |
|
| 246 | + $insertQuery .= ", "; |
|
| 247 | + } |
|
| 246 | 248 | } |
| 247 | 249 | return $insertQuery; |
| 248 | 250 | } |
@@ -326,8 +328,7 @@ discard block |
||
| 326 | 328 | if($arraySize > 1 && $condition == NULL) |
| 327 | 329 | { |
| 328 | 330 | $query = "Please Supply the condition"; |
| 329 | - } |
|
| 330 | - else |
|
| 331 | + } else |
|
| 331 | 332 | { |
| 332 | 333 | $columnName = self::whereAndClause($tableName, $data, $condition); |
| 333 | 334 | $query = "SELECT $fields FROM $tableName WHERE $columnName"; |
@@ -25,36 +25,36 @@ |
||
| 25 | 25 | $i = 0; |
| 26 | 26 | |
| 27 | 27 | if ($data[0]->REFERENCED_TABLE_NAME !== null) { |
| 28 | - $arraySize = count($data); |
|
| 29 | - |
|
| 30 | - foreach($data as $key => $value) { |
|
| 31 | - $output .= ' JOIN '.$value->REFERENCED_TABLE_NAME; |
|
| 32 | - } |
|
| 33 | - foreach($data as $key => $value) { |
|
| 34 | - $i++; |
|
| 35 | - $whereAnd = $i > 1 ? 'AND' : 'WHERE'; |
|
| 36 | - $output .= ' '.$whereAnd.' '.self::getTableName($connection).'.'.$value->COLUMN_NAME.'='.$value->REFERENCED_TABLE_NAME.'.'.$value->REFERENCED_COLUMN_NAME.' '; |
|
| 37 | - } |
|
| 38 | - } else { |
|
| 39 | - $output = false; |
|
| 40 | - } |
|
| 28 | + $arraySize = count($data); |
|
| 29 | + |
|
| 30 | + foreach($data as $key => $value) { |
|
| 31 | + $output .= ' JOIN '.$value->REFERENCED_TABLE_NAME; |
|
| 32 | + } |
|
| 33 | + foreach($data as $key => $value) { |
|
| 34 | + $i++; |
|
| 35 | + $whereAnd = $i > 1 ? 'AND' : 'WHERE'; |
|
| 36 | + $output .= ' '.$whereAnd.' '.self::getTableName($connection).'.'.$value->COLUMN_NAME.'='.$value->REFERENCED_TABLE_NAME.'.'.$value->REFERENCED_COLUMN_NAME.' '; |
|
| 37 | + } |
|
| 38 | + } else { |
|
| 39 | + $output = false; |
|
| 40 | + } |
|
| 41 | 41 | return $output; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function whereClause($data = null, $condition = null, $con = null) |
| 45 | 45 | { |
| 46 | - $joinClause = self::joinClause(); |
|
| 46 | + $joinClause = self::joinClause(); |
|
| 47 | 47 | $connection = self::checkConnection($con); |
| 48 | 48 | $tableName = self::getTableName($connection); |
| 49 | 49 | $columnName = self::whereAndClause($tableName, $data, $condition); |
| 50 | 50 | |
| 51 | - $query = 'SELECT * FROM '.$tableName; |
|
| 51 | + $query = 'SELECT * FROM '.$tableName; |
|
| 52 | 52 | |
| 53 | - if (! $joinClause) { |
|
| 54 | - $query .= ' WHERE '.$columnName; |
|
| 55 | - } else { |
|
| 56 | - $query .= ($data === null) ? $joinClause : $joinClause .' AND '.$columnName; |
|
| 57 | - } |
|
| 58 | - return $query; |
|
| 53 | + if (! $joinClause) { |
|
| 54 | + $query .= ' WHERE '.$columnName; |
|
| 55 | + } else { |
|
| 56 | + $query .= ($data === null) ? $joinClause : $joinClause .' AND '.$columnName; |
|
| 57 | + } |
|
| 58 | + return $query; |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | \ No newline at end of file |