本文整理汇总了PHP中Dba::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Dba::error方法的具体用法?PHP Dba::error怎么用?PHP Dba::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dba
的用法示例。
在下文中一共展示了Dba::error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install_create_account
/**
* install_create_account
* this creates your initial account and sets up the preferences for the -1 user and you
*/
function install_create_account($username, $password, $password2)
{
if (!strlen($username) or !strlen($password)) {
Error::add('general', T_('No Username/Password specified'));
return false;
}
if ($password !== $password2) {
Error::add('general', T_('Passwords do not match'));
return false;
}
if (!Dba::check_database()) {
Error::add('general', sprintf(T_('Database connection failed: %s'), Dba::error()));
return false;
}
if (!Dba::check_database_inserted()) {
Error::add('general', sprintf(T_('Database select failed: %s'), Dba::error()));
return false;
}
$username = Dba::escape($username);
$password = Dba::escape($password);
$insert_id = User::create($username, 'Administrator', '', '', $password, '100');
if (!$insert_id) {
Error::add('general', sprintf(T_('Administrative user creation failed: %s'), Dba::error()));
return false;
}
// Fix the system users preferences
User::fix_preferences('-1');
return true;
}
示例2: insert
/**
* insert
*
* This inserts the song described by the passed array
* @param array $results
* @return int|boolean
*/
public static function insert(array $results)
{
$catalog = $results['catalog'];
$file = $results['file'];
$title = trim($results['title']) ?: $file;
$artist = $results['artist'];
$album = $results['album'];
$albumartist = $results['albumartist'] ?: $results['band'];
$albumartist = $albumartist ?: null;
$bitrate = $results['bitrate'] ?: 0;
$rate = $results['rate'] ?: 0;
$mode = $results['mode'];
$size = $results['size'] ?: 0;
$time = $results['time'] ?: 0;
$track = $results['track'];
$track_mbid = $results['mb_trackid'] ?: $results['mbid'];
$track_mbid = $track_mbid ?: null;
$album_mbid = $results['mb_albumid'];
$album_mbid_group = $results['mb_albumid_group'];
$artist_mbid = $results['mb_artistid'];
$albumartist_mbid = $results['mb_albumartistid'];
$disk = $results['disk'] ?: 0;
$year = $results['year'] ?: 0;
$comment = $results['comment'];
$tags = $results['genre'];
// multiple genre support makes this an array
$lyrics = $results['lyrics'];
$user_upload = isset($results['user_upload']) ? $results['user_upload'] : null;
$license = isset($results['license']) ? $results['license'] : null;
$composer = isset($results['composer']) ? $results['composer'] : null;
$label = isset($results['publisher']) ? $results['publisher'] : null;
$catalog_number = isset($results['catalog_number']) ? $results['catalog_number'] : null;
$language = isset($results['language']) ? $results['language'] : null;
$channels = $results['channels'] ?: 0;
$release_type = isset($results['release_type']) ? $results['release_type'] : null;
$replaygain_track_gain = isset($results['replaygain_track_gain']) ? $results['replaygain_track_gain'] : null;
$replaygain_track_peak = isset($results['replaygain_track_peak']) ? $results['replaygain_track_peak'] : null;
$replaygain_album_gain = isset($results['replaygain_album_gain']) ? $results['replaygain_album_gain'] : null;
$replaygain_album_peak = isset($results['replaygain_album_peak']) ? $results['replaygain_album_peak'] : null;
$albumartist_id = null;
if (!isset($results['albumartist_id'])) {
if ($albumartist) {
$albumartist_id = Artist::check($albumartist, $albumartist_mbid);
}
} else {
$albumartist_id = intval($results['albumartist_id']);
}
$artist_id = null;
if (!isset($results['artist_id'])) {
$artist_id = Artist::check($artist, $artist_mbid);
} else {
$artist_id = intval($results['artist_id']);
}
$album_id = null;
if (!isset($results['album_id'])) {
$album_id = Album::check($album, $year, $disk, $album_mbid, $album_mbid_group, $albumartist_id, $release_type);
} else {
$album_id = intval($results['album_id']);
}
$sql = 'INSERT INTO `song` (`file`, `catalog`, `album`, `artist`, ' . '`title`, `bitrate`, `rate`, `mode`, `size`, `time`, `track`, ' . '`addition_time`, `year`, `mbid`, `user_upload`, `license`, ' . '`composer`, `channels`) ' . 'VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
$db_results = Dba::write($sql, array($file, $catalog, $album_id, $artist_id, $title, $bitrate, $rate, $mode, $size, $time, $track, time(), $year, $track_mbid, $user_upload, $license, $composer, $channels));
if (!$db_results) {
var_dump(Dba::error());
exit;
debug_event('song', 'Unable to insert ' . $file, 2);
return false;
}
$song_id = Dba::insert_id();
if ($user_upload) {
Useractivity::post_activity($this->id, 'upload', 'song', $song_id);
}
if (is_array($tags)) {
// Allow scripts to populate new tags when injecting user uploads
if (!defined('NO_SESSION')) {
if ($user_upload && !Access::check('interface', 50, $user_upload)) {
$tags = Tag::clean_to_existing($tags);
}
}
foreach ($tags as $tag) {
$tag = trim($tag);
if (!empty($tag)) {
Tag::add('song', $song_id, $tag, false);
Tag::add('album', $album_id, $tag, false);
Tag::add('artist', $artist_id, $tag, false);
}
}
}
$sql = 'INSERT INTO `song_data` (`song_id`, `comment`, `lyrics`, `label`, `language`, `catalog_number`, `replaygain_track_gain`, `replaygain_track_peak`, `replaygain_album_gain`, `replaygain_album_peak`) ' . 'VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
Dba::write($sql, array($song_id, $comment, $lyrics, $label, $language, $catalog_number, $replaygain_track_gain, $replaygain_track_peak, $replaygain_album_gain, $replaygain_album_peak));
return $song_id;
}