mysql.prg
- Code: Select all Expand view
- #include "FiveTouch.ch"
function Main()
local oDlg := QDialog()
local oLayout := QVBoxLayout()
local oBrw := QTableView( oDlg )
local aRows := GetData()
local n, m, aKeys := hb_HKeys( aRows[ 1 ] )
local oModel := QStandardItemModel( Len( aRows ), Len( aKeys ), oDlg )
for n = 1 to Len( aKeys )
oModel:SetHorizontalHeaderItem( n - 1, QStandardItem( aKeys[ n ] ) )
next
for n = 1 to Len( aRows )
for m = 1 to Len( aKeys )
oModel:SetItem( n - 1,m - 1, QStandardItem( hb_HGet( aRows[ n ], aKeys[ m ] ) ) )
next
next
oDlg:SetLayout( oLayout )
oBrw:SetModel( oModel )
oLayout:AddWidget( oBrw )
oDlg:SetWindowTitle( "A browse" )
oDlg:Resize( 500, 400 )
oDlg:Center()
oDlg:Exec()
return nil
function GetData()
LOCAL oClient := TIpClientHttp():New( "http://www.fivetechsoft.com/webservice.php" )
LOCAL hRequest := {=>}
LOCAl hParams := {=>}
LOCAl cJson
if oClient:Open()
hParams[ "database" ] = "fivetech_webservice"
hParams[ "username" ] = "fivetech_test"
hParams[ "password" ] = "webservice"
hParams[ "sql" ] = "SELECT * FROM `users`"
oClient:oUrl:AddGetForm( hParams )
cJson = oClient:ReadAll()
hb_jsonDecode( cJson, @hRequest )
oClient:Close()
endif
return hRequest[ "result" ]