public function createOrUpdate(array $args, $byKeys = null)
{
$pk = static::PRIMARY_KEY;
$ret = null;
if ($pk && isset($args[$pk])) {
$val = $args[$pk];
$ret = $this->load(array($pk => $val));
} elseif ($byKeys) {
$conds = array();
foreach ((array) $byKeys as $k) {
if (array_key_exists($k, $args)) {
$conds[$k] = $args[$k];
}
}
$ret = $this->load($conds);
}
if ($ret && $ret->success || $pk && isset($this->_data[$pk])) {
return $this->update($args);
} else {
return $this->create($args);
}
}