本文整理汇总了PHP中JTable::hasPrimaryKey方法的典型用法代码示例。如果您正苦于以下问题:PHP JTable::hasPrimaryKey方法的具体用法?PHP JTable::hasPrimaryKey怎么用?PHP JTable::hasPrimaryKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JTable
的用法示例。
在下文中一共展示了JTable::hasPrimaryKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHasPrimaryKeyAutoincrementFalse
/**
* Test for hasPrimaryKey method with table that has auto increment and the result is false.
*
* @return void
*
* @since 12.3
*/
public function testHasPrimaryKeyAutoincrementFalse()
{
TestReflection::setValue($this->object, '_autoincrement', true);
$this->object->id1 = null;
$this->object->id2 = null;
$this->assertFalse($this->object->hasPrimaryKey());
}
示例2: hasPrimaryKey
/**
* Validate that the primary key has been set.
*
* @return boolean True if the primary key(s) have been set.
*
* @since 1.5.2
*/
public function hasPrimaryKey()
{
// For Joomla 3.2+ a native method has been provided
if (method_exists(get_parent_class(), 'hasPrimaryKey')) {
return parent::hasPrimaryKey();
}
// Otherwise, it checks if the only key field compatible for older Joomla versions is set or not
if (isset($this->_tbl_key) && !empty($this->_tbl_key) && empty($this->{$this->_tbl_key})) {
return false;
}
return true;
}