$db = new \DB\SQL('mysql:host=localhost;port=????;dbname=test','user','password');
$titleofPage = Models->getTitleOfPage();
public function __construct() {$this->db = parent::__construct( \Base::instance()->get('db'), 'lm_config' );}
parent::__construct();
public function getTitle() { $result = $db->exec('SELECT title FROM lm_config'); return $result; }
(eg. "call to undefined method "exec()" on NULL")
invalid data source name [D:\xampp2\htdocs\fatfree\private\lib\db\sql.php:496]
[D:/xampp2/htdocs/fatfree/private/lib/db/sql.php:496] PDO->__construct('','config',NULL,[]) [D:/xampp2/htdocs/fatfree/private/classes/Models.php:6] DB\SQL->__construct(NULL,'config') [D:/xampp2/htdocs/fatfree/private/model/MainModel.php:6] Models->__construct() [D:/xampp2/htdocs/fatfree/public/index.php:46] MainModel->__construct()
; Set Installed
installed = true
; Database Settings
db_dns = mysql:host=localhost;dbname=
db_host = localhost
db_name = tested
db_user = root
db_pass =
db_prefix =
function __construct() {
$f3 = Base::instance();
$this->f3 = $f3;
$this->home_url = $f3->get('SCHEME').'://'.$f3->get('HOST').$f3->get('BASE');
/* Database Connect */
try {
$db = new DB\SQL(
$f3->get('db_dns') . $f3->get('db_name'),
$f3->get('db_user'),
$f3->get('db_pass')
);
} catch (PDOException $e) {
$f3->status(503);
echo "<h1>Error establishing a database connection</h1>";
exit;
}
// Database
$this->db = $db;
}
class LoginController extends BaseController
<?php
class User extends DB\SQL\Mapper {
protected $f3;
public function __construct(DB\SQL $db) {
$this->f3 = Base::instance();
$db_prefix = $this->f3->get('db_prefix');
parent::__construct($db,$db_prefix.'series');
}
db->exec($query);
$db = new DB\SQL( getenv('DB_DNS'),
getenv('DB_NAME'),
getenv('DB_USER'),
getenv('DB_PASS')
);
// Load environment vars for development
if (getenv('PROD_ENVIRONMENT') === FALSE) {
$dotenv = Dotenv\Dotenv::create(__DIR__ . '/conf');
$dotenv->load();
}