2
I wonder if there is any way to know if a column exists or not in the Laravel
.
For example, I want to sort data from the query string. If the value "column" exists in the table, then I sort by this field.
$coluna = Input::get('coluna');
if (se_a_coluna_existe_na_tabela('usuarios', $coluna))
{
$query->orderBy($coluna);
}
Back to the dark side of the force :( :D
– Maniero
No, actually I am leaving PHP gradually. I already downloaded the full Visual Studio and I will install it on my home PC. :)
– Wallace Maxters
@bigown we all know that in the end the dark side loses :D
– Guilherme Lautert
@Guilhermelautert not until the last episode :P
– Bacco
In this case, it would be an incorrect parameter, I believe the best way is to try to order, and capture the exception, if there is no column (If you do not want the user to know that you screwed up...)
– mau humor
@mauhumor well, it’s a good idea. I can also catch the
QueryException
and bring a message to the user– Wallace Maxters
Who gave the negative, could inform what is wrong with the question?
– Wallace Maxters