symfony - DBAL - symfony2 bind a value for LIKE operator -
i trying execute sql query involves operator dbal
basically query following:
public function getsubsitebyhostname($host){ $sql = "select a.id, a.title, a.layout_id sites left join layouts b on a.layout_id = b.id a.baseurl '%:host%' "; $stmt = $this->db->prepare($sql); $stmt->bindvalue("host", $host); $stmt->execute(); return $stmt->fetch(); } sqlstate[42000]: syntax error or access violation: 1064 have error in sql syntax; check manual corresponds mysql server version right syntax use near '%'hostname.dev'%
obiviously i'm doing wrong bindvalue
the answer easier thought, adam suggested
$stmt->bindvalue("host", '%'.$host.'%');
Comments
Post a Comment