×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    13

    Unhappy Need solution for creating item (related: qml, sqlite) ?

    Hi,

    I'm new in qml programming.
    I read a Storage.js file code, its code wants to create a table name "playlist" and you can setPlaylist (to set data table) or getPlaylist (to get data table).
    As I understand, pl is an item (playlist) which have many small items (song), each song have 4 property: source, title, arstist and time.
    It's ok when I make a song item, but I don't know how to make a playlist item which don't have fixed number of songs.

    Thanks.

    //Storage.js
    function setPlaylist(pl){
    var db = openDatabase()
    var res = ""
    db.transaction(
    function(tx){
    var rs = tx.executeSql("DELETE FROM playlist;")
    var count = 0
    for(var i=0;i<pl.count;i++){
    rs = tx.executeSql("INSERT INTO playlist VALUES (?,?,?,?);"[pl.item(i).source, pl.item(i).title, pl.item(i).artist, pl.item(i).time])
    count += rs.rowsAffected
    }
    if(count>0)
    res = "OK"
    else res = "Error"
    }
    )
    return res
    }

    function getPlaylist(pl){
    var db = openDatabase()
    var res = ""
    db.transaction(
    function(tx){
    var rs = tx.executeSql("SELECT * FROM playlist;")
    if(rs.rows.length>0){
    for(var i = 0;i<rs.rows.length;i++){
    pl.append(
    {"source":rs.rows.item(i).source,"title":rs.rows.item(i).title,"artist":rs.rows.item(i).artist,"time":rs.rows.item(i).time,"selected":false}
    )
    }
    }
    }
    )
    return res
    }
    Last edited by allicius; 2012-04-15 at 06:18.

  2. #2
    Nokia Developer Expert
    Join Date
    Oct 2007
    Posts
    441

    Re: Need solution for creating item (related: qml, sqlite) ?

    Hi

    your code fetches unknown in advance amount of records
    var rs = tx.executeSql("SELECT * FROM playlist;")
    SQL expression execution returns array of records and amount of records is the array size
    rs.rows.length

Similar Threads

  1. Replies: 0
    Last Post: 2011-03-28, 16:46
  2. give me solution related IndexNamesL() function
    By Tanya in forum Symbian User Interface
    Replies: 4
    Last Post: 2007-04-11, 04:58
  3. Problem creating Visual Studio .NET solution
    By miranda2112 in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2005-02-17, 22:56

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×