1

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,

2
  • can you explain it more clearly? and how you want the output look like? Commented Jun 6, 2014 at 8:43
  • if i echo second query i want replace {var[$i]['mgr_id']} with value like "SELECT * FROM emp_master where mgr_id = 2" if i pass $sql to $db_query=$row->query($sql); it will run on database Commented Jun 6, 2014 at 8:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.