Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.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
在第225行的/app/code/core/Mage/core/Model/Abstract.php中对布尔值调用成员函数load()_Php_Magento - Fatal编程技术网

在第225行的/app/code/core/Mage/core/Model/Abstract.php中对布尔值调用成员函数load()

在第225行的/app/code/core/Mage/core/Model/Abstract.php中对布尔值调用成员函数load(),php,magento,Php,Magento,阅读本教程 从最后3天开始工作,如果可以,请帮助 但我得到了这个错误:- 正在加载ID为1的blogpost 致命错误:在第225行的/var/www/html/magento/app/code/core/Mage/core/Model/Abstract.php中调用布尔值上的成员函数load() /var/www/html/magento/app/code/local/alanstromdotcom/Weblog/etc/config.xml <config> <mo

阅读本教程 从最后3天开始工作,如果可以,请帮助

但我得到了这个错误:-

正在加载ID为1的blogpost 致命错误:在第225行的/var/www/html/magento/app/code/core/Mage/core/Model/Abstract.php中调用布尔值上的成员函数load()

/var/www/html/magento/app/code/local/alanstromdotcom/Weblog/etc/config.xml

<config>    
<modules>
    <Alanstormdotcom_Weblog>
        <version>0.1.0</version>
    </Alanstormdotcom_Weblog>
</modules>
<frontend>
    <routers>
        <weblog>
            <use>standard</use>
            <args>
                <module>Alanstormdotcom_Weblog</module>
                <frontName>weblog</frontName>
            </args>
        </weblog>
    </routers>  
</frontend>
<global>
    <models>
        <weblog>
            <class>
                Alanstormdotcom_Weblog_Model
            </class>
            <resourceModel>
                weblog_mysql4
            </resourceModel>
        </weblog>
        <weblog_mysql4>
            <class>Alanstormdotcom_Weblog_Model_Mysql4</class>
            <entities>
                <blogpost>
                    <table>blog_posts</table>
                </blogpost>
            </entities>
        </weblog_mysql4>
    </models>
    <resources>
        <weblog_write>
            <connection>
                <use>core_write</use>
            </connection>
        </weblog_write>
        <weblog_read>
            <connection>
                <use>core_read</use>
            </connection>
        </weblog_read>
    </resources>
</global>

0.1.0
标准
网络日志
网络日志
网络日志模式
weblog_mysql4
Alanstormdotcom_博客_模型_Mysql4
博客文章
核心写入
核心读取

/var/www/html/magento/app/code/local/alanstromdotcom/Weblog/controllers/IndexController.php

<?php class Alanstormdotcom_Weblog_IndexController extends Mage_Core_Controller_Front_Action {
public function testModelAction() {
    $params=$this->getRequest()->getParams();
    $blogpost=Mage::getModel('weblog/blogpost');
    echo("Loading the blogpost with an ID of ".$params['id']);
    $blogpost->load($params['id']);
    $data=$blogpost->getData();
    var_dump($data);
} } ?>

/var/www/html/magento/app/code/local/alanstromdotcom/Weblog/Model/Mysql4/Blogpost.php

<?php
class Alanstormdotcom_Weblog_Model_Mysql4_Blogpost extends Mage_Core_Model_Mysql4_Abstract {
protected function _construct()
{
    $this->_init('weblog/blogpost', 'blogpost_id');
}   } ?>
<?php
class Alanstormdotcom_Weblog_Model_Blogpost extends Mage_Core_Model_Abstract{
protected function _construct(){
    $this->_init('weblog/blogpost');
} } ?>

/var/www/html/magento/app/code/local/alanstromdotcom/Weblog/Model/Blogpost.php

<?php
class Alanstormdotcom_Weblog_Model_Mysql4_Blogpost extends Mage_Core_Model_Mysql4_Abstract {
protected function _construct()
{
    $this->_init('weblog/blogpost', 'blogpost_id');
}   } ?>
<?php
class Alanstormdotcom_Weblog_Model_Blogpost extends Mage_Core_Model_Abstract{
protected function _construct(){
    $this->_init('weblog/blogpost');
} } ?>

试试这个

<config>    
<modules>
    <Alanstormdotcom_Weblog>
        <version>0.1.0</version>
    </Alanstormdotcom_Weblog>
</modules>
<frontend>
    <routers>
        <weblog>
            <use>standard</use>
            <args>
                <module>Alanstormdotcom_Weblog</module>
                <frontName>weblog</frontName>
            </args>
        </weblog>
    </routers>  
</frontend>
<global>
    <models>
        <weblog>
            <class>Alanstormdotcom_Weblog_Model</class>
            <resourceModel>weblog_mysql4</resourceModel>
        </weblog>
        <weblog_mysql4>
            <class>Alanstormdotcom_Weblog_Model_Mysql4</class>
            <entities>
                <blogpost>
                    <table>blog_posts</table>
                </blogpost>
            </entities>
        </weblog_mysql4>
    </models>
    <resources>
        <weblog_write>
            <connection>
                <use>core_write</use>
            </connection>
        </weblog_write>
        <weblog_read>
            <connection>
                <use>core_read</use>
            </connection>
        </weblog_read>
    </resources>
</global>

0.1.0
标准
网络日志
网络日志
网络日志模式
weblog_mysql4
Alanstormdotcom_博客_模型_Mysql4
博客文章
核心写入
核心读取
模型和资源模型应该在同一条线上


$blogpost
变量包含什么?通过尝试检索一个weblog/blogpost模型,您告诉Magento实例化一个名为Alanstormdotcom\u weblog\u Model\u BlogpostYes的类,但是当您
变量转储
$blogpost
的内容时,它实际上包含什么?请检查您的日志和异常文件。创建表
blog_posts
blog_id
int(11)非空自动增量,
title
text,
post
text,
date
datetime默认空,
timestamp非空默认当前时间戳,主键(
blogpost\u id
)插入
blogpost
值(1、'mynewtitle'、'thisablog post'、'2009-07-01 00:00:00'、'2009-07-02 23:12:30');数组'blogpost\u id'=>字符串'1'(长度=1)'Title'=>字符串'mynewtitle'(长度=12)'post'=>string'这是一篇博客文章'(长度=19)'date'=>string'2009-07-01 00:00:00'(长度=19)'timestamp'=>string'2009-07-02 16:12:30'(长度=19)