ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# Abstract class Phalcon\\Db # Abstract class **Phalcon\\Db** Phalcon\\Db and its related classes provide a simple SQL database interface for Phalcon Framework. The Phalcon\\Db is the basic class you use to connect your PHP application to an RDBMS. There is a different adapter class for each brand of RDBMS. This component is intended to lower level database operations. If you want to interact with databases using higher level of abstraction use Phalcon\\Mvc\\Model. Phalcon\\Db is an abstract class. You only can use it with a database adapter like Phalcon\\Db\\Adapter\\Pdo ``` <pre class="calibre14">``` <?php try { $connection = new \Phalcon\Db\Adapter\Pdo\Mysql(array( 'host' => '192.168.0.11', 'username' => 'sigma', 'password' => 'secret', 'dbname' => 'blog', 'port' => '3306', )); $result = $connection->query("SELECT * FROM robots LIMIT 5"); $result->setFetchMode(Phalcon\Db::FETCH_NUM); while ($robot = $result->fetch()) { print_r($robot); } } catch (Phalcon\Db\Exception $e) { echo $e->getMessage(), PHP_EOL; } ``` ``` ### Constants *integer***FETCH\_LAZY** *integer***FETCH\_ASSOC** *integer***FETCH\_NAMED** *integer***FETCH\_NUM** *integer***FETCH\_BOTH** *integer***FETCH\_OBJ** *integer***FETCH\_BOUND** *integer***FETCH\_COLUMN** *integer***FETCH\_CLASS** *integer***FETCH\_INTO** *integer***FETCH\_FUNC** *integer***FETCH\_GROUP** *integer***FETCH\_UNIQUE** *integer***FETCH\_KEY\_PAIR** *integer***FETCH\_CLASSTYPE** *integer***FETCH\_SERIALIZE** *integer***FETCH\_PROPS\_LATE** ### Methods public static **setup** (*unknown* $options) Enables/disables options in the Database component | - [索引](# "总目录") - [下一页](# "Abstract class Phalcon\Db\Adapter") | - [上一页](# "Class Phalcon\Crypt\Exception") | - [API Indice](#) »