Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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,

share|improve this question
    
can you explain it more clearly? and how you want the output look like? –  Feroz Akbar Jun 6 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 –  user3227331 Jun 6 at 8:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.