Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何从锂电池中的控制器附加连接配置?_Php_Lithium - Fatal编程技术网

Php 如何从锂电池中的控制器附加连接配置?

Php 如何从锂电池中的控制器附加连接配置?,php,lithium,Php,Lithium,我正在构建一个GooglePlacesAPI,它是一个http数据源包 我认为最好是附带一个基本的Places模型和一个基本的gplaces连接,这样数据源就可以在我的应用程序PlacesController中使用: use app\models\Places; use google\models\Places as GPlaces; class PlacesController extends \lithium\action\Controller { ... } 但是我希望能够以某种方式使

我正在构建一个GooglePlacesAPI,它是一个http数据源包

我认为最好是附带一个基本的
Places
模型和一个基本的
gplaces
连接,这样数据源就可以在我的应用程序
PlacesController
中使用:

use app\models\Places;
use google\models\Places as GPlaces;

class PlacesController extends \lithium\action\Controller { ... }
但是我希望能够以某种方式使用so API键来增加插件默认连接
gplaces

尝试:

GPlaces::config(array(
    'key' => 'AIzaSyAQ802bwgTUw6KcBnaHF1YWdzW6zvIf4to'
));
但这并不影响(正如我们所预料的)联系


有什么想法吗?

在本例中,
GPlaces
是一个模型,因此这样做只会将该键分配给模型的配置,而这不是您想要的

如果您有一个名为
'gplaces'
的连接,则应在
连接::add()
中使用该键对其进行配置,然后您可以告诉您的模型这样使用该连接:

GPlaces::config(array(
    'connection' => 'gplaces'
));