<?PHP/*PDO Learning*/ $dsn= ' MYSQL:HOST=LOCALHOST;DBNAME=CSWL ';//Build a Connection DSN $db=NewPdo$dsn, ' root ', ');//instantiate PDO "the second parameter is the user name, the third is the password" #. Query $obj=$db->prepare ("select * from level_class where id =?")); $id= 28; $obj->bindparam (1,$idPdo::param_int); $obj-execute (); $result=$obj->fetchall (PDO::FETCH_ASSOC); Var_dump($result);?>
PDO supports two types of parameter binding schemes:
1. What if the SQL ' statement is used? Number as a placeholder, in the Bindparam parameter, the first parameter is filled in the order of placeholders, such as 1 for the first one? The value of the number
2. If the SQL statement uses ": Variable name" as a placeholder, then the first parameter in the Bingparam parameter is ": Variable name"
Ps:bindparam function: par1, placeholder identifier, PAR2: value (must be represented as variable, otherwise reported: cannot pass parameter 2), PAR3: Value mode
With PDO::P aram_int,pdo::P aram_str,....