CakePHP从Google Analytics中保存数据

时间:2022-02-08 14:29:28

I've been working with this plugin: http://www.neilcrookes.com/2009/09/27/get-google-analytics-data-in-your-cakephp/ but honestly it's over my head.

我一直在使用这个插件:http://www.neilcrookes.com/2009/09/27/get-google-analytics-data-in-your-cakephp/但老实说,这是我的头脑。

Under Analytic.php it seems useTable is set to false, however, when it's true it throws an error. I am new to Cake and Cake plugins, so maybe I am interacting the wrong way.

在Analytic.php下,似乎将useTable设置为false,但是,当它为true时会抛出错误。我是Cake和Cake插件的新手,所以也许我正在以错误的方式进行交互。

I'd like to save the dimensions and metrics being pulled into a database using cake. Any direction would be greatly appreciated.

我想使用cake保存被拉入数据库的维度和指标。任何方向将不胜感激。

1 个解决方案

#1


3  

the model has useTable = false as it is using a datasource to get the data. you cant just set it to true, and it wont work any other way. if you want to save it create a new model with a db table like normal and then do something like the following.

该模型具有useTable = false,因为它使用数据源来获取数据。你不能把它设置为真,它不会以任何其他方式工作。如果你想保存它创建一个像普通的db表一样的新模型,然后执行类似下面的操作。

in new model...

在新模型中......

$data = ClassRegistry::init('AnaliticsModel')->findMethod();

then manipulate it how you need

然后根据你的需要操纵它

$this->save($data);

its now in your db... you can then do $this->find() <-- normal cake stuff on the new model

它现在在你的数据库中......你可以在新模型上做$ this-> find()< - 普通蛋糕

#1


3  

the model has useTable = false as it is using a datasource to get the data. you cant just set it to true, and it wont work any other way. if you want to save it create a new model with a db table like normal and then do something like the following.

该模型具有useTable = false,因为它使用数据源来获取数据。你不能把它设置为真,它不会以任何其他方式工作。如果你想保存它创建一个像普通的db表一样的新模型,然后执行类似下面的操作。

in new model...

在新模型中......

$data = ClassRegistry::init('AnaliticsModel')->findMethod();

then manipulate it how you need

然后根据你的需要操纵它

$this->save($data);

its now in your db... you can then do $this->find() <-- normal cake stuff on the new model

它现在在你的数据库中......你可以在新模型上做$ this-> find()< - 普通蛋糕