public function gen_value($input)
{
//如果为空,返回空
$input = trim($input);
if ($input == "" || $input == "-") {
return "";
}
//先检查是不是已经是 mongoid
if (strlen($input) == 24 && MongoId::isValid($input)) {
return $input;
}
$this->db->select(array($this->valueField, $this->showField))->where(array($this->showField => $input));
if (!isset($this->whereOrgId)) {
$this->whereOrgId = $this->CI->myOrgId;
}
$this->db->where(array('orgId' => $this->whereOrgId));
$query = $this->db->get($this->tableName);
if ($query->num_rows() > 0) {
$result = $query->row_array();
$real_id = $result['_id']->{'$id'};
} else {
$new_id = $this->plusCreate($input);
$real_id = $new_id->{'$id'};
}
return $real_id;
}