本文整理汇总了PHP中Record::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Record::get方法的具体用法?PHP Record::get怎么用?PHP Record::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record::get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRecordCallsLoadIfAnAttributeWasNotSetYet
public function testRecordCallsLoadIfAnAttributeWasNotSetYet()
{
$record = new Record(array('id' => 4), $this->dao, TRUE);
$this->dao->expects($this->any())->method('getAttributes')->will($this->returnValue(array('id' => Dao::INT, 'name' => Dao::STRING)));
$this->dao->expects($this->once())->method('getData')->with(array('id' => 4))->will($this->returnValue(array('id' => 4, 'name' => 'Test')));
self::assertEquals('Test', $record->get('name'));
self::assertEquals('Test', $record->get('name'));
// Checking it doesn't load twice
}
示例2: removeMeta
/**
* /
* @param Record $record [description]
* @return [type] [description]
*/
public function removeMeta(Record $record)
{
$item_name = $record->get('item_name');
$item_id = $record->get('item_id');
$key = $record->get('key');
if (!is_string($item_name) || !is_int($item_id) || !is_string($key)) {
throw new \Exception("Invalid input type", 1);
}
$sql = "DELETE FROM metadata WHERE item_name=:item_name AND item_id=:item_id AND key=:key";
$result = $this->db->run($sql, array('item_name' => $item_name, 'item_id' => $item_id, 'key' => $key));
return $result;
}
示例3: removeAllAttachments
/**
* /
* @param Record $record [description]
* @return [type] [description]
*/
public function removeAllAttachments(Record $record)
{
$id = $record->get('id');
$item_name = $record->get('item_name');
if (!is_int($id) || !is_string($item_name)) {
throw new \Exception("Invalid input type", 1);
}
$bind = array('group_name' => $this->slug, 'group_id' => $id, 'item_name' => $item_name);
$sql = "DELETE FROM attachments WHERE group_name=:group_name, group_id=:group_id, item_name=:item_name";
$result = $this->db->run($sql, $bind);
return $result;
}
示例4: getReferenced
/**
* Returns a DaoIterator for a specific reference.
* A DataSource can directly return the DataHash, so it doesn't have to be fetched.
*
* @param Record $record
* @param string $attribute The attribute it's being accessed on
* @return DaoIterator
*/
public function getReferenced($record, $attribute)
{
if ($data = $record->getDirectly($attribute)) {
if (is_array($data)) {
if (count($data) === 0 || is_array(reset($data))) {
// The data hash is an array, either empty, or containing the hashes.
return new DaoHashListIterator($data, $this->getForeignDao());
} elseif (is_int(reset($data)) && ($foreignKey = $this->getForeignKey())) {
// The data hash is an array containing the ids, and there is a
// foreign key to link them to.
return new DaoKeyListIterator($data, $this->getForeignDao(), $foreignKey);
}
}
Log::warning(sprintf('The data hash for `%s` was set but incorrect.', $attribute));
return new DaoHashListIterator(array(), $this->getForeignDao());
} else {
// Get the list of ids
$localKey = $this->getLocalKey();
$foreignKey = $this->getForeignKey();
if ($localKey && $foreignKey) {
$localValue = $record->get($localKey);
return new DaoKeyListIterator($localValue ? $localValue : array(), $this->getForeignDao(), $foreignKey);
}
return new DaoKeyListIterator(array(), $this->getForeignDao(), $foreignKey);
}
}
示例5: getReferenced
/**
* Returns a DaoIterator for a specific reference.
* A DataSource can directly return the DataHash, so it doesn't have to be fetched.
*
* @param Record $record
* @param string $attribute The attribute it's being accessed on
* @return DaoIterator
*/
public function getReferenced($record, $attribute)
{
$foreignDao = $this->getForeignDao();
$joinDao = $this->getJoinDao();
// Get all joins, that point to the local key.
$joins = $joinDao->getIterator($this->applyFilter(array($this->getJoinToLocalKey() => $record->get($this->getLocalKey()))));
// Extract an array of foreign keys.
$foreignKeys = array();
foreach ($joins as $join) {
$foreignKeys[] = $join->get($this->getJoinToForeignKey());
}
// And return the key list iterator.
return new DaoKeyListIterator($foreignKeys, $this->getForeignDao(), $this->getForeignKey());
}
示例6: getReferenced
/**
* Returns a DaoIterator for a specific reference.
* A DataSource can directly return the DataHash, so it doesn't have to be fetched.
*
* @param Record $record
* @param string $attribute The attribute it's being accessed on
* @return DaoIterator
*/
public function getReferenced($record, $attribute)
{
return $this->getForeignDao()->find(array($this->getForeignKey() => $record->get($this->getLocalKey())));
}
示例7: getData
function getData($field = null)
{
return $this->escape(parent::get($field));
}