afriend wrote: > > I'm working on the DynamicPlaylist integration part. And it seems I have > a sql problem. I've successfully managed to rebuild a no-parameter > playlist. But I have some other PLs with temporary tables. I've been > using them for a long time with DynamicPlaylist (via custom SQLplaylist > definitions). But they don't seem to work directly in DPL. Is it > possible that DPL has a problem with temporary tables? Or that > SQLplaylist does some translating I'm missing? Here's a simplified > version with one parameter that returns zero tracks: > > > Code: -------------------- > > $sql = "DROP TABLE IF EXISTS randomweightedratingshigh; > DROP TABLE IF EXISTS randomweightedratingslow; > DROP TABLE IF EXISTS randomweightedratingscombined; > > create temporary table randomweightedratingslow as select tracks.url as url from tracks > join tracks_persistent on > tracks.url=tracks_persistent.url and tracks_persistent.rating <= 49 > limit 60; > > create temporary table randomweightedratingshigh as select tracks.url as url from tracks > join tracks_persistent on > tracks.url=tracks_persistent.url and tracks_persistent.rating > 49 > limit 40; > > create temporary table randomweightedratingscombined as > SELECT * FROM randomweightedratingslow > UNION > SELECT * from randomweightedratingshigh; > > SELECT * from randomweightedratingscombined > ORDER BY random() > limit 20; > > DROP TABLE randomweightedratingshigh; > DROP TABLE randomweightedratingslow; > DROP TABLE randomweightedratingscombined; > "; > -------------------- > > > > It doesn't seem to work in Database Query either. Seems only > SQLplaylist can work with this. Any idea why?
How do you integrate ? I you integrate by implementing getNextDynamicPlayListTracks I guess you are aware that you need to return an array of Slim::Schema::Track objects and not the string with the sql statement. You need to execute the sql yourself and execute each sql statement separately, you can probably steal some code from SQL Playlist plugin function executeSQLForPlaylist: https://github.com/erland/lms-sqlplaylist/blob/5955592540b5c157518edf61a731b5ca484c8813/src/Plugin.pm#L1052 It splits the statement string into separate statements, one per row, and execute the statements and lookup Slim::Schema::Track objects by calling the getTracksForResult function also included in SQL Playlist code. You can probably remove a large part of the code since you probably dont need to cover all variants SQL Playlist supports. If you dont want to execute the sql yourself you should instead integrate with SQL Playlist plugin. I think SQL playlist separate statements by new line character so you cant write a statement on multiple rows as you did in your forum post. The free form query in Database Query only supports a single statement if I remember correctly so thats probably the reason that doesn't work. Erland Isaksson ('My homepage' (http://erland.isaksson.info)) Developer of 'many plugins/applets' (https://wiki.slimdevices.com/index.php/User_Erland.html) *Starting with LMS 8.0 I no longer support my plugins/applets* ('see here for more information' (https://forums.slimdevices.com/showthread.php?49483-Announce-New-versions-of-erlands-plugins&p=998836&viewfull=1#post998836) ) ------------------------------------------------------------------------ erland's Profile: http://forums.slimdevices.com/member.php?userid=3124 View this thread: http://forums.slimdevices.com/showthread.php?t=113344
_______________________________________________ plugins mailing list plugins@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/plugins