Php 如何从锂电池中的控制器附加连接配置?
我正在构建一个GooglePlacesAPI,它是一个http数据源包 我认为最好是附带一个基本的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 { ... } 但是我希望能够以某种方式使
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'
));