本文整理汇总了PHP中AppModel::read方法的典型用法代码示例。如果您正苦于以下问题:PHP AppModel::read方法的具体用法?PHP AppModel::read怎么用?PHP AppModel::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppModel
的用法示例。
在下文中一共展示了AppModel::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: read
public function read($fields = null, $id = null, $unify = true)
{
$category = parent::read($fields, $id);
if (!empty($category) && $unify) {
$category[is_string($unify) ? $unify : 'Category'] = $category[$this->alias];
}
return $category;
}
示例2: readCached
/**
*
* @param AppModel $model
* @param int $id
*/
public function readCached($model, $id = null)
{
if (empty($id)) {
$id = $model->getID();
}
$key = $model->Behaviors->enabled('Translate') ? Inflector::underscore($model->alias) . "_{$id}_" . SlConfigure::read('I18n.locale') : Inflector::underscore($model->alias) . "_{$id}";
$data = Cache::read($key, 'models');
if (empty($data)) {
Cache::write($key, $data = $model->read(null, $id), 'models');
}
return $data;
}
示例3: isset
/**
* SetById method. Check is model innitialized.
*
* If $id is defined read record from model with this primary key value
*
* @param AppModel $model
* @param ID $id - value of model primary key to read
* @return boolean True if model initialized, false if no info in $model->data exists.
* @access private
*/
function __setById(&$model, $id = null, $checkId = true)
{
if (!isset($id)) {
if ($checkId) {
return isset($model->data[$model->alias]['id']);
} else {
return isset($model->data[$model->alias]);
}
} else {
return $model->read(null, $id);
}
}
示例4: read
function read($fields = null, $id = null)
{
$data = parent::read($fields, $id);
if ($data) {
if (!empty($data['CmsNode']['model'])) {
$data2 = ClassRegistry::init("{$data['CmsNode']['plugin']}.{$data['CmsNode']['model']}")->read(null, $data['CmsNode']['foreign_key']);
if ($data2) {
$data += $data2;
} else {
$data = null;
}
}
}
return $data;
}
示例5: testTwitterSaveToken
function testTwitterSaveToken()
{
$this->loadFixtures('UserToken');
$this->TestModel = ClassRegistry::init('UserToken');
$this->TestModel->Behaviors->attach('TwitterKit.Twitter');
// --
$this->TestModel->id = 4;
$this->TestModel->twitterSetToken('dummy_token4', 'dummy_secret4');
$result = $this->TestModel->twitterSaveToken();
$this->assertTrue($result);
$data = $this->TestModel->read();
$this->assertEqual('dummy_token4', $data['UserToken']['oauth_token']);
$this->assertEqual('dummy_secret4', $data['UserToken']['oauth_token_secret']);
// --
$this->TestModel->Behaviors->Twitter->DataSource->reset();
$this->TestModel->Behaviors->detach('TwitterKit.Twitter');
$this->TestModel->Behaviors->attach('TwitterKit.Twitter', array('fields' => array('oauth_token' => 'access_token', 'oauth_token_secret' => 'access_token_secret')));
$this->TestModel->twitterSetToken('dummy_token5', 'dummy_secret5');
$result = $this->TestModel->twitterSaveToken(5);
$this->assertTrue($result);
$data = $this->TestModel->read();
$this->assertEqual('dummy_token5', $data['UserToken']['access_token']);
$this->assertEqual('dummy_secret5', $data['UserToken']['access_token_secret']);
}
示例6: beforeDelete
/**
* Callback
* Populates the $Model->data with the current register that will be deleted
* for the callback afterDelete
*
* @access public
*
* @param AppModel $Model
* @param bool $cascade
*
* @return bool|mixed
*/
public function beforeDelete(&$Model, $cascade)
{
$Model->read();
return true;
}
示例7: AppModel
<?php
$obj = new AppModel($id);
$obj->useTable = 'pl_miejscowosci';
$obj->alias = 'Miejscowosc';
$obj->read();
return $this->DB->query('SELECT Powiat.id,Powiat.nazwa, Wojewodztwo.id, Wojewodztwo.nazwa FROM pl_powiaty Powiat, wojewodztwa Wojewodztwo WHERE Powiat.id = ' . $obj->data['Miejscowosc']['powiat_id'] . ' AND Wojewodztwo.id=' . $obj->data['Miejscowosc']['woj_id']);
示例8: getparentnode
/**
* Get the parent node
*
* reads the parent id and returns this node
*
* @param AppModel $model
* @param mixed $id The ID of the record to read
* @param integer $recursive The number of levels deep to fetch associated records
* @return array Array of data for the parent node
* @access public
*/
function getparentnode(&$model, $id = null, $fields = null, $recursive = -1)
{
if (empty($id)) {
$id = $model->id;
}
extract($this->settings[$model->alias]);
$parentId = $model->read($parent, $id);
if ($parentId) {
$parentId = $parentId[$model->alias][$parent];
$parent = $model->find('first', array('conditions' => array($model->escapeField() => $parentId), 'fields' => $fields, 'recursive' => $recursive));
return $parent;
} else {
return false;
}
}
示例9: twitterSetTokenById
/**
* set OAuth Access Token By Id
*
* @param AppModel $model
* @param mixed $id
* @return true|false
*/
public function twitterSetTokenById($model, $id = null)
{
if (is_null($id)) {
$id = $model->id;
}
$data = $model->read($this->settings[$model->alias]['fields'], $id);
if (empty($data[$model->alias])) {
return false;
}
return $this->twitterSetToken($model, $data[$model->alias]);
}
示例10: __setById
/**
* SetById method. Check is model innitialized.
*
* If $id is defined read record from model with this primary key value
*
* @param AppModel $model
* @param ID $id - value of model primary key to read
* @return boolean True if model initialized, false if no info in $model->data exists.
*/
private function __setById($model, $id = null, $checkId = true)
{
if (!isset($id)) {
if ($checkId) {
return isset($model->data[$model->alias][$model->primaryKey]);
} else {
return isset($model->data[$model->alias]);
}
} else {
return $model->read(null, $id);
}
}
示例11: read
/**
* undocumented function
*
* @param string $fields
* @param string $id
* @return void
*/
function read($fields = null, $id = null)
{
$data = parent::read($fields, $id);
$data['Project']['config'] = unserialize($data['Project']['config']);
return $data;
}
示例12: moveup
/**
* Move up element
*
* @param AppModel $Model Model instance
* @param mixed $id The ID of the record to move
* @param mixed $number how many places to move the node, or true to move to first position
* @return boolean true on success, false on failure
*/
public function moveup(&$Model, $id = null, $number = 1)
{
if (is_array($id)) {
extract(array_merge(array('id' => null), $id));
}
if (!$number) {
return false;
}
if (empty($id)) {
$id = $Model->id;
}
$data = $Model->read(am($this->settings[$Model->alias]['order_field'], $this->settings[$Model->alias]['group_fields']), $id);
$order = $data[$Model->alias][$this->settings[$Model->alias]['order_field']];
if (is_int($number)) {
$order -= abs($number);
} elseif ($number === true) {
$order = $this->settings[$Model->alias]['start_at'];
} else {
return false;
}
if ($order < $this->settings[$Model->alias]['start_at']) {
$order = $this->settings[$Model->alias]['start_at'];
}
$Model->id = $id;
return $Model->saveField($this->settings[$Model->alias]['order_field'], $order);
}
示例13: _getData
/**
*
* @param AppModel $model
* @return array
*/
protected function _getData($model)
{
$_recursive = $model->recursive;
$model->recursive = -1;
$data = $model->read(null, $model->id);
$model->recursive = $_recursive;
return $data[$model->alias];
}
示例14: getparentnode
/**
* Get the parent node
*
* reads the parent id and returns this node
*
* @param AppModel $model
* @param mixed $id The ID of the record to read
* @param integer $recursive The number of levels deep to fetch associated records
* @return array Array of data for the parent node
* @access public
*/
function getparentnode(&$model, $id = null, $fields = null, $recursive = -1)
{
if (empty($id)) {
$id = $model->id;
}
extract($this->settings[$model->name]);
$parentId = $model->read($parent, $id);
if ($parentId) {
$parentId = $parentId[$model->name][$parent];
$parent = $model->find(array($model->escapeField() => $parentId), $fields, null, $recursive);
return $parent;
} else {
return false;
}
}
示例15: getparentnode
/**
* Get the parent node
*
* reads the parent id and returns this node
*
* @param AppModel $Model Model instance
* @param mixed $id The ID of the record to read
* @param integer $recursive The number of levels deep to fetch associated records
* @return array Array of data for the parent node
* @access public
*/
function getparentnode(&$Model, $id = null, $fields = null, $recursive = null)
{
if (is_array($id)) {
extract(array_merge(array('id' => null), $id));
}
$overrideRecursive = $recursive;
if (empty($id)) {
$id = $Model->id;
}
extract($this->settings[$Model->alias]);
if (!is_null($overrideRecursive)) {
$recursive = $overrideRecursive;
}
$parentId = $Model->read($parent, $id);
if ($parentId) {
$parentId = $parentId[$Model->alias][$parent];
$parent = $Model->find('first', array('conditions' => array($Model->escapeField() => $parentId), 'fields' => $fields, 'recursive' => $recursive));
return $parent;
}
return false;
}