|
PDO::queryPrepares and executes an SQL statement without placeholders Description
public PDOStatementfalse PDO::query(string
$query , intnull $fetchMode = null )public PDOStatementfalse PDO::query(string
$query , intnull $fetchMode = PDO::FETCH_COLUMN, int $colno )public PDOStatementfalse PDO::query(
string $query ,intnull $fetchMode = PDO::FETCH_CLASS,string $classname ,array $constructorArgs ) public PDOStatementfalse PDO::query(string
$query , intnull $fetchMode = PDO::FETCH_INTO, object $object )PDO::query prepares and executes an SQL statement in a single function call, returning the statement as a PDOStatement object. For a query that you need to issue multiple times, you will realize better performance if you prepare a PDOStatement object using PDO::prepare and issue the statement with multiple calls to PDOStatement::execute. If you do not fetch all of the data in a result set before issuing your next call to PDO::query, your call may fail. Call PDOStatement::closeCursor to release the database resources associated with the PDOStatement object before issuing your next call to PDO::query.
Parameters
Return Values
Returns a PDOStatement object or Errors/Exceptions
Emits an error with level
Throws a PDOException if the attribute Examples
Example #1 SQL with no placeholders can be executed using PDO::query
The above example will output: apple red 150 banana yellow 250 kiwi brown 75 lemon yellow 25 orange orange 300 pear green 150 watermelon pink 90 See Also
|