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
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_USE_DEFAULT
integer FETCH_LAZY
integer FETCH_ASSOC
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_NAMED
integer FETCH_KEY_PAIR
integer FETCH_GROUP
integer FETCH_UNIQUE
integer FETCH_CLASSTYPE
integer FETCH_SERIALIZE
integer FETCH_PROPS_LATE
Methods
public static setup (array $options)
Enables/disables options in the Database component
© 2011–2016 Phalcon Framework Team
Licensed under the Creative Commons Attribution License 3.0.
https://docs.phalconphp.com/en/2.0.0/api/Phalcon_Db.html