I want to do something like that in Laravel (valid sqlite query):
select * from 'tbUsers' where length(name)>50;
I tried
User::with('Permissons')->where('LENGTH(name)','>','50')->get();
But it seems not to work........
note: other queries works without problem:
User::with('Permissons')->where('active','=','1')->get();
You can use laravel helper method Str::length() to find string length or you can use php strlen() method .
$wordlist = Wordlist::where('id', '<=', $correctedComparisons)->get(); $wordCount = $wordlist->count(); The Count Number Of Rows Laravel Controller was solved using a number of scenarios, as we have seen.
The Eloquent ORM included with Laravel provides a beautiful, simple ActiveRecord implementation for working with your database. Each database table has a corresponding "Model" which is used to interact with that table. Before getting started, be sure to configure a database connection in config/database. php .
DB::raw() is used to make arbitrary SQL commands which aren't parsed any further by the query builder. They therefore can create a vector for attack via SQL injection. So in my example I guess that the query with DB::raw is faster since laravel doesn't check or validate anything.
Try this
whereRaw( string $sql, array $bindings = array(), string $boolean = 'and')
User::with('Permissons')->whereRaw('LENGTH(name) > 50')->get();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With