there you go (script in attachement). Remove the txt extension and execute on the command line with php. It will generate a txt file in the directory where you put and execute the script.
The SQL request also gets the play count and the date of import if needed.

Cheers,

. e

On 12/13/2016 07:51 AM, Morten Krarup Nielsen wrote:
Hi.

I need to output a text file that lists all my music from the SQL
database, can anyone help me?

It should include the following:

1. cart#
2. Artist name
3. Title name
4. Album name
5. Scheduler code

encoding should be UTF-8

-          each line contains of one entry for one file

-          each line consists of fields which are TAB separated (or
any other seperator)

-          each line is separated by LF or CRLF

Thank you!

Kind regards,

Morten
_______________________________________________
Rivendell-dev mailing list
Rivendell-dev@lists.rivendellaudio.org
http://caspian.paravelsystems.com/mailman/listinfo/rivendell-dev

<?php error_reporting(E_ALL);
  // lists all carts in a group to a text file
        $query= "
        SELECT CART.*, CUTS.PLAY_COUNTER, CUTS.ORIGIN_DATETIME
        FROM CART
        INNER JOIN CUTS ON CART.NUMBER = CUTS.CART_NUMBER
        WHERE CART.GROUP_NAME='MUSIC'
        ";
        
        $db = mysql_connect("127.0.0.1", "user", "password")or die('connexion 
échouée : ' . mysql_error());
        mysql_select_db("Rivendell") or die(mysql_error());
        $results = mysql_query($query) or die(mysql_error());
        mysql_close($db);
        echo 'Carts returned : '.mysql_num_rows($results);
        
        $file = "music_list.csv";

        while ($r = mysql_fetch_array($results))
                {
                        $write = 
$r['NUMBER']."\t".$r['ARTIST']."\t".$r['TITLE']."\t".$r['ALBUM']."\t".$r['SCHED_CODES']."\r\n";
                        file_put_contents($file, utf8_encode($write), 
FILE_APPEND | LOCK_EX);
                }

// EOF
_______________________________________________
Rivendell-dev mailing list
Rivendell-dev@lists.rivendellaudio.org
http://caspian.paravelsystems.com/mailman/listinfo/rivendell-dev

Reply via email to