本文整理汇总了PHP中JTable::getFields方法的典型用法代码示例。如果您正苦于以下问题:PHP JTable::getFields方法的具体用法?PHP JTable::getFields怎么用?PHP JTable::getFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JTable
的用法示例。
在下文中一共展示了JTable::getFields方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRowData
/**
* Gets a row of data from a table
*
* @param JTable $table JTable instance for a row.
*
* @return array Associative array of all columns and values for a row in a table.
*
* @since 3.1
*/
public function getRowData($table)
{
$fields = $table->getFields();
$data = array();
foreach ($fields as &$field) {
$columnName = $field->Field;
$value = $table->{$columnName};
$data[$columnName] = $value;
}
return $data;
}
示例2: testGetFields
/**
* Test for getFields method.
*
* @return void
*
* @since 12.3
*/
public function testGetFields()
{
$this->assertEquals(array('id1' => (object) array('Field' => 'id1', 'Type' => 'INTEGER', 'Null' => 'NO', 'Default' => '\'0\'', 'Key' => 'PRI'), 'id2' => (object) array('Field' => 'id2', 'Type' => 'INTEGER', 'Null' => 'NO', 'Default' => '\'0\'', 'Key' => 'PRI'), 'title' => (object) array('Field' => 'title', 'Type' => 'TEXT', 'Null' => 'NO', 'Default' => '\'\'', 'Key' => ''), 'asset_id' => (object) array('Field' => 'asset_id', 'Type' => 'INTEGER', 'Null' => 'NO', 'Default' => '\'0\'', 'Key' => ''), 'hits' => (object) array('Field' => 'hits', 'Type' => 'INTEGER', 'Null' => 'NO', 'Default' => '\'0\'', 'Key' => ''), 'checked_out' => (object) array('Field' => 'checked_out', 'Type' => 'INTEGER', 'Null' => 'NO', 'Default' => '\'0\'', 'Key' => ''), 'checked_out_time' => (object) array('Field' => 'checked_out_time', 'Type' => 'TEXT', 'Null' => 'NO', 'Default' => '\'0000-00-00 00:00:00\'', 'Key' => ''), 'published' => (object) array('Field' => 'published', 'Type' => 'INTEGER', 'Null' => 'NO', 'Default' => '\'0\'', 'Key' => ''), 'publish_up' => (object) array('Field' => 'publish_up', 'Type' => 'TEXT', 'Null' => 'NO', 'Default' => '\'0000-00-00 00:00:00\'', 'Key' => ''), 'publish_down' => (object) array('Field' => 'publish_down', 'Type' => 'TEXT', 'Null' => 'NO', 'Default' => '\'0000-00-00 00:00:00\'', 'Key' => ''), 'ordering' => (object) array('Field' => 'ordering', 'Type' => 'INTEGER', 'Null' => 'NO', 'Default' => '\'0\'', 'Key' => ''), 'params' => (object) array('Field' => 'params', 'Type' => 'TEXT', 'Null' => 'NO', 'Default' => '\'\'', 'Key' => '')), $this->object->getFields());
}
示例3: getDataObject
/**
* Method to get an object containing all of the table columns and values.
*
* @param JTable $table JTable object.
*
* @return object Contains all of the columns and values.
*
* @since 3.2
*/
public function getDataObject(JTable $table)
{
$fields = $table->getFields();
$dataObject = new stdClass();
foreach ($fields as $field) {
$fieldName = $field->Field;
$dataObject->{$fieldName} = $table->get($fieldName);
}
return $dataObject;
}