您可以构建一个简单的SQL Select,如下所示:
<?phpfunction create_sql_select(array $pair){ $condition = array(); foreach ( $pair as $key => $value){ $condition[] = "{$key} = '{$value}'"; } // Separate by AND delimiter if there are more than 1 pair $condition = join(' AND ', $condition); // Return prepared string: return "SELECT * FROM your_table WHERe {$condition}";}//Will print: SELECt * FROM your_table WHERe user = 'some' AND age = '10'print create_sql_select(array('user' => 'some', 'age' => 10));


