You should elaborate on the "this doesn't work".
Sorry, I get an:
#ErrorException
#Use of undefined constant MyModelName - assumed 'MyModelName'
It crashes on there line where I put $history = MyModelName;
Normally, I would do this:
#$history = MyModelName::where($ary[0],$ary[1],$ary[2])
but I can't in this circumstance because I don't have any definite knowledge of which of the search params will be coming thru.
Wade
Yep, you need to create a new instance of your model.
Ok, dum dum on my part. I did that, but now I'm not getting valid data yet.
$history = new MyModelName;
$history->where('content','like','%test%');
$history->get();
print_r($history);
Returns a null array. However, if I do this:
print_r(MyModelName::where('content','like','%test%')->get());
I receive a full data set of my two test records.
Wade
$history->where('content','like','%test%'); // fixed '%test'%
Not sure what you mean. My line was correct.
Anyway, I figured out the problem.
The below line works.
$history = new MyModelName;
$history->where('content','like','%test%');
$tmp = $history->get();
print_r($tmp);
This also works:
$history = new MyModelName;
$history->where('content','like','%test%');
print_r($history->get());
Thanks for the help everyone.
Wade
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community