JTable是什么?
JTable是数据库中数据表在程序中的表达,其实JTable更对应着表中的一行,以及相应的操作。Joomla中的 JTable**对应中数据库中 **表,我们在使用的时候要针对我们自己所使用的表扩展自己的JTable.我们需要关注的是JTable的函数checkin,checkout ,这两个函数对更新的数据进行合法性检查,我个人觉得对于数据完整性的检查应该放在Jtable的check中。
Jtable 比较常用的函数,看名字就明白了,记住几个吧:
delete,store,bind,load,setError等,具体还是需要用的时候看看源代码吧。
数据表类
Method
Description
IsCheckedOut
检测,一个项目是否被检查
__construct
构造函数
addIncludePath
添加个jtable应寻找表类型的目录,可通过一个字符串或一个数组的目录。
Bind
绑定一个命名数组/哈希到这个对象
Candelete
一般检查是否dependancies存在这个对象,在数据库架构
Check
一般检测方法
Checkin
检测行
Checkout
检测列
Delete
默认删除方法
getDBO
得到数据库对象
getInstance
实例化
getKeyName
得到内部主键名
getNextOrder
返回顺序值,替换组里的新项目
getTableName
得到内部表的名字
Hit
Load
读取数据库的一行并且绑定
Move
Publish
发布/取消的方法
Reorder
序列选定的记录
Reset
重置默认属性
Save
保存
setDBO
设置内部数据库对象
Store
插入或者更新行
toXML
导出项目到XML
addIncludePath()
意义添加个jtable应寻找表类型的目录,可通过一个字符串或一个数组的目录。:
语法: array addIncludePath ([string $path = null])
string $path: A path to search.
实际应用:
jimport('joomla.database.table');
$temp =& new jtable;
$tem = $temp->addIncludePath('var/www/trunk');
print_r($tem);
Candelete()
意义: 一般检查是否dependancies存在这个对象,在数据库架构
语法: true|false canDelete ([ $oid = null], [int $joins = null], string $msg, array 2)
string $msg: Error message returned
array 2: Optional array to compiles standard joins: format [label=>'Label',name=>'table name',idfield=>'field',joinfield=>'field']
int $joins: Optional key index
$oid
实际应用:
jimport('joomla.database.table');
$temp =& new jtable('jos_tilu_cal','id',$joomla);
$tem = $temp->candelete();
var_dump($tem);
Check()
意义: 一般检测方法
语法: boolean check ()
实际应用:
jimport('joomla.database.table');
$temp =& new jtable('jos_tilu_cal','id',$joomla);
$tem = $temp->check();
print_r($tem);
结果; True if the object is ok
Checkin()
意义: 检测行
语法: boolean checkin ([mixed $oid = null])
mixed $oid: The primary key value for the row
实际应用:
jimport('joomla.database.table');
$temp =& new jtable('jos_tilu_cal','id',$joomla);
$tem = $temp->checkin();
print_r($tem);
Checkout()
意义: 检测列
语法: boolean checkout (integer $who, [mixed $oid = null])
integer $who: The id of the user
mixed $oid: The primary key value for the row
实际应用:
jimport('joomla.database.table');
$temp =& new jtable('jos_tilu_cal','id',$joomla);
$tem = $temp->checkout($id);
print_r($tem);
结果: True if successful, or if checkout is not supported
getDBO()
意义: 得到数据库对象
语法: object A &getDBO ()
getKeyName()
意义: 得到内部主键名
语法: string getKeyName ()
getTableName()
意义: 得到内部表的名字
语法: string getTableName ()
实际应用:
jimport('joomla.database.table');
$tdb =& JFactory::getDBO();
$temp =& new jtable('jos_users','id',$tdb);
$db = $temp->getDBO();
$key = $temp->getKeyName();
$tablename = $temp->gettablename();
print_r($db);
echo "<br>";
print_r($key);
echo "<br>";
print_r($tablename);
echo "<br>";
JTable是数据库中数据表在程序中的表达,其实JTable更对应着表中的一行,以及相应的操作。Joomla中的 JTable**对应中数据库中 **表,我们在使用的时候要针对我们自己所使用的表扩展自己的JTable.我们需要关注的是JTable的函数checkin,checkout ,这两个函数对更新的数据进行合法性检查,我个人觉得对于数据完整性的检查应该放在Jtable的check中。
Jtable 比较常用的函数,看名字就明白了,记住几个吧:
delete,store,bind,load,setError等,具体还是需要用的时候看看源代码吧。
数据表类
Method
Description
IsCheckedOut
检测,一个项目是否被检查
__construct
构造函数
addIncludePath
添加个jtable应寻找表类型的目录,可通过一个字符串或一个数组的目录。
Bind
绑定一个命名数组/哈希到这个对象
Candelete
一般检查是否dependancies存在这个对象,在数据库架构
Check
一般检测方法
Checkin
检测行
Checkout
检测列
Delete
默认删除方法
getDBO
得到数据库对象
getInstance
实例化
getKeyName
得到内部主键名
getNextOrder
返回顺序值,替换组里的新项目
getTableName
得到内部表的名字
Hit
Load
读取数据库的一行并且绑定
Move
Publish
发布/取消的方法
Reorder
序列选定的记录
Reset
重置默认属性
Save
保存
setDBO
设置内部数据库对象
Store
插入或者更新行
toXML
导出项目到XML
addIncludePath()
意义添加个jtable应寻找表类型的目录,可通过一个字符串或一个数组的目录。:
语法: array addIncludePath ([string $path = null])
string $path: A path to search.
实际应用:
jimport('joomla.database.table');
$temp =& new jtable;
$tem = $temp->addIncludePath('var/www/trunk');
print_r($tem);
Candelete()
意义: 一般检查是否dependancies存在这个对象,在数据库架构
语法: true|false canDelete ([ $oid = null], [int $joins = null], string $msg, array 2)
string $msg: Error message returned
array 2: Optional array to compiles standard joins: format [label=>'Label',name=>'table name',idfield=>'field',joinfield=>'field']
int $joins: Optional key index
$oid
实际应用:
jimport('joomla.database.table');
$temp =& new jtable('jos_tilu_cal','id',$joomla);
$tem = $temp->candelete();
var_dump($tem);
Check()
意义: 一般检测方法
语法: boolean check ()
实际应用:
jimport('joomla.database.table');
$temp =& new jtable('jos_tilu_cal','id',$joomla);
$tem = $temp->check();
print_r($tem);
结果; True if the object is ok
Checkin()
意义: 检测行
语法: boolean checkin ([mixed $oid = null])
mixed $oid: The primary key value for the row
实际应用:
jimport('joomla.database.table');
$temp =& new jtable('jos_tilu_cal','id',$joomla);
$tem = $temp->checkin();
print_r($tem);
Checkout()
意义: 检测列
语法: boolean checkout (integer $who, [mixed $oid = null])
integer $who: The id of the user
mixed $oid: The primary key value for the row
实际应用:
jimport('joomla.database.table');
$temp =& new jtable('jos_tilu_cal','id',$joomla);
$tem = $temp->checkout($id);
print_r($tem);
结果: True if successful, or if checkout is not supported
getDBO()
意义: 得到数据库对象
语法: object A &getDBO ()
getKeyName()
意义: 得到内部主键名
语法: string getKeyName ()
getTableName()
意义: 得到内部表的名字
语法: string getTableName ()
实际应用:
jimport('joomla.database.table');
$tdb =& JFactory::getDBO();
$temp =& new jtable('jos_users','id',$tdb);
$db = $temp->getDBO();
$key = $temp->getKeyName();
$tablename = $temp->gettablename();
print_r($db);
echo "<br>";
print_r($key);
echo "<br>";
print_r($tablename);
echo "<br>";