需要吧PHP.ini,的display_errors關掉!
作業:
1,熟悉joomla的資料庫操作
2,開發插件
3,設計模闆
4,子產品
1, JTable::addIncludePath( JPATH_COMPONENT.DS.'tables' );
要在元件目錄下建立一個tables,把資料庫檔案放進去
命名規則
$row = &JTable::getInstance('Comments','Table');
選項使用
$ranks = array(
'0'=>array('value'=>'0','text'=>'好')
,'1'=>array('value'=>'1','text'=>'一般')
,'2'=>array('value'=>'2','text'=>'差')
);
$lists['user_id'] = JHTML::_('list.users', 'user_id', $row->user_id, 1, NULL, 'name', 0);
$lists['ranks'] = JHTML::_('select.genericList'(這個為HTML類型), $ranks(資料源為一個二維數組), 'ranks'(ID的名字), 'class-"inputbox" '.'','value'(值),'text'(文本)
,$row->ranks(預設值));
問題1:怎麼存日期?
2011,1,21
基本操作:
儲存,删除都有預設值
儲存(save),删除(remove)
任務為task字段
元件開發總結:
命名規則:
檔案夾:com_comments
執行的php檔案為:admin.comments.php
常用模闆:
defined('_JEXEC') or die('Restricted access');
require_once (JApplicationHelper::getPath('admin_html'));
JTable::addIncludePath( JPATH_COMPONENT.DS.'tables' );
switch ($task){
case 'edit':
case 'add':
editComment($option);
break;
case 'save':
case 'apple':
saveComment($option);
case 'remove':
removeComment($option);
default:
showComment($option);
}
其中,save,remove,edit都為預設方法名
顯示檔案:admin.comments.html.php
資料庫表: 如檔案名為comments,類名要為TableComments
常錯記錄:
1.要切記for循環嵌套
本文轉自 liam2199 部落格,原文連結:http://blog.51cto.com/youxilua/773052 如需轉載請自行聯系原作者