我该如何在函数中使用PDO

1: PDO use prepared statement which the meaning of prepared is something that we use it in many functions i think, and we prepared it for many functions.then i just want to know should i use diffrent sql query in all of my functions or should i define many query at first point in my init.php file(which include functions and connection to db)and then in each function pass them to the function to use these queries?just an example for what i described:

$query1 = "Insert into names(id,name) values (:id,:names)"
$query2 = "insert into games(id,name) values (:id,:names)"

and then for functions somtihing like this

function job($query){
//do the job
}

i ask this question because i read in some place i have to use this prepared statment in more than one place and if its true how should i use some unique query in a function?

2: can i use this :id :names in two prepared statement?or i have to set unique names?

$query1 = "Insert into names(id,name) values (:id,:names)"
$query2 = "insert into games(id,name) values (:id,:names)"

wont they conflict with each other?

I certainly wouldn't define all of my queries in one place for them to be used later -- I would put the queries where they are going to be used; otherwise it could get very confusing, especially if you name them query1, query2, etc.

If you have the same query that is prepared separately, then you can use the same tokens without any problem:

$stmt1 = $db->prepare($query1);
$stmt2 = $db->prepare($query2);

You can bind completely different values to :id and :name for both stmt1 and stmt2.

If you bind :id and :name right after each query it will be ok, but if you only bind them only once after declaring both query statements the last binded statement will overwrite the values. You can create a function to handle the queries if you desire, I personally write out the queries each time just to keep an eye on what I am doing in case i need last minute changes, but that is fine to stream line your work.