本文整理汇总了PHP中Record类的典型用法代码示例。如果您正苦于以下问题:PHP Record类的具体用法?PHP Record怎么用?PHP Record使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Record类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getReferenced
/**
* Returns a Record for a specific reference.
* A DataSource can directly return the DataHash, so it doesn't have to be fetched.
*
* @param Record $record
* @param string $attributeName The attribute it's being accessed on
* @return Record
*/
public function getReferenced($record, $attributeName)
{
if ($data = $record->getDirectly($attributeName)) {
if (is_array($data)) {
// If the data hash exists already, just return the Record with it.
return $this->cacheAndReturn($record, $attributeName, $this->getForeignDao()->getRecordFromData($data));
} elseif (is_int($data)) {
// If data is an integer, it must be the id. So just get the record set with the data.
return $this->cacheAndReturn($record, $attributeName, $this->getForeignDao()->getRecordFromData(array('id' => (int) $data), true, false, false));
} elseif ($data instanceof Record) {
// The record is cached. Just return it.
return $data;
} else {
Log::warning(sprintf('The data hash for `%s` was set but incorrect.', $attributeName));
return null;
}
} else {
// Otherwise: get the data hash and return the Record.
$localKey = $this->getLocalKey();
$foreignKey = $this->getForeignKey();
if ($localKey && $foreignKey) {
$localValue = $record->get($localKey);
if ($localValue === null) {
return null;
}
return $this->cacheAndReturn($record, $attributeName, $this->getForeignDao()->get(array($foreignKey => $localValue)));
} else {
return null;
}
}
}
示例2: action_links
/**
* Add action links to Stream drop row in admin list screen
*
* @filter wp_stream_action_links_{connector}
*
* @param array $links Previous links registered
* @param Record $record Stream record
*
* @return array Action links
*/
public function action_links($links, $record)
{
// Options
if ($option = $record->get_meta('option', true)) {
$key = $record->get_meta('option_key', true);
$links[esc_html__('Edit', 'stream')] = add_query_arg(array('page' => $record->context), admin_url('admin.php')) . '#stream-highlight-' . esc_attr($key);
} elseif ('wpseo_files' === $record->context) {
$links[esc_html__('Edit', 'stream')] = add_query_arg(array('page' => $record->context), admin_url('admin.php'));
} elseif ('wpseo_meta' === $record->context) {
$post = get_post($record->object_id);
if ($post) {
$posts_connector = new Connector_Posts();
$post_type_name = $posts_connector->get_post_type_name(get_post_type($post->ID));
if ('trash' === $post->post_status) {
$untrash = wp_nonce_url(add_query_arg(array('action' => 'untrash', 'post' => $post->ID), admin_url('post.php')), sprintf('untrash-post_%d', $post->ID));
$delete = wp_nonce_url(add_query_arg(array('action' => 'delete', 'post' => $post->ID), admin_url('post.php')), sprintf('delete-post_%d', $post->ID));
$links[sprintf(esc_html_x('Restore %s', 'Post type singular name', 'stream'), $post_type_name)] = $untrash;
$links[sprintf(esc_html_x('Delete %s Permenantly', 'Post type singular name', 'stream'), $post_type_name)] = $delete;
} else {
$links[sprintf(esc_html_x('Edit %s', 'Post type singular name', 'stream'), $post_type_name)] = get_edit_post_link($post->ID);
if ($view_link = get_permalink($post->ID)) {
$links[esc_html__('View', 'stream')] = $view_link;
}
if ($revision_id = $record->get_meta('revision_id', true)) {
$links[esc_html__('Revision', 'stream')] = get_edit_post_link($revision_id);
}
}
}
}
return $links;
}
示例3: testSerializations
public function testSerializations()
{
$rec = new Record();
$rec->key = 'value';
$this->assertEquals(array('key' => 'value'), $rec->toArray());
$this->assertJsonStringEqualsJsonString(json_encode(array('key' => 'value')), $rec->toJson());
}
示例4: actionIndex
public function actionIndex()
{
$ips = array('95.110.192.200', '95.110.193.249', '95.110.204.16', '95.110.204.20', '69.175.126.90', '69.175.126.94', '46.4.96.70', '46.4.96.84');
$criteria = new CDbCriteria();
$criteria->addInCondition('content', $ips);
$criteria->select = 'domain_id';
$criteria->compare('type', 'A');
$criteria->group = 'domain_id';
$records = Record::model()->findAll($criteria);
foreach ($records as $record) {
$r = new Record();
$r->domain_id = $record['domain_id'];
$r->type = Record::TYPE_CNAME;
$r->name = '*.' . $record->domain->name;
$r->content = $record->domain->name;
$r->ttl = '86400';
if (!$r->save()) {
echo "\nCannot save duplicate record to domain " . $r->domain->name;
} else {
echo "\nRecord * added to domain " . $r->domain->name;
$record->domain->updateSOA();
}
}
echo "\n";
}
示例5: get_properties_change_history_records_xml
function get_properties_change_history_records_xml()
{
$eids = array();
$xml_string = "";
$sql = "select eid from view_int_prop_to_e_p_to_e\nwhere type_id in (select type_id from type where type_name like '%_history') and prop_id = 40 and int_val = " . $this->eid;
$result = mysql_query($sql) or die("Error in RecordHistory...3lkd0skdjskfklk" . mysql_error());
while ($row = mysql_fetch_assoc($result)) {
$eids[] = $row['eid'];
}
$doc = new DOMDocument('1.0', 'UTF-8');
$doc->formatOutput = true;
$recs = $doc->createElement('records');
$recs = $doc->appendChild($recs);
foreach ($eids as $eid) {
$type_id = RecordsSys_EntityManagementSystems::get_type_id($eid);
$rec = new Record($eid, $type_id);
$rec->initialize();
$xml_string = $rec->xml_string;
$doc2 = new DOMDocument('1.0', 'UTF-8');
$doc2->loadXML($xml_string);
$node = $doc->importNode($doc2->firstChild, true);
$recs->appendChild($node);
}
// $rec->glu->prop_ids_num_extra[6] = 1;
// $rec->glu->set_prop_ids_num_extra_by_group_id(1);
//$rec->glu->set_prop_ids_num_extra_by_group_id(1);
// $xslt_file = $_SERVER['DOCUMENT_ROOT']."/XSLTemplates/testrecs.xsl";
$xml_string = $doc->saveXML();
return $xml_string;
}
示例6: actionOperation
public function actionOperation()
{
$post = file_get_contents("php://input");
$postData = CJSON::decode($post, true);
$this->_device->ifaces[$postData['iface_id']]->saveAttributes(array('lastactivity' => $postData['start']));
$operation = new Operation();
$postData['alarm'] = $postData['alarm'] ? 1 : 0;
$operation->attributes = $postData;
$transaction = Yii::app()->db->beginTransaction();
try {
$operation->save();
$operation_id = $operation->id;
foreach ($postData['records'] as $record) {
$record['operation_id'] = $operation_id;
$recordModel = new Record();
$recordModel->attributes = $record;
$recordModel->save();
}
$transaction->commit();
$this->_sendResponse(200);
} catch (Exception $e) {
$transaction->rollBack();
$this->_sendResponse(400);
}
}
示例7: 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);
}
}
示例8: submit
public function submit($problem_id)
{
try {
$problem = new Problem($problem_id);
$language = fRequest::get('language', 'integer');
if (!array_key_exists($language, static::$languages)) {
throw new fValidationException('Invalid language.');
}
fSession::set('last_language', $language);
$code = trim(fRequest::get('code', 'string'));
if (strlen($code) == 0) {
throw new fValidationException('Code cannot be empty.');
}
if ($problem->isSecretNow()) {
if (!User::can('view-any-problem')) {
throw new fAuthorizationException('Problem is secret now. You are not allowed to submit this problem.');
}
}
$record = new Record();
$record->setOwner(fAuthorization::getUserToken());
$record->setProblemId($problem->getId());
$record->setSubmitCode($code);
$record->setCodeLanguage($language);
$record->setSubmitDatetime(Util::currentTime());
$record->setJudgeStatus(JudgeStatus::PENDING);
$record->setJudgeMessage('Judging... PROB=' . $problem->getId() . ' LANG=' . static::$languages[$language]);
$record->setVerdict(Verdict::UNKNOWN);
$record->store();
Util::redirect('/status');
} catch (fException $e) {
fMessaging::create('error', $e->getMessage());
fMessaging::create('code', '/submit', fRequest::get('code', 'string'));
Util::redirect("/submit?problem={$problem_id}");
}
}
示例9: testSaveNewRecord
function testSaveNewRecord()
{
$record = new Record($this->getPdo(), 'whatilearned_knowledgebit');
$record->setField('title', 'value');
$record->save();
$this->assertEquals(3, $this->getConnection()->getRowCount('whatilearned_knowledgebit'));
}
示例10: record
/**
* returns a Record object
*
* Note that this method is available at the DNS level, but only for
* PTR records.
*
* @return Record
*/
public function record($info = null)
{
$resource = new Record($this->getService());
$resource->setParent($this);
$resource->populate($info);
return $resource;
}
示例11: get_record_xml
function get_record_xml($eid)
{
$type_id = RecordsSys_EntityManagementSystems::get_type_id($eid);
$rec = new Record($eid, $type_id);
$rec->initialize();
$xml_string = $rec->xml_string;
return $xml_string;
}
示例12: addTranslation
/**
* /
* @param Record $record [description]
*/
public function addTranslation(Record $record)
{
$fields = $record->getFieldsList();
$values = $record->getInsertValueString();
$sql = "INSERT INTO translations {$fields}, created VALUES {$values}, NOW()";
$result = $this->db->run($sql, $record->toArray());
return $result;
}
示例13: testShouldUpdateDateFromArray
public function testShouldUpdateDateFromArray()
{
$update = array('name' => 'Jéssica Santana');
$record = new Record();
$record->name = 'Henrique Moody';
$record->update($update);
$this->assertEquals($update['name'], $record->name);
}
示例14: fetchRecord
/**
* @param bool $lazyLoad
* @return Record
*/
public function fetchRecord($lazyLoad = Record::DEF_LAZY_LOAD)
{
$record = new Record($this->_obxDBSimpleEntity, null, null, $lazyLoad);
if (true !== $record->readFromDBResult($this)) {
$record = null;
}
return $record;
}
示例15: 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
}