Returns the PDO instance used by the the ORM to communicate with
the database. This can be called if any low-level DB access is
required outside the class. If multiple connections are used,
accepts an optional key name for the connection.
/** * * To create and save multiple elements, easy way * Using an array with rows array(array('name'=>'value',...), array('name2'=>'value2',...),..) * or a array multiple * */ public function insert($rows, $ignore = false) { ORM::get_db()->beginTransaction(); foreach ($rows as $row) { $class = $this->_class_name; $class::create($row)->save($ignore); } ORM::get_db()->commit(); return ORM::get_db()->lastInsertId(); }
public function testMultiplePdoConnections() { $this->assertInstanceOf('MockPDO', ORM::get_db()); $this->assertInstanceOf('MockPDO', ORM::get_db(ORM::DEFAULT_CONNECTION)); $this->assertInstanceOf('MockDifferentPDO', ORM::get_db(self::ALTERNATE)); }