phalcon 4 with sql server #15888
EhsanJamshidi
started this conversation in
General
Replies: 1 comment
-
hi, we have a great example app ( that I think has everything ) https://github.com/phalcon/vokuro more specific you need to register a service to your container and then you can use it with $di->get("db") for raw queries, or just use models more tutorials here: https://docs.phalcon.io/4.0/en/tutorial-basic use Phalcon\Di\FactoryDefault;
// Create a DI
$di= new FactoryDefault();
$di->set('db', function () use ($config) {
$class = new \Phalcon\Db\Adapter\Pdo\Mysql([
'host' => $config->database->host,
'username' => $config->database->username,
'password' => $config->database->password,
'dbname' => $config->database->dbname,
'port' => $config->database->port,
'charset' => 'utf8',
"options" => [
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
\PDO::ATTR_PERSISTENT => false,
\PDO::ATTR_EMULATE_PREPARES => false,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
\PDO::ATTR_STRINGIFY_FETCHES => false
]
]);
return $class;
}, true); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, anyone can help me with how to connect phalcon v4 to SQL server?
Beta Was this translation helpful? Give feedback.
All reactions