previousDB_common::nextQueryIsManip() (Previous) (Next) DB_common::provides()next

View this page in Last updated: Sun, 21 Jun 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

DB_common::prepare()

DB_common::prepare() – 後で実行するための SQL 文を準備する

Synopsis

resource prepare ( string $query )

Description

execute() で実行できるように、SQL 文を 準備します。

Parameter

string $query

準備するクエリ。

Return value

resource - クエリのハンドル、あるいは失敗した場合に DB_Error オブジェクトを返します。

Note

This function can not be called statically.

Example

prepare() の使用法

<?php
// $db という名前の DB オブジェクトを取得しているとします...
$sth $db->prepare('INSERT INTO numbers (number) VALUES (?)');
if (
PEAR::isError($sth)) {
    die(
$sth->getMessage());
}

$res =& $db->execute($sth1);
if (
PEAR::isError($res)) {
    die(
$res->getMessage());
}
?>
previousDB_common::nextQueryIsManip() (Previous) (Next) DB_common::provides()next

Download Documentation Last updated: Sun, 21 Jun 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
Note by: user2037
It may not be obvious but you need to "escape placeholder characters" such as question marks, exclamation points, and ampersands when preparing a query. For example: "SELECT * WHERE a \!= FALSE AND b = ?".