Пример #1
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new OnyokuDB();
     }
     return self::$instance;
 }
Пример #2
0
        }
        if ($this->name == '') {
            $this->name = '%';
        }
        $this->pos = 0;
        $this->num = 0;
    }
}
// main
$searcher = new Searcher();
$input = new Input();
$output = null;
$count = 0;
try {
    $searcher->setInput($input);
    $db = OnyokuDB::getInstance();
    if ($count = $searcher->count($db)) {
        // ヒットした件数
        $searcher->search($db);
    }
    $output = $searcher->export();
} catch (Exception $e) {
    $error_message = $e->getMessage();
}
$result['results'] = $count;
if ($output) {
    $tmp = json_decode($output, true);
    for ($i = 0; $i < $count; $i++) {
        $a['name'] = $tmp['data'][$i][0];
        if ($input->mode == 'artist' || $input->mode == 'label') {
            $a['kana'] = $tmp['data'][$i][1];
Пример #3
0
function register_music($input)
{
    $db = OnyokuDB::getInstance();
    $sql = 'INSERT INTO music' . ' (title)' . ' VALUES($1)' . ' RETURNING no';
    foreach ($input->music as $music) {
        if ($music->id) {
            $id_list[] = $music->id;
        } else {
            $res = $db->query($sql, array($music->title));
            $row = $res->fetchArray();
            $id_list[] = $row['no'];
        }
    }
    return $id_list;
}