Mình đang học thiết kế component qua tài liệu. Mình gõ không sót 1 chữ nào nhưng vẫn bị lỗi.
Đây là toàn bộ trang web và database để các bạn xem dùm :
http://www.mediafire.com/download.php?mwdm4jdvgtz
Làm ơn xem dùm mình code của component "Restaurant Reviews" bên trong thư mục com_reviews trong thư mục administrator/components/ (vì mình đang thiết kế phần back-end thôi chưa qua phần front-end). File lỗi nằm theo đường dẫn này "...joomla 1.5.15\administrator\components\com_reviewsadmin.review.php" (Hàm lỗi là saveReview()).
Xin hãy giúp mình.
Cấu trúc thư mục :
Phần Back-end :
administrator
|***** Manual signatures are NOT allowed *****__com_reviews
.................|***** Manual signatures are NOT allowed *****__tables
..................................|____review.php
.................|***** Manual signatures are NOT allowed *****__admin.reviews.html.php
.................|***** Manual signatures are NOT allowed *****__admin.reviews.php
.................|***** Manual signatures are NOT allowed *****__toolbar.reviews.html.php
.................|***** Manual signatures are NOT allowed *****__toolbar.reviews.php
Hiện giờ mình chỉ làm phần back-end còn chưa quan tâm tới phần front-end :
Mình bị lỗi ở hàm saveReview() . Nằm trong file admin.reviews.php
Hàm saveReview()
Code: Select all
function saveReview($option)
{
global $mainframe;
$row =& JTable::getInstance('review', 'Table');
if (!$row->bind(JRequest::get('post')))
{
return JError::raiseWarning( 500, $row->getError() );
}
$row->quicktake = JRequest::getVar('quicktake', '', 'post', 'string', JREQUEST_ALLOWRAW);
$row->review = JRequest::getVar('review', '', 'post', 'string', JREQUEST_ALLOWRAW);
if(!$row->review_date)
$row->review_date=date('Y-m-d H:i:s');
if(!$row->store())
{
JError::raiseError(500, $row->getError() );
}
switch($task)
{
case 'apply':
$msg='Changes to Review saved';
$link='index.php?option='.$option.'&task=edit&cid[]='.$row->id;
break;
case 'save':
default:
$msg='Review saved';
$link='index.php?option='.$option;
break;
}
$mainframe->redirect($link, $msg);
}
Code: Select all
<?php
defined('_JEXEC') or die('Restricted access');
class TableReview extends JTable
{
var $id=null;
var $name=null;
var $address=null;
var $reservations=null;
var $quicktake=null;
var $review=null;
var $notes=null;
var $smoking=null;
var $credit_cards=null;
var $cuisine=null;
var $avg_dinner_price=null;
var $review_date=null;
var $published=null;
function __construct(&$db)
{
parent::__construct('#_reviews', 'id', $db);
}
}
?>