我对如何使用 meddo 配置类感到困惑
$database = new Medoo([
'database_type' => 'mysql',
'database_name' => 'name',
'server' => 'localhost',
'username' => 'your_username',
'password' => 'your_password',
]);
在另一个班级内
class Blog {
public function getBlogs(){
return $database->select('post', "title");
}
}
现在我正在使用全局变量来解决它们是我可以使用的任何直接方式。
我不想这样使用它
<?php
include 'classes/config.php';
class blog{
function A(){
global $database;
return $database->select('post', "title");
}
}
function B(){
global $database;
return $database->select('post', "title");
}
}
function C(){
global $database;
return $database->select('post', "title");
}
}
?>