php - laarvel query builder output is messy -


i'm new laravel framework , faced problem , when send query results in form :

[{"visitors":3}] 

here code used result :

<?php echo $q = db::table('visitors')->select('visitors')->get(); ?> 

is there missed ?

this not best practice

<?php echo $q = db::table('visitors')->select('visitors')->get(); ?> 

following mvc pattern, should query in controller,

$q = db::table('visitors')->select('visitors')->get(); 

then pass $q in view. loop through $q results. if need specific result, $id = 3, use where.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -