dtwy2858 2015-07-27 09:27
浏览 43

在Windows中成功创建的Magento模型对象会在Linux中引发错误

I have the following error occur in my custom module :

Fatal error: Call to a member function setData() on a non-object in /opt/lampp/htdocs/magento/app/code/local/Phparrow/Hello/controllers/IndexController.php

My code is as follows -

config.xml

<global>
    <blocks>
        <hello>
                <class>Phparrow_Hello_Block</class>
        </hello>
    </blocks>
    <helpers>
        <hello>
            <class>Phparrow_Hello_Helper</class>   
        </hello>
    </helpers>
        <models>
            <hello>
                <class>Phparrow_Hello_Model</class>
                <resourceModel>hello_mysql4</resourceModel>
            </hello>
            <hello_mysql4>
                <class>Phparrow_Hello_Model_Mysql4</class>
                <entities>        
                    <hello>
                        <table>hello</table>
                    </hello>
                </entities>
            </hello_mysql4>
        </models>
        <resources>
            <hello_setup>
                <setup>
                    <module>Phparrow_Hello</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </hello_setup>
            <hello_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </hello_write>
            <hello_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </hello_read>
        </resources>
</global> 

magento\app\code\local\Phparrow\Hello\Model\Hello.php

<?php
class Phparrow_Hello_Model_Hello extends Mage_Core_Model_Abstract
{
    public function _construct(){
        print 'test';
       $this->_init('hello/hello');
    print 'test1';
    }
}

magento\app\code\local\Phparrow\Hello\Model\mysql4\Hello.php

<?php
class Phparrow_Hello_Model_Mysql4_Hello extends Mage_Core_Model_Mysql4_Abstract
    public function _construct()
    {
        $this->_init('hello/hello', 'hello_id');
    }
}

magento\app\code\local\Phparrow\Hello\Model\mysql4\Hello\Collection.php

<?php
class Phparrow_Hello_Model_Mysql4_Hello_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
    public function _construct(){
        $this->_init('hello/hello');
    }
}

magento\app\code\local\Phparrow\Hello\controllers\IndexController.php

class Phparrow_Hello_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    { 
     $model1= Mage::getModel('hello/hello');
     echo get_class($model1);
     $model1->setData('name'->'Harsh','contact'->'8445895621');
     $model1->save();
    }
}

I have a hello table have that has three fields:

hello_id, name, contact

Why would this not work in Linux when it successfully executes in Windows?

  • 写回答

2条回答 默认 最新

  • douxiajia6309 2015-07-27 10:08
    关注

    I'm pretty sure this has to do with your path or file naming, make sure that the files and folders are named exactly as you typed it here.

    Windows doesn't care much and would probably serve up the file HelLo.php or hELLO.php just fine when the autoloader tried to find the model.

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?