本文整理汇总了PHP中Dba::num_rows方法的典型用法代码示例。如果您正苦于以下问题:PHP Dba::num_rows方法的具体用法?PHP Dba::num_rows怎么用?PHP Dba::num_rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dba
的用法示例。
在下文中一共展示了Dba::num_rows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_username
/**
* check_username
* This checks to make sure the username passed doesn't already
* exist in this instance of ampache
*/
public static function check_username($username)
{
$username = Dba::escape($username);
$sql = "SELECT `id` FROM `user` WHERE `username`='{$username}'";
$db_results = Dba::read($sql);
if (Dba::num_rows($db_results)) {
return false;
}
return true;
}
示例2: is_installed
/**
* is_installed
* This returns true or false if vlc controller is installed
*/
public function is_installed()
{
$sql = "DESCRIBE `localplay_vlc`";
$db_results = Dba::query($sql);
return Dba::num_rows($db_results);
}
示例3: import_playlist
/**
* playlist_import
* Attempts to create a Public Playlist based on the playlist file
*/
public static function import_playlist($playlist)
{
$data = file_get_contents($playlist);
if (substr($playlist, -3, 3) == 'm3u') {
$files = self::parse_m3u($data);
} elseif (substr($playlist, -3, 3) == 'pls') {
$files = self::parse_pls($data);
} elseif (substr($playlist, -3, 3) == 'asx') {
$files = self::parse_asx($data);
} elseif (substr($playlist, -4, 4) == 'xspf') {
$files = self::parse_xspf($data);
}
$songs = array();
$pinfo = pathinfo($playlist);
if (isset($files)) {
foreach ($files as $file) {
$file = trim($file);
// Check to see if it's a url from this ampache instance
if (substr($file, 0, strlen(AmpConfig::get('web_path'))) == AmpConfig::get('web_path')) {
$data = Stream_URL::parse($file);
$sql = 'SELECT COUNT(*) FROM `song` WHERE `id` = ?';
$db_results = Dba::read($sql, array($data['id']));
if (Dba::num_rows($db_results)) {
$songs[] = $data['id'];
}
} else {
// Remove file:// prefix if any
if (strpos($file, "file://") !== false) {
$file = urldecode(substr($file, 7));
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
// Removing starting / on Windows OS.
if (substr($file, 0, 1) == '/') {
$file = substr($file, 1);
}
// Restore real directory separator
$file = str_replace("/", DIRECTORY_SEPARATOR, $file);
}
}
debug_event('catalog', 'Add file ' . $file . ' to playlist.', '5');
// First, try to found the file as absolute path
$sql = "SELECT `id` FROM `song` WHERE `file` = ?";
$db_results = Dba::read($sql, array($file));
$results = Dba::fetch_assoc($db_results);
if (isset($results['id'])) {
$songs[] = $results['id'];
} else {
// Not found in absolute path, create it from relative path
$file = $pinfo['dirname'] . DIRECTORY_SEPARATOR . $file;
// Normalize the file path. realpath requires the files to exists.
$file = realpath($file);
if ($file) {
$sql = "SELECT `id` FROM `song` WHERE `file` = ?";
$db_results = Dba::read($sql, array($file));
$results = Dba::fetch_assoc($db_results);
if (isset($results['id'])) {
$songs[] = $results['id'];
}
}
}
}
// if it's a file
}
}
debug_event('import_playlist', "Parsed " . $playlist . ", found " . count($songs) . " songs", 5);
if (count($songs)) {
$name = $pinfo['extension'] . " - " . $pinfo['filename'];
$playlist_id = Playlist::create($name, 'public');
if (!$playlist_id) {
return array('success' => false, 'error' => T_('Failed to create playlist.'));
}
/* Recreate the Playlist */
$playlist = new Playlist($playlist_id);
$playlist->add_songs($songs, true);
return array('success' => true, 'id' => $playlist_id, 'count' => count($songs));
}
return array('success' => false, 'error' => T_('No valid songs found in playlist file.'));
}
示例4: is_installed
/**
* is_installed
* This returns true or false if vlc controller is installed
*/
public function is_installed()
{
$sql = "SHOW TABLES LIKE 'localplay_vlc'";
$db_results = Dba::query($sql);
return Dba::num_rows($db_results) > 0;
}
示例5: is_installed
/**
* is_installed
* This returns true or false if this controller is installed
*/
public function is_installed()
{
$sql = "DESCRIBE `localplay_httpq`";
$db_results = Dba::read($sql);
return Dba::num_rows($db_results);
}
示例6: check_lock_media
/**
* check_lock_media
*
* This checks to see if the media is already being played.
*/
public static function check_lock_media($media_id, $type)
{
$sql = 'SELECT `object_id` FROM `now_playing` WHERE ' . '`object_id` = ? AND `object_type` = ?';
$db_results = Dba::read($sql, array($media_id, $type));
if (Dba::num_rows($db_results)) {
debug_event('Stream', 'Unable to play media currently locked by another user', 3);
return false;
}
return true;
}
示例7: check_database_inserted
/**
* check_database_inserted
*
* Checks to make sure that you have inserted the database
* and that the user you are using has access to it.
*/
public static function check_database_inserted()
{
$sql = "DESCRIBE session";
$db_results = Dba::read($sql);
if (!$db_results) {
return false;
}
// Make sure the table is there
if (Dba::num_rows($db_results) < 1) {
return false;
}
return true;
}
示例8: create_type
/**
* create_type
*
* This creates a new catalog type entry for a catalog
* It checks to make sure its parameters is not already used before creating
* the catalog.
*/
public static function create_type($catalog_id, $data)
{
// TODO: This Method should be required / provided by parent
$beetsdb = $data['beetsdb'];
if (preg_match('/^[\\s]+$/', $beetsdb)) {
Error::add('general', T_('Error: Beets selected, but no Beets DB File provided'));
return false;
}
// Make sure this uri isn't already in use by an existing catalog
$selectSql = 'SELECT `id` FROM `catalog_beets` WHERE `beetsdb` = ?';
$db_results = Dba::read($selectSql, array($beetsdb));
if (Dba::num_rows($db_results)) {
debug_event('catalog', 'Cannot add catalog with duplicate uri ' . $beetsdb, 1);
Error::add('general', sprintf(T_('Error: Catalog with %s already exists'), $beetsdb));
return false;
}
$insertSql = 'INSERT INTO `catalog_beets` (`beetsdb`, `catalog_id`) VALUES (?, ?)';
Dba::write($insertSql, array($beetsdb, $catalog_id));
return true;
}
示例9: create_type
/**
* create_type
*
* This creates a new catalog type entry for a catalog
* It checks to make sure its parameters is not already used before creating
* the catalog.
*/
public static function create_type($catalog_id, $data)
{
$uri = $data['uri'];
$username = $data['username'];
$password = $data['password'];
if (substr($uri, 0, 7) != 'http://' && substr($uri, 0, 8) != 'https://') {
Error::add('general', T_('Error: Remote selected, but path is not a URL'));
return false;
}
if (!strlen($username) or !strlen($password)) {
Error::add('general', T_('Error: Username and Password Required for Remote Catalogs'));
return false;
}
$password = hash('sha256', $password);
// Make sure this uri isn't already in use by an existing catalog
$sql = 'SELECT `id` FROM `catalog_remote` WHERE `uri` = ?';
$db_results = Dba::read($sql, array($uri));
if (Dba::num_rows($db_results)) {
debug_event('catalog', 'Cannot add catalog with duplicate uri ' . $uri, 1);
Error::add('general', sprintf(T_('Error: Catalog with %s already exists'), $uri));
return false;
}
$sql = 'INSERT INTO `catalog_remote` (`uri`, `username`, `password`, `catalog_id`) VALUES (?, ?, ?, ?)';
Dba::write($sql, array($uri, $username, $password, $catalog_id));
return true;
}
示例10: check_session
private static function check_session($code)
{
// Purge expired sessions
$sql = "DELETE FROM `daap_session` WHERE `creationdate` < ?";
Dba::write($sql, array(time() - 1800));
self::check_auth($code);
if (!isset($_GET['session-id'])) {
debug_event('daap', 'Missing session id.', '');
} else {
$sql = "SELECT * FROM `daap_session` WHERE `id` = ?";
$db_results = Dba::read($sql, array($_GET['session-id']));
if (Dba::num_rows($db_results) == 0) {
debug_event('daap', 'Unknown session id `' . $_GET['session-id'] . '`.', '4');
}
}
}
示例11: create_type
/**
* create_type
*
* This creates a new catalog type entry for a catalog
* It checks to make sure its parameters is not already used before creating
* the catalog.
*/
public static function create_type($catalog_id, $data)
{
// TODO: This Method should be required / provided by parent
$uri = $data['uri'];
if (substr($uri, 0, 7) != 'http://' && substr($uri, 0, 8) != 'https://') {
AmpError::add('general', T_('Error: Beets selected, but path is not a URL'));
return false;
}
// Make sure this uri isn't already in use by an existing catalog
$selectSql = 'SELECT `id` FROM `catalog_beets` WHERE `uri` = ?';
$db_results = Dba::read($selectSql, array($uri));
if (Dba::num_rows($db_results)) {
debug_event('catalog', 'Cannot add catalog with duplicate uri ' . $uri, 1);
AmpError::add('general', sprintf(T_('Error: Catalog with %s already exists'), $uri));
return false;
}
$insertSql = 'INSERT INTO `catalog_beetsremote` (`uri`, `catalog_id`) VALUES (?, ?)';
Dba::write($insertSql, array($uri, $catalog_id));
return true;
}
示例12: create_type
/**
* create_type
*
* This creates a new catalog type entry for a catalog
* It checks to make sure its parameters is not already used before creating
* the catalog.
*/
public static function create_type($catalog_id, $data)
{
$apikey = $data['apikey'];
$secret = $data['secret'];
$path = $data['path'];
$getchunk = $data['getchunk'];
if (!strlen($apikey) or !strlen($secret)) {
Error::add('general', T_('Error: API Key and Secret Required for Dropbox Catalogs'));
return false;
}
$pathError = Dropbox\Path::findError($path);
if ($pathError !== null) {
Error::add('general', T_('Invalid <dropbox-path>: ' . $pathError));
return false;
}
// Make sure this app isn't already in use by an existing catalog
$sql = 'SELECT `id` FROM `catalog_dropbox` WHERE `apikey` = ?';
$db_results = Dba::read($sql, array($apikey));
if (Dba::num_rows($db_results)) {
debug_event('catalog', 'Cannot add catalog with duplicate key ' . $apikey, 1);
Error::add('general', sprintf(T_('Error: Catalog with %s already exists'), $apikey));
return false;
}
$sql = 'INSERT INTO `catalog_dropbox` (`apikey`, `secret`, `path`, `getchunk`, `catalog_id`) VALUES (?, ?, ?, ?, ?)';
Dba::write($sql, array($apikey, $secret, $path, $getchunk ? 1 : 0, $catalog_id));
return true;
}
示例13: has_vote
/**
* has_vote
* This checks to see if the current user has already voted on this object
*/
public function has_vote($object_id, $type = 'song')
{
$tmp_id = Dba::escape($this->tmp_playlist);
$object_id = Dba::escape($object_id);
$type = Dba::escape($type);
$user_id = Dba::escape($GLOBALS['user']->id);
/* Query vote table */
$sql = 'SELECT `tmp_playlist_data`.`object_id` ' . 'FROM `user_vote` INNER JOIN `tmp_playlist_data` ' . 'ON `tmp_playlist_data`.`id`=`user_vote`.`object_id` ' . "WHERE `user_vote`.`user`='{$user_id}' " . "AND `tmp_playlist_data`.`object_type`='{$type}' " . "AND `tmp_playlist_data`.`object_id`='{$object_id}' " . "AND `tmp_playlist_data`.`tmp_playlist`='{$tmp_id}'";
$db_results = Dba::read($sql);
/* If we find row, they've voted!! */
if (Dba::num_rows($db_results)) {
return true;
}
return false;
}
示例14: exists
/**
* exists
*
* This checks to see if the specified session of the specified type
* exists
* based on the type.
*/
public static function exists($type, $key)
{
// Switch on the type they pass
switch ($type) {
case 'api':
case 'stream':
$sql = 'SELECT * FROM `session` WHERE `id` = ? AND `expire` > ? ' . "AND `type` IN ('api', 'stream')";
$db_results = Dba::read($sql, array($key, time()));
if (Dba::num_rows($db_results)) {
return true;
}
break;
case 'interface':
$sql = 'SELECT * FROM `session` WHERE `id` = ? AND `expire` > ?';
if (AmpConfig::get('use_auth')) {
// Build a list of enabled authentication types
$types = AmpConfig::get('auth_methods');
$enabled_types = implode("','", $types);
$sql .= " AND `type` IN('{$enabled_types}')";
}
$db_results = Dba::read($sql, array($key, time()));
if (Dba::num_rows($db_results)) {
return true;
}
break;
default:
return false;
}
// Default to false
return false;
}
示例15: create_type
/**
* create_type
*
* This creates a new catalog type entry for a catalog
* It checks to make sure its parameters is not already used before creating
* the catalog.
*/
public static function create_type($catalog_id, $data)
{
// Clean up the path just in case
$path = rtrim(rtrim(trim($data['path']), '/'), '\\');
if (!strlen($path)) {
AmpError::add('general', T_('Error: Path not specified'));
return false;
}
// Make sure that there isn't a catalog with a directory above this one
if (self::get_from_path($path)) {
AmpError::add('general', T_('Error: Defined Path is inside an existing catalog'));
return false;
}
// Make sure the path is readable/exists
if (!Core::is_readable($path)) {
debug_event('catalog', 'Cannot add catalog at unopenable path ' . $path, 1);
AmpError::add('general', sprintf(T_('Error: %s is not readable or does not exist'), scrub_out($data['path'])));
return false;
}
// Make sure this path isn't already in use by an existing catalog
$sql = 'SELECT `id` FROM `catalog_local` WHERE `path` = ?';
$db_results = Dba::read($sql, array($path));
if (Dba::num_rows($db_results)) {
debug_event('catalog', 'Cannot add catalog with duplicate path ' . $path, 1);
AmpError::add('general', sprintf(T_('Error: Catalog with %s already exists'), $path));
return false;
}
$sql = 'INSERT INTO `catalog_local` (`path`, `catalog_id`) VALUES (?, ?)';
Dba::write($sql, array($path, $catalog_id));
return true;
}