/** @path(/myclass) */ class MyClass{ /** * @route({"GET","/do"}) * @param({"arg0","$._GET.arg0"}) */ public doSomething($arg0){ return Sql::select('xxx')->from('table_xxx')->where( 'xxx = ?', $arg0)->get($this->db); } /** * 依赖注入PDO实例 * @property * @var PDO */ public $db; }
配置文件
{ { "MyClass":{ "properties":{ "db":"@db1" } }, }, "db1":{ "singleton":true, "class":"PDO", "pass_by_construct":true, "properties":{ "dsn":"mysql:host=127.0.0.1;dbname=xxx", "username":"xxxx", "passwd":"xxxx" } }, }
您可能感兴趣的文章: