php - PDO multiple queries understanding issue -
okay guys having hard time understanding how query.
this trying accomplish:
i trying output distinct brands query result. when user searches instance "shoe" can output of shoes in database, plus have choice on side user can select brand filter results. can output of data need match against query, can't figure out how a query can query first query pdo.
here have:
<?php require_once 'login.php'; $db = new pdo("mysql:host=$host;dbname=$dbname", $user, $pass); $usersearch=strip_tags($_post['searchquery']); $query=$db->prepare("select * products match(description) against (? in boolean mode) or match(brand) against(? in boolean mode);select distinct brand products"); $query->execute(array('+%'.$usersearch.'%','+%'.$usersearch.'%')); $result=$query->fetchall(pdo::fetch_assoc); ?> my problem "select distinct brand products".
is correct way perform multiple queries? select each brand from first query left of semicolon or perform query on each row in db?
any appreciated.
i'm kind of @ stand still.
no, cannot prepare , execute multi queries in 1 string pdo.
you can use mysqli::multi_query, without preparing. useless multi select.
you use union, count of selected fields must same. example
select brand products match(description) against (? in boolean mode) or match(brand) against(? in boolean mode) union select distinct brand products p.s. or use 2 separated queries :^ )
Comments
Post a Comment