Good day !
There is a sql query:
$gPlaceholderName = $mysqli->query("SELECT `gPlaceholderName` FROM `gData` WHERE `gID` = '$gID'"); Help make a prepared request and explain how to use them and make them yourself in the future.
Good day !
There is a sql query:
$gPlaceholderName = $mysqli->query("SELECT `gPlaceholderName` FROM `gData` WHERE `gID` = '$gID'"); Help make a prepared request and explain how to use them and make them yourself in the future.
In order to prepare and execute a SQL query you need:
Prepare a request
Bind a variable to parameters
Run query
The prepare function prepares the SQL statement for execution.
Note: The following example is in the Object Oriented style.
$gPlaceholderName = $mysqli->prepare("SELECT `gPlaceholderName` FROM `gData` WHERE `gID` = ?"); The bind_param function is responsible for binding variables to parameters.
$gPlaceholderName->bind_param("i", $groupID); The letter i stands for integer type.
The following are commonly used parameters:
i - the corresponding variable is of type integer
d - the corresponding variable is of type double
s - the corresponding variable is of type string
execute is responsible for executing the SQL query.
$gPlaceholderName->execute(); All submitted information is taken from official Russian PHP documentation.
I also wanted to thank Alexei Shimansky and Kirill Korushkin for instructing on the right path.
Source: https://ru.stackoverflow.com/questions/755349/
All Articles
просто я не замечал объяснения функции bind_param и не понимал что означала и откуда там бралась буква- yes, the manual basically says "Parameter labels should be associated with application variables with the functions mysqli_stmt_bind_param () and / or mysqli_stmt_bind_result () before launching a query or fetching strings "and if you go to php.net/manual/ru/mysqli-stmt.bind-param.php, look at what types are. That will be clear - Alexey Shimansky