sql查询的模式匹配替换string中的数组值

i will explain scenario first.

i have database with 3 table (emp_master,mgr_master,query_transaction)mgr_master contain manager data, emp_master table contain employee data with foreign key of mgr_master query_transaction contain query which i'm going to run on other 2 tables tables

i have 2 record in query_transaction:

1. SELECT * FROM `emp_master` where mgr_id = {query_id}
2. SELECT * FROM `emp_master` where mgr_id = {var[$i]['mgr_id']})

i'm fetching this two query and keeping in array variable(var)

if i use below code

$query = $var[0]['query_trans'];

$sql= preg_replace('/\{([a-zA-Z0-9_]+)\}/e', "$$1", $query);
$db_query=$row->query($sql);

then it works fine for first query

but i don't want this($query = $var[0]['query_trans'];) step so i have written 2'ed query it doesn't display any record

what's is my observation is In pattern matching is i need to include patterns for ([,],',",$)

if you have any idea for such a logic than share it with me. any Help is appreciated,