PHP mysqli: prepare() function
mysqli_prepare function / mysqli::prepare
The mysqli_prepare function / mysqli::prepare — Prepare an SQL statement for execution.
Syntax:
Object oriented style
mysqli_stmt mysqli::prepare ( string $query )
Procedural style
mysqli_stmt mysqli_prepare ( mysqli $link , string $query )
Parameter:
Name | Description | Required/Optional |
---|---|---|
link | A link identifier returned by mysqli_connect() or mysqli_init() | Required for procedural style only and Optional for Object oriented style |
query | The query, as a string. | Required |
Usage: Procedural style
mysqli_prepare ( string $query );
Return value:
mysqli_prepare() returns a statement object or FALSE if an error occurred.
Version: PHP 5, PHP 7
Example of object oriented style:
Example of procedural style:
Output:
Amersfoort is in district Utrecht
Output:
EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID 156 Janette King JKING 011.44.1345.429268 1987-08-12 SA_REP 10000.00 0.35 146 80 100 Steven King SKING 515.123.4567 1987-06-17 AD_PRES 24000.00 0.00 0 90
See also