本文整理汇总了PHP中AppModel::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP AppModel::findById方法的具体用法?PHP AppModel::findById怎么用?PHP AppModel::findById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppModel
的用法示例。
在下文中一共展示了AppModel::findById方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sess_write
function sess_write($key, $value)
{
// If the client doesn't have a session, and one isn't being created ($value), do nothing.
if (empty($_COOKIE[session_name()]) && empty($value)) {
return TRUE;
}
$Controller = getInstance()->Controller;
$Session = new AppModel('Session');
$result = $Session->findById($key);
$user_id = 0;
if (isset($Controller->User->user['id'])) {
$user_id = $Controller->User->user['id'];
}
if (isset($result['Session']['id'])) {
$Session->save(array('hostname' => $_SERVER['REMOTE_ADDR'], 'session' => $value), array('id' => $key));
} else {
$Session->create(array('id' => $key, 'hostname' => $_SERVER['REMOTE_ADDR'], 'session' => $value));
}
return TRUE;
}
示例2: extract
/**
* Get the parent node
*
* reads the parent id and returns this node
*
* @since 1.2
* @param AppModel $model
* @param mixed $id The ID of the record to read
* @param int $recursive The number of levels deep to fetch associated records
* @return array Array of data for the parent node
* @access public
*/
function get_parent_node(&$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->findById($parentId, $fields, null, $recursive);
return $parent;
} else {
return false;
}
}
示例3: __insertAtPosition
/**
* Inserts an item on a certain position
*
* @param AppModel $model
* @param $position
* @return boolean
*/
private function __insertAtPosition($model, $position)
{
extract($this->settings[$model->alias]);
$data = $model->data;
$model->data[$model->alias][$positionColumn] = 0;
$model->save(null, array('validate' => $validate, 'callbacks' => $callbacks));
$model->create($data);
$model->recursive = 0;
$model->findById($model->id);
$this->removeFromList($model);
$result = $this->__incrementPositionsOnLowerItems($model, $position);
if ($position <= $this->__bottomPositionInList($model) + 1) {
$model->data[$model->alias][$positionColumn] = $position;
$result = $model->save(null, array('validate' => $validate, 'callbacks' => $callbacks));
}
return $result;
}