本文整理汇总了PHP中Track::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Track::insert方法的具体用法?PHP Track::insert怎么用?PHP Track::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Track
的用法示例。
在下文中一共展示了Track::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFiles
/**
* Scan the specified folder and subfolders, insert in the library the files found.
*
* @param string $folder Root folder to scan
*
* @return array Tracks inserted
*/
public function addFiles($folder)
{
require_once $_SERVER['DOCUMENT_ROOT'] . '/server/lib/Artist.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/server/lib/Album.php';
$result = array();
$this->scanFolders($folder, $this->folders);
foreach ($this->files as $file) {
//reset timeout for 20 seconds before processing each file
set_time_limit(20);
$track = new Track();
$track->file = $file;
$trackInfo = $track->readId3();
if (key_exists('comments_html', $trackInfo)) {
//ID3 has been found, we can use it
if (key_exists('title', $trackInfo['comments_html'])) {
$track->title = $trackInfo['comments_html']['title'][0];
}
if (key_exists('album', $trackInfo['comments_html'])) {
$track->albumName = $trackInfo['comments_html']['album'][0];
}
if (key_exists('artist', $trackInfo['comments_html'])) {
$track->artistName = $trackInfo['comments_html']['artist'][0];
}
if (key_exists('track_number', $trackInfo['comments_html'])) {
$track->track = intval($trackInfo['comments_html']['track_number'][0]);
}
if (key_exists('year', $trackInfo['comments_html'])) {
$track->year = intval($trackInfo['comments_html']['year'][0]);
}
if (key_exists('audio', $trackInfo) && key_exists('bitrate_mode', $trackInfo['audio'])) {
$track->mode = $trackInfo['audio']['bitrate_mode'];
}
if (key_exists('audio', $trackInfo) && key_exists('bitrate', $trackInfo['audio'])) {
$track->bitrate = intval($trackInfo['audio']['bitrate']);
}
if (key_exists('playtime_seconds', $trackInfo)) {
$track->time = intval($trackInfo['playtime_seconds']);
}
if (key_exists('filesize', $trackInfo)) {
$track->size = intval($trackInfo['filesize']);
}
}
if (!isset($track->title, $track->albumName, $track->artistName)) {
//We use the filesystem pattern /path/artistName/albumName/title.ext
$elements = explode('/', $file);
$title = str_replace('-', ' ', str_replace('_', ' ', end($elements)));
$albumName = str_replace('-', ' ', str_replace('_', ' ', prev($elements)));
$artistName = str_replace('-', ' ', str_replace('_', ' ', prev($elements)));
if (!isset($track->title)) {
$track->title = $title;
}
if (!isset($track->albumName)) {
$track->albumName = $albumName;
}
if (!isset($track->artistName)) {
$track->artistName = $artistName;
}
}
//insert/update artist
$artist = new Artist();
$track->artist = $artist->insertIfRequired($track->artistName, null);
//insert/update album
$album = new Album();
$track->album = $album->insertIfRequired($track->albumName, null, $track->artist);
//insert track
if ($track->insert()) {
//add to the returned array
array_push($result, $track->structureData($track));
}
}
//return inserted files
return $result;
}
示例2: connectToEncryptedMySQL
<?php
require_once "/etc/apache2/capstone-mysql/encrypted-config.php";
require_once "your-class-file.php";
$pdo = connectToEncryptedMySQL("/etc/apache2/data-design/jchavez790");
///now produce nomally
$track = new Track(null, 1, "this is form PHP");
$track->insert($pdo);
$track->setTrackContent("now I changed the message");
$track->update($pdo);
$track->delete($pdo);