我在我的網站得到一個警告消息:警告:創建從空值默認對象 - 的Joomla
Warning: Creating default object from empty value in /homepages/16/d381040813/htdocs/components/com_events_booking/models/event.php on line 169
我在event.php開通169條線上,代碼:
$row->event->BeforeDisplay = trim(implode("\n", $results));
我event.php文件是:
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.model');
/**
* Event_Booking Component - Event Model
* @package Event_Booking
* @subpackage Model
*/
class Events_BookingModelEvent extends JModel {
/** @var int Total of documents */
var $_total = null;
/** @var object Pagination object */
var $_pagination = null;
/** @var string */
var $nullDate = null;
/** @var string */
var $now = null;
/** @var int */
var $_id = null;
/** @var array realty data */
var $_data = null;
/**
* Constructor.
*/
function __construct() {
global $mainframe, $option;
parent::__construct();
$this->nullDate = $this->_db->getNullDate();
$jdate = JFactory::getDate();
$this->now = $jdate->toMySQL();
$id = JRequest::getInt('id', 0);
if(!$id){
$session = &JFactory::getSession();
$user = JFactory::getUser();
$joinevent = $session->get('joinevent');
if(@count($joinevent[$user->get('id')])){
$id = $joinevent[$user->get('id')]['id'];
}
}
$this->setId($id);
}
/**
* Method to set the identifier
*
* @access public
* @param int $id realty identifier
*/
function setId($id) {
$this->_id = $id;
$this->_data = null;
}
/**
* Method to get event item data.
* @access public
* @return object
*/
function getData($id = null) {
// Lets load the data if it doesn't already exist
if (empty($this->_data)) {
$id = $id ? $id : $this->_id;
$query = 'SELECT a.*, b.id AS bid , b.title AS btitle , c.id AS cid , c.title AS ctitle, c.street, c.city, c.state, c.zip, ct.name AS `country`, c.website, c.latitude, c.longitude'
. ' FROM #__events_events AS a'
. ' INNER JOIN #__events_categories AS b ON a.category_id = b.id'
. ' INNER JOIN #__events_venues AS c ON a.venue_id = c.id'
. ' LEFT JOIN #__events_countries AS ct ON ct.code LIKE c.country'
. ' WHERE a.published = 1 AND a.id = '. (int) $id
;
$this->_db->setQuery($query);
$this->_data = $this->_db->loadObject();
}
if (!$this->_data->id) {
JError::raiseError(404, JText::_('COM_EVENTS_BOOKING_EVENT_NOT_FOUND'));
}
return $this->_data;
}
/**
* Method to get group item data.
* @access public
* @return array
*/
function getGroup($id = null) {
$query = 'SELECT g.* FROM #__events_groups as g'
. ' WHERE g.published = 1 AND a.id = '. (int) $id
;
$this->_db->setQuery($query);
$row = $this->_db->loadObject();
return $row;
}
/**
* Method to get Expired item data.
* @access public
* @return array
*/
function getExpired() {
$date = new JDate();
$id = $this->_id;
$query = 'SELECT COUNT(*) FROM #__events_events AS a WHERE a.id = '.(int)$id.' AND a.published = 1 AND a.expired > '.$this->_db->Quote($date->toMySQL());
$this->_db->setQuery($query);
$row = $this->_db->loadResult();
return $row;
}
/**
* Method to get Expired Capacity.
* @access public
* @return array
*/
function getCapacity() {
$data = $this->getData();
$id = $this->_id;
$result = $this->getMemberCapacity($data->capacity);
return $result;
}
/**
* Method to get Member Capacity COM_EVENTS_BOOKING_JOIN_EVENT.
* @access public
* @return array
*/
function getMemberCapacity($capacity=0) {
$id = $this->_id;
// $query = 'SELECT COUNT(*) FROM #__events_members AS a WHERE a.event_id = '.(int)$id;
$query = 'SELECT COUNT(*)'
. ' FROM #__events_members AS a'
. ' INNER JOIN #__events_bookings AS b ON b.id = a.booking_id'
. ' WHERE a.event_id = '.(int)$id
. ' AND b.approved = 1'
. ' AND a.approved = 1'
;
$this->_db->setQuery($query);
$row = $this->_db->loadResult();
$result = array();
$result['m_capacity'] = $row;
$result['e_capacity'] = (int)($capacity-(int)$row);
return $result;
}
function execPlugins(&$row, $view, $task){
$params = &JComponentHelper::getParams('com_events_booking');
$limitstart = JRequest::getInt('limitstart');
//Import plugins
$dispatcher = &JDispatcher::getInstance();
JPluginHelper::importPlugin ('content');
$row->text = $row->description;
$results = $dispatcher->trigger('onBeforeDisplay', array ('com_events_booking.event', &$row, &$params, $limitstart));
$row->event->BeforeDisplay = trim(implode("\n", $results));
$results = $dispatcher->trigger('onAfterDisplay', array ('com_events_booking.event', &$row, &$params, $limitstart));
$row->event->AfterDisplay = trim(implode("\n", $results));
$results = $dispatcher->trigger('onAfterDisplayTitle', array ('com_events_booking.event', &$row, &$params, $limitstart));
$row->event->AfterDisplayTitle = trim(implode("\n", $results));
$results = $dispatcher->trigger('onBeforeDisplayContent', array ('com_events_booking.event', &$row, &$params, $limitstart));
$row->event->BeforeDisplayContent = trim(implode("\n", $results));
$results = $dispatcher->trigger('onAfterDisplayContent', array ('com_events_booking.event', &$row, &$params, $limitstart));
$row->event->AfterDisplayContent = trim(implode("\n", $results));
$dispatcher->trigger('onContentPrepare', array ('com_events_booking.event', &$row, &$params, $limitstart));
return $row;
}
/**
* Method to store the booking
*
* @access public
* @param $data
* @return boolean True on success
*/
function store($data) {
//$row = JTable::getInstance('form', 'Table');
$row =& $this->getTable('event');
// bind the form fields to the version table
if (!$row->bind($data)) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// make sure the category is valid
if (!$row->check()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// store the category table to the database
if (!$row->store()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
return $row;
}
我GOOGLE了一天,但沒有結果。請幫我隱藏這個警告或解決這個問題。
中顯示錯誤頁面的URL: http://www.lefoodist.biz/calendar-gb/calendar-hosted-gastronomic-dinners?view=event&id=478#box-details
您可以使用error_reporting(E_NONE)隱藏錯誤或在php.ini中設置合適的值,或者使用函數ini_set()也可以使用@操作符來隱藏錯誤。錯誤也可能是由於上一行導致的,所以你應該在你的文章中包含這一行 – Robert
是的,我已經使用它,現在得到了結果@robert –