|
|
Home Developer Manual 11. API Reference [REVIEW] database->query |
| [REVIEW] database->query |
|
|
|
|
Last reviewed: Not reviewed database->queryExecutes the current SQL query string. The syntax and semantics of SQL statements are beyond the scope of this manual. Prior to Joomla 1.1 the only database software supported was MySQL and the reference manual may be found at http://dev.mysql.com/doc/. From Joomla 1.1 onwards support for multiple databases is provided using the ADODB database abstraction library. Syntaxobject query ( [array $params] )
This function returns a database resource object if successful or false if not. The error code can be examined by calling database->getErrorNum and the error message can be obtained by calling database->getErrorMsg. ExamplesExample: function countCategories() { global $database; $sql = "SELECT * FROM #__categories"; $database->setQuery( $sql ); if (!$result = $database->query()) { echo $database->stderr(); return false; } return $database->getNumRows( $result ); } echo 'There are ' . countCategories() . ' categories'; might produce: There are 6 categoriesPlease report any errors on this page to the Developer Documentation Forum. |
|
| Last Updated ( Sunday, 24 December 2006 ) |
| < Prev | Next > |
|---|





