PDO BindValue without adding to query!

Mesmereyesed

New Member
Im trying to find out the best way to execute these types of queriesWhat I want to do is build a filter type function where i was in an array and the query is constructed!the problem is with PDO before you can bind a value you need to prepare the statement, but if i prepare the statement I cant change the query.Let me show you an example:\[code\]public function GetFeedsByFilter($filter = array()){ //Base Query $Query = 'SELECT feeds,sites,users,categories WHERE feed_site_id = site_id AND feed_uid = user_id AND feed_category_id = category_id'; if(isset($filter['limit'])){$filter['limit'] = 30;} //Setters //Check the different filters if(isset($filter['category'])) { //Here I want to bind the category //i can do the following $Query .= ' AND category_id = :cid'; //But now I cant bind the value with $statement->bindValue }}\[/code\]now I can first construct the string for the query then do all the if statements to bind them but that's way to much!Any ideas how I can overcome this issue ?
 
Back
Top