| @@ 109-116 (lines=8) @@ | ||
| 106 | * |
|
| 107 | * @return array All the records in the table. |
|
| 108 | */ |
|
| 109 | public function getAllRecords($table) |
|
| 110 | { |
|
| 111 | if (gettype($table) !== 'string') { |
|
| 112 | throw new InvalidArgumentException("The parameter {$table} is not a string. A string is required instead."); |
|
| 113 | } |
|
| 114 | ||
| 115 | return $this->getPdo()->query("SELECT * FROM {$table}")->fetchAll(); |
|
| 116 | } |
|
| 117 | ||
| 118 | /** |
|
| 119 | * Update a record in the database. |
|
| @@ 42-52 (lines=11) @@ | ||
| 39 | * |
|
| 40 | * @return array The columns of the table. |
|
| 41 | */ |
|
| 42 | public function getColumns($table) |
|
| 43 | { |
|
| 44 | if (gettype($table) !== 'string') { |
|
| 45 | throw new InvalidArgumentException("The parameter {$table} is not an string. A string is required instead."); |
|
| 46 | } |
|
| 47 | ||
| 48 | return $this->getPdo()->query("SELECT COLUMN_NAME |
|
| 49 | FROM INFORMATION_SCHEMA.COLUMNS |
|
| 50 | WHERE TABLE_NAME = N'{$table}' |
|
| 51 | AND TABLE_SCHEMA = N'{$this->_database}'")->fetchAll(); |
|
| 52 | } |
|
| 53 | ||
| 54 | /** |
|
| 55 | * Returns the Connection's PDO. |
|
| @@ 71-78 (lines=8) @@ | ||
| 68 | * |
|
| 69 | * @return string The primary key of the table. |
|
| 70 | */ |
|
| 71 | public function getPrimaryKey($table) |
|
| 72 | { |
|
| 73 | if (gettype($table) !== 'string') { |
|
| 74 | throw new InvalidArgumentException("The parameter {$table} is not an string. A string is required instead."); |
|
| 75 | } |
|
| 76 | ||
| 77 | return $this->getPdo()->query("SHOW KEYS FROM {$table} WHERE Key_name = 'PRIMARY'")->fetchAll()[0]['Column_name']; |
|
| 78 | } |
|
| 79 | ||
| 80 | public static function load() |
|
| 81 | { |
|
| @@ 41-50 (lines=10) @@ | ||
| 38 | * |
|
| 39 | * @return array The columns of the table. |
|
| 40 | */ |
|
| 41 | public function getColumns($table) |
|
| 42 | { |
|
| 43 | if (gettype($table) !== 'string') { |
|
| 44 | throw new InvalidArgumentException("The parameter {$table} is not an string. A string is required instead."); |
|
| 45 | } |
|
| 46 | ||
| 47 | return $this->getPdo()->query("SELECT COLUMN_NAME |
|
| 48 | FROM {$this->_database}.INFORMATION_SCHEMA.COLUMNS |
|
| 49 | WHERE TABLE_NAME = N'{$table}'")->fetchAll(); |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * Returns the Connection's PDO. |
|