Most efficient way to populate array from database values?

wiemercats

New Member
If I wanted to get a list of product_ids with a certain brand. I would do this:\[code\]$id_list = array();$qry = 'SELECT product_id FROM products WHERE product_brand = :brand';$STH = $this->pdo->prepare($qry);$STH->execute(array("brand" => $brand));$STH->setFetchMode(PDO::FETCH_ASSOC);while($row = $STH->fetch()){ $id_list[] = $row['product_id'];}\[/code\]Is there a faster more efficient way? It seems like if I am only selecting 1 column there should be a better approach to selecting/inserting that into an array.
 
Back
Top