Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8891157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:40:00+00:00 2026-06-14T22:40:00+00:00

1: PDO use prepared statement which the meaning of prepared is something that we

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:40:02+00:00Added an answer on June 14, 2026 at 10:40 pm

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have something like the following PDO Statement which we use to communicate with
I want to use pdo in my application, but before that I want to
I checked this: How do I use pdo's prepared statement for order by and
I have found many ways to use the exec statement for PDO, but I'm
I am trying to use a prepared statement that deletes from two (temporary) tables:
I've just started learning aboud PDO and prepared statements (which sure seem to beat
When I am using a PDO prepared statement, and use it to plug in
Possible Duplicate: How do I use pdo's prepared statement for order by and limit
So I'm fairly paranoid and use mysql_real_escape_string() with PDO. I actually don't use prepared
I'm new to PHP and PDO, and I try to use prepared statements here.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.