|
@@ 131-146 (lines=16) @@
|
| 128 |
|
* @return string Table column name |
| 129 |
|
* @throws \InvalidArgumentException |
| 130 |
|
*/ |
| 131 |
|
public function getTableColumnName(string $columnNameOrAlias) : string |
| 132 |
|
{ |
| 133 |
|
// Case insensitive search |
| 134 |
|
if ($this->isColumnAliasExists($columnNameOrAlias)) { |
| 135 |
|
return $this->lowerColumnAliases[strtolower($columnNameOrAlias)]; |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
// Search real column names |
| 139 |
|
if ($this->isColumnNameExists($columnNameOrAlias)) { |
| 140 |
|
return $columnNameOrAlias; |
| 141 |
|
} |
| 142 |
|
|
| 143 |
|
throw new \InvalidArgumentException( |
| 144 |
|
'Column ' . $columnNameOrAlias . ' not found in table ' . $this->tableName |
| 145 |
|
); |
| 146 |
|
} |
| 147 |
|
|
| 148 |
|
/** |
| 149 |
|
* Get table column alias by column name or alias. |
|
@@ 156-171 (lines=16) @@
|
| 153 |
|
* @return string Table column alias |
| 154 |
|
* @throws \InvalidArgumentException |
| 155 |
|
*/ |
| 156 |
|
public function getTableColumnAlias(string $columnNameOrAlias) : string |
| 157 |
|
{ |
| 158 |
|
// Case insensitive search |
| 159 |
|
if ($this->isColumnAliasExists($columnNameOrAlias)) { |
| 160 |
|
return $columnNameOrAlias; |
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
// Search real column names |
| 164 |
|
if ($this->isColumnNameExists($columnNameOrAlias)) { |
| 165 |
|
return array_flip($this->columnAliases)[$columnNameOrAlias]; |
| 166 |
|
} |
| 167 |
|
|
| 168 |
|
throw new \InvalidArgumentException( |
| 169 |
|
'Column ' . $columnNameOrAlias . ' not found in table ' . $this->tableName |
| 170 |
|
); |
| 171 |
|
} |
| 172 |
|
|
| 173 |
|
/** |
| 174 |
|
* Get table primary field name. |