Hallo everyone,
Im new to this forum, but not new to PHP, I do a lot programming in it, but sometimes I have to less knowledge to solve the problems I get.
The title is not very explained what my problem is, so mods, edit it if you want.
The problem
The goal I currently aim in the code I write is to build a dynamic query. Dynamic, because the user can choose to want other output or values.
To archive my goal, I found this query builder: http://code.google.com/p/mqb/ and I found this one working very well. (Found more query builders, but this one is the only one - i think - that works for me)
In this code I want my if else:
$query = query::select()
->field("u.u_id")->as("id")
->field("u.uren_begin")->as("begin")
->field("u.uren_eind")->as("eind")
->field("l.u_voornaam")->as("voornaam")
->field("loc.loc_naam")->as("vestiging")
->from("uren")->as("u")
->join
(
query::select()
->from("login")->as("l")
->where("l.u_id")->equals(new field("u.u_id"))
)
->join
(
query::select()
->from("locaties")->as("loc")
->where("l.u_locatie")->equals(new field("loc.loc_id"))
);
;
What I want is within this code or else an if else statement, like adding and ->join when some statement is true
Now I show you a sample to add to the above code: (and that is not possible I know, but you know what I want)
if($something) { // when true, add a join
->join
(
query::select()
->from("something")->as("s")
->where("s.usefull")->equals(new field("a.avalue"))
)
}
As you know that would never work. My question is now, can you help me to archive such a manner of if else in this code?
Thanks in advance