How to retrieve using multiple conditions

Permalink
I found [$list->filterByStudentFirstName('Andrew');] from the following link.

https://documentation.concrete5.org/developers/express/creating-read...


How to retrieve data with multiple conditions?

 
mnakalay replied on at Permalink Best Answer Reply
mnakalay
The simplest would be to repeat the same line several times before getting the result
$list->filterByStudentFirstName('Andrew');
$list->filterByStudentFirstName('Robert');
$results = $list->getResults();

Another possibility, but I didn't test it would be
$list->filterByStudentFirstName("('Andrew','Robert')", "in");
$results = $list->getResults();

It might work but like I said, I didn't test it.
davidkham replied on at Permalink Reply
Is it the following that you mean?

$list->filterByStudentID(1);
$list->filterByStudentFirstName('Andrew');
$list->filterByStudentExamResult(100);


I would like to replace instead of sql query [select * from student where studentid='1' and studentfirstname='Andrew' and studentexamresult=100] with concrete5 retrieve format.
mnakalay replied on at Permalink Reply
mnakalay
Yes except once you filtered by ID you probably don't need the other stuff as most likely each ID is unique and only one student has it.

In the example I gave you would get all students with first name Andrew OR Robert
davidkham replied on at Permalink Reply
Thank for the reply.

how to loop and retrieve $results?
mnakalay replied on at Permalink Reply
mnakalay
foreach ($results as $result)
{
    // do something with current $result
}