librefm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Librefm-commits] [1499] convert everything in gnukebox to adodb


From: Clint Adams
Subject: [Librefm-commits] [1499] convert everything in gnukebox to adodb
Date: Tue, 12 May 2009 00:17:33 +0000

Revision: 1499
          http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1499
Author:   clint
Date:     2009-05-12 00:17:32 +0000 (Tue, 12 May 2009)
Log Message:
-----------
convert everything in gnukebox to adodb

Modified Paths:
--------------
    trunk/gnukebox/fix-album-art.php
    trunk/gnukebox/musicbrainz.php

Modified: trunk/gnukebox/fix-album-art.php
===================================================================
--- trunk/gnukebox/fix-album-art.php    2009-05-11 23:36:42 UTC (rev 1498)
+++ trunk/gnukebox/fix-album-art.php    2009-05-12 00:17:32 UTC (rev 1499)
@@ -24,29 +24,26 @@
 
 
 header('Content-type: text/html; charset=utf-8');
-require_once('database.php');
+require_once('database2.php');
 
-  $res = $mdb2->query("SELECT name, artist_name, image, artwork_license FROM 
Album WHERE artwork_license IS NULL LIMIT 5000");
+       $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+       $res = $adodb->GetAll("SELECT name, artist_name, image, artwork_license 
FROM Album WHERE artwork_license IS NULL LIMIT 5000");
 
-                       if(PEAR::isError($res)) {
-                               die($res->getMessage());
-                       }
-                       while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
-                       echo "<img width=50 src=" . 
go_get_album_art($row['artist_name'], $row['name']) ." />&nbsp;";
+               if(!$res) {
+                       die("sql error");
+               }
+               foreach($res as &$row) {
+               echo "<img width=50 src=" . 
go_get_album_art($row['artist_name'], $row['name']) ." />&nbsp;";
 
+               sleep (3);
+               for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
 
-                           sleep (3);
-                          for ($i = 0; $i < ob_get_level(); $i++) { 
ob_end_flush(); }
-    ob_implicit_flush(1)  ;
+               ob_implicit_flush(1)  ;
+               }
+               echo "</ol>";
 
-
-                       
-
-                       }
-                        echo "</ol>";
-
        function go_get_album_art($artist, $album){
-               global $mdb2;
+               global $adodb;
 
   $Access_Key_ID = "1EST86JB355JBS3DFE82"; // this is mattl's personal key :)
 
@@ -71,16 +68,16 @@
 $image = $aws_xml->Items->Item->MediumImage->URL;
        
        if (!$image) { $image = "/i/qm50.png"; $license="librefm";}
-       
+
        if ($image) {
 
         
           if ($license == "") { $license = "amazon"; }
 
-         $license = $mdb2->quote($license);
-         $image = $mdb2->quote($image);
-         $album = $mdb2->quote($album);
-         $artist = $mdb2->quote($artist);
+         $license = $adodb->qstr($license);
+         $image = $adodb->qstr($image);
+         $album = $adodb->qstr($album);
+         $artist = $adodb->qstr($artist);
 
                  $sql = ("UPDATE Album SET image = " 
 
@@ -92,10 +89,10 @@
                         . ($artist) . " AND name = "
                                      . ($album));
 
-                 $res = $mdb2->query($sql);
+                 $res = $adodb->Execute($sql);
 
-               if(PEAR::isError($res)) {
-                 die("FAILED " . $res->getMessage() . " query was :" . $sql);
+               if(!$res) {
+                 die("FAILED query was :" . $sql);
                }
 
        return $image;

Modified: trunk/gnukebox/musicbrainz.php
===================================================================
--- trunk/gnukebox/musicbrainz.php      2009-05-11 23:36:42 UTC (rev 1498)
+++ trunk/gnukebox/musicbrainz.php      2009-05-12 00:17:32 UTC (rev 1499)
@@ -24,19 +24,19 @@
 
 
 header('Content-type: text/html; charset=utf-8');
-require_once('database.php');
+require_once('database2.php');
 require_once('utils/human-time.php');
 
-$res = $mdb2->query("SELECT artist, track from scrobbles where Album is null 
LIMIT 20;");
+$adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+$res = $adodb->GetAll("SELECT artist, track from scrobbles where Album is null 
LIMIT 20;");
 
      echo "<ul>";
 
-                       if(PEAR::isError($res)) {
-                               die($res->getMessage());
+                       if(!$res) {
+                               die("sql error");
                        }
-                       while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
+                       foreach($res as &$row) {
 
-
                        echo "<li>" . $row['artist'] . "&mdash;" . 
$row['track'] . "</li>";
 
                        echo "Finding album...";
@@ -46,7 +46,6 @@
                           for ($i = 0; $i < ob_get_level(); $i++) { 
ob_end_flush(); }
     ob_implicit_flush(1)  ;
 
-
                        }
                        
 
@@ -68,39 +67,34 @@
 
 function ScrobbleLookup($artist, $track){
 
-                    global $mdb2;
+                    global $adodb;
 
-                       $sql = "SELECT album from scrobbles where artist = " . 
$mdb2->quote($artist) . " and track = " . $mdb2->quote($track) . " LIMIT 1;";
+                       $sql = "SELECT album from scrobbles where artist = " . 
$adodb->qstr($artist) . " and track = " . $adodb->qstr($track) . " LIMIT 1;";
 
-                       $resAlbum = $mdb2->query($sql);
+                       $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+                       $album = $adodb->GetOne($sql);
 
-                       if(PEAR::isError($resAlbum)) {
-                            die($resAlbum->getMessage());
+                       if(!$album) {
+                            die("sql error");
                         }
 
-                       $albumData = $resAlbum->fetchRow(MDB2_FETCHMODE_ASSOC);
-
-                       return $albumData['album'];
-
+                       return $album;
 }
 
 function BrainzLookup($artist, $track){
 
-                    global $mdb2;
+                    global $adodb;
 
-                       $sql = "select a.name as artist,l.name as album, t.name 
as track,t.gid as mbid from brainz.track t left join brainz.artist a on 
t.artist=a.id left join brainz.albumjoin j on j.track=t.id left join 
brainz.album l on l.id=j.album  where lower(t.name)=" . 
$mdb2->quote(mb_strtolower($track, "UTF-8")) . " and lower(a.name)=" . 
$mdb2->quote(mb_strtolower($artist, "UTF-8")) . " LIMIT 1;";
+                       $sql = "select a.name as artist,l.name as album, t.name 
as track,t.gid as mbid from brainz.track t left join brainz.artist a on 
t.artist=a.id left join brainz.albumjoin j on j.track=t.id left join 
brainz.album l on l.id=j.album  where lower(t.name)=" . 
$adodb->qstr(mb_strtolower($track, "UTF-8")) . " and lower(a.name)=" . 
$adodb->qstr(mb_strtolower($artist, "UTF-8")) . " LIMIT 1;";
                        
-                       $resBrainz = $mdb2->query($sql);
+                       $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+                       $albumData = $adodb->GetRow($sql);
 
-                       if(PEAR::isError($resBrainz)) {
-                            die($resBrainz->getMessage());
+                       if(!$albumData)) {
+                            die("sql error");
                         }
 
-                       $albumData = $resBrainz->fetchRow(MDB2_FETCHMODE_ASSOC);
-
                        return $albumData['album'];
-
 }
-
-               ?>
+?>
                </ul>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]