CakePHP的使用find从模型检索数据()。生产服务器上不同的数组键 [英] CakePHP retrieving data from model using find(). Different array keys on production server

查看:204
本文介绍了CakePHP的使用find从模型检索数据()。生产服务器上不同的数组键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对我的生产和开发服务器完全相同的code,但我似乎得到不同的数组键使用find时,('第一')来检索数据。

开发:

 阵列

    [首页] =>排列
        (
            [标题] =>欢迎!
            [关键词] =>关键字1关键字2关键字3
        ))

生产:

 阵列

    [0] =>排列
        (
            [标题] =>欢迎!
            [关键词] =>关键字1关键字2关键字3
        ))

code在AppController的:

  //获取页面标题和关键字
        当前是$ = ​​$这个 - >&页面 - GT;找到(第一,
            阵列(
                '条件'=>阵列('Page.name'=> $这个 - > PARAMS ['控制'])
                '域'=>阵列('Page.title','Page.keywords')
            ));
        PR($当前页);


解决方案

我记得这一个...:P我以前有同样的问题。

它无论是PHP版本或MySQL的版本引起的。检查您的服务器为您的蛋糕版本通过的最低要求

为cakephp2.0要求

为cakephp1.3要求

您可以使用phpinfo()函数检查他们;

希望这有助于

I have the same exact code on my production and development servers but I seem to get different array keys when using find('first') to retrieve data.

Development:

Array
(
    [Page] => Array
        (
            [title] => Welcome!
            [keywords] => keyword 1 keyword 2 keyword 3
        )

)

Production:

 Array
(
    [0] => Array
        (
            [title] => Welcome!
            [keywords] => keyword 1 keyword 2 keyword 3
        )

)

Code in AppController:

//get page title and keywords
        $currentPage = $this->Page->find('first', 
            array(
                'conditions' => array('Page.name' => $this->params['controller']),
                'fields' => array('Page.title', 'Page.keywords')
            ));


        pr($currentPage);

解决方案

I remember this one... :P I had the same problem before

It's caused either by the php version or the mysql version. Check if your server passes the minimum requirements for your cake version

requirements for cakephp2.0

requirements for cakephp1.3

you can check them using a phpinfo();

Hope this helps

这篇关于CakePHP的使用find从模型检索数据()。生产服务器上不同的数组键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆