[Gambas-user] collection of collection problem

Fabien Bodard gambas.fr at ...626...
Fri Mar 24 15:52:00 CET 2017


Sorry but despite your article ... that i've read all the content I
can't understand your need ... And I'm sur there is a way to do it
simpler with Gambas.


What I've understand :

' Gambas module file

Public Sub Main()

  Dim hCon As New Connection(Subst("mysql://&1@&2:3306/&3",
$servername, $username, $dbname))
  Dim $orders As String = "SELECT * FROM almorder WHERE cod_order = &1"
  Dim $ordersproducts As String = "SELECT * FROM alorderproducts WHERE
cod_order = &1"

  Dim CurrentOrder As String = "001"
  Dim cOrder as Collection

  hCon.Password = $password
  hCon.Open

'refer to the first line of the returned collection to get a single collection
  cOrder = ResultToCollectionArray(db.Exec($orders, CurrentOrder))[0]

  cOrder!cod_contenido =
ResultToCollectionArray(db.Exec($ordersproducts, CurrentOrder)


  'So we can read :

  Print cOrder!cod_contenido[2]!can_product

  'that refer To the Line 2 Of the array contained In column
"cod_contenido" Of cOrder....column "can_product"

End


Private Function ResultToCollectionArray(hResult As Result) As Collection[]
  Dim a As New String[]
  Dim f As ResultField
  Dim C As Collection
  Dim aC As New Collection[]
  Dim s As String

  If Not hResult And If Not hResult.Available Then Return

  For Each f In ResultField
    a.Add(f.Name)
  Next

  For Each hResult
    c = New Collection
    For Each s In a
      c[s] = hResult[s]
    Next
    aC.Add(c)
  Next
  Return aC
End




2017-03-23 19:49 GMT+01:00 PICCORO McKAY Lenz <mckaygerhard at ...626...>:
> well, this its a funny case, the code of the firts mail are the correct way
> , but one line are incorrect.. that's why not working
>
> in any case i put how must be done in this article:
> http://qgqlochekone.blogspot.com/2017/03/gambas3-collections-of-collections-as.html
>
> my error, a typo in the line:
>   filasdet.Add(columnas, rsetd!cod_contenido)
> must be:
>   filasdet.Add(columnasdet, rsetd!cod_contenido)
>
> and in the article i try to explain why i done that
>
>
> Lenz McKAY Gerardo (PICCORO)
> http://qgqlochekone.blogspot.com
>
> 2017-03-23 8:25 GMT-04:00 Fabien Bodard <gambas.fr at ...626...>:
>
>> Please tel me how you make the array in php. And in java. Or give me a
>> link.
>> I'll try to answer this evening
>> For me you need arrays of collections.
>> Array are the lines storage and collection the line itself.
>>
>> Colresult[2]!storage[3]!article
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user



-- 
Fabien Bodard




More information about the User mailing list