本文整理汇总了PHP中ORM::pk方法的典型用法代码示例。如果您正苦于以下问题:PHP ORM::pk方法的具体用法?PHP ORM::pk怎么用?PHP ORM::pk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ORM
的用法示例。
在下文中一共展示了ORM::pk方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove
/**
* Removes a relationship between this model and another.
*
* @param string alias of the has_many "through" relationship
* @param ORM related ORM model
* @return ORM
*/
public function remove($alias, ORM $model)
{
DB::delete($this->_has_many[$alias]['through'])->where($this->_has_many[$alias]['foreign_key'], '=', $this->pk())->where($this->_has_many[$alias]['far_key'], '=', $model->pk())->execute($this->_db);
return $this;
}
示例2: remove
/**
* Removes a relationship between this model and another.
*
* @param string alias of the has_many "through" relationship
* @param ORM related ORM model
*/
public function remove($alias, ORM $model)
{
$through = ORM::factory($this->_has_many[$alias]['through']);
// Match this model's primary key in through table
$col1 = $this->_object_name . $through->_foreign_key_suffix;
$val1 = $this->pk();
// Match other model's primary key in through table
$col2 = $model->_object_name . $through->_foreign_key_suffix;
$val2 = $model->pk();
$through->where($col1, '=', $val1)->where($col2, '=', $val2)->delete_all();
}
示例3: __construct
/**
* Creates a new MAttach.
*
* $mattach = new MAttach($user,$log);
*
* @param ORM Model
* @param ORM/String Model to Save
* @return void
*/
public function __construct(ORM $model, $smodel)
{
if ($smodel instanceof ORM)
{
try
{
$this->model = $smodel;
$this->model->model_id = $model->pk();
$this->model->model_name = $model->object_name();
}
catch (Exception $e)
{
throw $e;
}
}
elseif (is_string($smodel))
{
try
{
$this->model = ORM::factory($smodel);
$this->model->model_id = $model->pk();
$this->model->model_name = $model->object_name();
}
catch (Exception $e)
{
throw $e;
}
}
else
{
throw new Exception('WTF?');
}
}
示例4: get
/**
* @param ORM $obj
*/
public static function get($obj)
{
return ORM::factory('Seo')->where('model', '=', strtolower($obj->object_name()))->where('pk', '=', $obj->pk())->find();
}