I have an integer array containing id values, that I want to search a mixed database by. In pseudocode this would be :
prepare -> Select * From dataset Where id= :NextArrayValue
For all ArrayValues.
I have been googling this question for a while now. I understand how to perform this operation with a single value, or hardcoded as a finite list of values, using bindParam.
I don't want to spam the database with reconnects. I want to return the desired rows by using a single prepared statement that I execute once, and can refer to later. Ideally I would want a function that operates similarly to bindValue, that will repeat the operation for all values of an integer array. Here is a rough draft of what I am trying to do:
$body_array = array();//how do I cast this to text/string? Should I?
$wage_array = array();
$email_array = array();
$title_array = array();
$get_posts = $db2->prepare("SELECT * FROM active_posts WHERE id= :post_id");
$get_posts-> bindValue(':post_id', $posts_array_index); //This is where I have my question
$get_posts->execute();
$get_posts->bindColumn("body", $body);
$get_posts->bindColumn("wage", $wage);
$get_posts->bindColumn("email", $email);
$get_posts->bindColumn("title", $title);
for ($i=0; $i<$posts; $i++ ) {
$get_posts->fetch(PDO::FETCH_BOUND); //This doesn't actually work yet, but is the method I will use
array_push($body_array, $body);
array_push($wage_array, $wage);
array_push($email_array, $email);
array_push($title_array, $title);
}
print_r($body_array);
print_r($wage_array);
print_r($email_array);
print_r($title_array);
}