Вы не зарегистрированы? Нажмите здесь для регистрации.
Забыли пароль? Запросите новый здесь.
|
Вы должны авторизироваться, чтобы добавить сообщение.
|
|
|
Последние активные темы форума |
|
PDOStatement::execute
(no version information, might be only in CVS) PDOStatement::execute --
Executes a prepared statement
Descriptionbool PDOStatement::execute ( [array input_parameters] ) Внимание |
Эта функция является ЭКСПЕРИМЕНТАЛЬНОЙ.
Поведение этой функции, ее имя и относящаяся к ней документация
могут измениться в последующих версиях PHP без уведомления.
Используйте эту функцию на свой страх и риск. |
Execute the prepared statement. If the prepared statement included
parameter markers, you must either:
call PDOStatement::bindParam() to bind PHP variables
to the parameter markers: bound variables pass their value as input and receive the
output value, if any, of their associated parameter markers or pass an array of input-only parameter values
Пример 1. Execute a prepared statement with bound variables
<?php
/* Execute a prepared statement by binding PHP variables */
$calories
=
150
;
$colour
=
'red'
;
$sth
=
$dbh
->
prepare
(
'SELECT name, colour, calories
FROM fruit
WHERE calories < :calories AND colour = :colour'
);
$sth
->
bindParam
(
':calories'
,
$calories
,
PDO_PARAM_INT
);
$sth
->
bindParam
(
':colour'
,
$colour
,
PDO_PARAM_STR
,
12
);
$sth
->
execute
();
?>
|
|
Пример 2. Execute a prepared statement with an array of insert values
<?php
/* Execute a prepared statement by passing an array of insert values */
$calories
=
150
;
$colour
=
'red'
;
$sth
=
$dbh
->
prepare
(
'SELECT name, colour, calories
FROM fruit
WHERE calories < :calories AND colour = :colour'
);
$sth
->
bindParam
(
':calories'
,
$calories
,
PDO_PARAM_INT
);
$sth
->
bindParam
(
':colour'
,
$colour
,
PDO_PARAM_STR
,
12
);
$sth
->
execute
(array(
':calories'
=>
$calories
,
':colour'
=>
$colour
));
?>
|
|
Пример 3. Execute a prepared statement with question mark placeholders
<?php
/* Execute a prepared statement by binding PHP variables */
$calories
=
150
;
$colour
=
'red'
;
$sth
=
$dbh
->
prepare
(
'SELECT name, colour, calories
FROM fruit
WHERE calories < ? AND colour = ?'
);
$sth
->
bindParam
(
1
,
$calories
,
PDO_PARAM_INT
);
$sth
->
bindParam
(
2
,
$colour
,
PDO_PARAM_STR
,
12
);
$sth
->
execute
();
?>
|
|
|
· Гостей: 1
· Пользователей: 0
· Всего пользователей: 453
· Новый пользователь: ZDA
|
|