Introduction - Query

Introduction - Query -- Performing a query against a database.

Description

To perform a query against a database, you have to use the function query(), that takes the query string as an argument. On failure you get a MDB_Error object. Be sure to check it with MDB::isError(). On success, you get MDB_OK or when you set a SELECT-statment a result resource handle

例 33-1A simple MDB query


<?php
// Once you have a valid MDB object...
$sql = "select * from clients";

$result = $db->query($sql);

// Always check that $result is not an error
if (MDB::isError($result)) {
    die ($result->getMessage());
}

// Continue on with your script
?>