public function generatePermalink() { $permalink = SimpleRandom::string(16); while ($this->count(Query::condition()->andWhere('permalink_post', Query::EQUAL, $permalink))) { $permalink = SimpleRandom::string(16); } return $permalink; }
public function create($pIdUser) { $perma = SimpleRandom::string(8); while ($this->count(Query::condition()->andWhere('permalink_list', Query::EQUAL, $perma))) { $perma = SimpleRandom::string(8); } $name = self::DEFAULT_NAME; $current_count = $this->count(Query::condition()->andWhere('name_list', Query::LIKE, self::DEFAULT_NAME . '%')->andWhere('id_user', Query::EQUAL, $pIdUser)); if ($current_count > 0) { $name .= " (" . ($current_count + 1) . ")"; } $this->insert(array('name_list' => $name, 'permalink_list' => $perma, 'public_list' => 0, 'share_list' => 1, 'id_user' => $pIdUser, 'creation_date_list' => 'NOW()')); return $perma; }
/** * Constructor * @param int $pLength * @param string $pName */ public function __construct($pLength, $pName) { $this->length = $pLength; $this->name = $pName; $this->value = SimpleRandom::string($this->length); }