2.Bind using pdo
# $pdo already generated above $sql = "SELECT p.id FROM products p WHERE p.name =: p.name";// error due to: p.name $stmt = $pdo->prepare ($sql); $stmt->bindValue (': p.name', 'Test product', '2'); $stmt->execute (); # fetch results with fetch
It works if you set WHERE p.name =: name in the SQL statement
: p.name, please tell me how to escape
Answer # 1
I can't find it in the official manual
The only placeholders you can use with named placeholders are "alphanumeric characters, underscores" only
Switch to the question mark placeholder if you really don't like it
Answer # 2
For the same reason you can't use periods in php variable names
I think you can't include a period in the placeholder name.
The evidence is being investigated.
Note that the rules for naming variables (not just placeholders) are
It is in.
- php - i want to delete sqlite data using ajax
- php - output when using recursive function
- php - can you create table with table name using mysqli variable?
- php - i want to narrow down by using the result of calculating the column value using laravel where
- php - i don't know if path is in zsh shell (when using mamp&laravel)
- how to set credentials when running from aws php (not using aws)
- php - i want to pass the data to another page using the form tag in wordpress
- php - test using laravel http's post method gives only status code  results
- php - i want to send and receive using checkbox in form
- php - class not found when using namespace in exception handling
- php - i want to repeatedly process the output using the for statement in smart custom fields
- image upload using post method does not work in php
- php - i tried to make a chat application using pusher with laravel and read the tutorial, but it does not work
- i want to distribute css and js for each page using functionphp in wordpress theme creation
- php - please tell me how to debug when using the arrow operator
- php - upload multiple images using drag and drop
- php - i want to narrow down the search in real time using wordpress ajax
- using redis in a php session with php 73x
- php - i want to find the maximum value in an array using the max () function
- why is sql not populated on the php login screen?
- php - processing of delete function with laravel
- php - how to join the table managed by id with the table with id
- php - what are query variables?
- php - cannot search with more than 2 digits in sql like clause
- php - about time display (format)
- php - css and images are not reflected when paginating
- i want to prevent the serial number of ids from being broken by deleting the [cakephp] table [db]
- a php program that searches for data registered in sql by "year-month-day" by "year and month"
- php - sqlstate[hy000]  access denied for user'root'@'localhost' (using password: no) cannot be resolved