Example #1
0
	/**
	* Find a list of keys by pattern
	*
	* @param string $pattern Must be redis-like, see http://code.google.com/p/redis/wiki/KeysCommand - be careful when using this with the mysql backend as using the [character] specifier will trigger a REGEXP match which will be largely unquoted.
	* @return array
	* @throws Interspire_KeyStore_Exception
	*/
	public function keys($pattern)
	{
		$pattern = $this->redisPatternToMysql($pattern);

		if ($pattern) {
			$pattern = $this->db->Query("SELECT `key` FROM `[|PREFIX|]keystore` WHERE `key` " . $pattern);
		}
		else
		{
			$pattern = $this->db->Query("SELECT `key` FROM `[|PREFIX|]keystore`");
		}

		if ($pattern === false) {
			throw new Interspire_KeyStore_Exception($this->db->GetErrorMsg());
		}

		$return = array();
		while ($row = $this->db->Fetch($pattern))
		{
			$return[] = $row['key'];
		}
		return $return;
	}