Page 1 of 2
Pasar query a un arreglo
Posted: Sat Jun 29, 2019 6:25 pm
by Compuin
Hola foro,
Como puedo leer una tabla mysql y pasar su contenido a un arreglo?
Hay algun ejemplo en Fivewin?
Gracias
Re: Pasar query a un arreglo
Posted: Sun Jun 30, 2019 12:11 am
by joseluisysturiz
Usa oQry:fillarray...es lo mejor y mas rapido, saludos...
Code: Select all | Expand
// FILLARRAY
oQry:FillArray( {| aRow | AAdd( oBrw:aArrayData, { aRow[2], aRow[4] } ) } ) // CON POSICION CAMPO
oBrw:aArrayData := oQry:FillArray( , { "vende_cedula", "vende_apellidos" } ) // CON CAMPOS. PARA LOS xBRW O UN ARRAY
oQry:FillArray( {| aRow | ( AAdd( Array1, cValToChar( aRow[1] ) ) ,; // PARA LOS COMBOBOX CON QRY
AAdd( Array2, aRow[2]) ) }, )
Re: Pasar query a un arreglo
Posted: Sun Jun 30, 2019 1:51 am
by Compuin
joseluisysturiz wrote:Usa oQry:fillarray...es lo mejor y mas rapido, saludos...
Code: Select all | Expand
// FILLARRAY
oQry:FillArray( {| aRow | AAdd( oBrw:aArrayData, { aRow[2], aRow[4] } ) } ) // CON POSICION CAMPO
oBrw:aArrayData := oQry:FillArray( , { "vende_cedula", "vende_apellidos" } ) // CON CAMPOS. PARA LOS xBRW O UN ARRAY
oQry:FillArray( {| aRow | ( AAdd( Array1, cValToChar( aRow[1] ) ) ,; // PARA LOS COMBOBOX CON QRY
AAdd( Array2, aRow[2]) ) }, )
Muchas gracias paisano
Re: Pasar query a un arreglo
Posted: Sun Jun 30, 2019 2:19 am
by joseluisysturiz
Olvide comentarte que esto es usando TDolphin, saludos...
![Shocked :shock:](./images/smilies/icon_eek.gif)
Re: Pasar query a un arreglo
Posted: Sun Jun 30, 2019 2:20 am
by Compuin
joseluisysturiz wrote:Olvide comentarte que esto es usando TDolphin, saludos...
![Shocked :shock:](./images/smilies/icon_eek.gif)
Si, imagino que es TDolphin
Yo uso Eagle1, deberia funcionar ya que solo es el resultado del query
Re: Pasar query a un arreglo
Posted: Sun Jun 30, 2019 3:03 am
by joseluisysturiz
fillarray si no me equivoco, es un methodo de TDolphin, en FWMaria o algo asi nativo de FW se usa algo diferente, aun no he migrado a el nativo de FW, pero para alla voy Dios mediante, tambien puedes hacer un recorrido del qry y usar aadd(array, valores/{valores}), es lo mas clasico, saludos...
![Shocked :shock:](./images/smilies/icon_eek.gif)
Re: Pasar query a un arreglo
Posted: Sun Jun 30, 2019 2:17 pm
by nageswaragunupudi
Native FWH:
Simple and the fastest:
aData := oCn:Execute( cQry )
Example:
Code: Select all | Expand
aStates := oCn:Execute( "select code,name from states" )
Re: Pasar query a un arreglo
Posted: Sun Jun 30, 2019 2:19 pm
by Compuin
nageswaragunupudi wrote:Native FWH:
Simple and the fastest:
aData := oCn:Execute( cQry )
Example:
Code: Select all | Expand
aStates := oCn:Execute( "select code,name from states" )
Thanks Mr Rao
Re: Pasar query a un arreglo
Posted: Sun Jun 30, 2019 2:20 pm
by Compuin
joseluisysturiz wrote:fillarray si no me equivoco, es un methodo de TDolphin, en FWMaria o algo asi nativo de FW se usa algo diferente, aun no he migrado a el nativo de FW, pero para alla voy Dios mediante, tambien puedes hacer un recorrido del qry y usar aadd(array, valores/{valores}), es lo mas clasico, saludos...
![Shocked :shock:](./images/smilies/icon_eek.gif)
Gracias Jose Luis por la aclaratoria
Re: Pasar query a un arreglo
Posted: Sun Jun 30, 2019 4:47 pm
by joseluisysturiz
nageswaragunupudi wrote:Native FWH:
Simple and the fastest:
aData := oCn:Execute( cQry )
Example:
Code: Select all | Expand
aStates := oCn:Execute( "select code,name from states" )
Buen dia Mr. NAO, si ya tengo un queri hecho con fillarray selecciono solo los campos que deseo pasar al array sin necesidad de hacer la consulta al momento, como lo haria con la nativa de FW.? gracias...
![Shocked :shock:](./images/smilies/icon_eek.gif)
Re: Pasar query a un arreglo
Posted: Sun Jun 30, 2019 5:00 pm
by nageswaragunupudi
If you already made a query (we call it RowSet), then you can use method GetRows(), which is similar to FillArray() of Dolphin.
aData := oRs:GetRows( [nRows], [nFromRow], [aFieldNames] )
Example:
Code: Select all | Expand
oRs := oCn:RowSet( "customer" )
aDataFull := oRs:GetRows()
aDataPart := oRs:GetRows( 20, 101, { "first", "city", "salary" } )
But, if you did not read query (rowset) already, we can save lot of time by directly reading the data into an array, instead of first reading into a query and then copying data from query into an array.
This is simple and fast
Code: Select all | Expand
aData := oCn:Execute( "select first, city, salary from customer where id between 101 and 120" )
Re: Pasar query a un arreglo
Posted: Sun Jun 30, 2019 7:27 pm
by joseluisysturiz
nageswaragunupudi wrote:If you already made a query (we call it RowSet), then you can use method GetRows(), which is similar to FillArray() of Dolphin.
aData := oRs:GetRows( [nRows], [nFromRow], [aFieldNames] )
Example:
Code: Select all | Expand
oRs := oCn:RowSet( "customer" )
aDataFull := oRs:GetRows()
aDataPart := oRs:GetRows( 20, 101, { "first", "city", "salary" } )
But, if you did not read query (rowset) already, we can save lot of time by directly reading the data into an array, instead of first reading into a query and then copying data from query into an array.
This is simple and fast
Code: Select all | Expand
aData := oCn:Execute( "select first, city, salary from customer where id between 101 and 120" )
Excelente, veo que se porta igual que fillarray, ahora otra duda...se puede agrgar un valor que no sea de la consulta, como por ejemplo un valor booleano o el valor de una variable.?
ejemplo:
Code: Select all | Expand
aDataPart := oRs:GetRows( 20, 101, { "first", "city", "salary", .f. } )
// Esto seriviria para usar un xbrowse y usar setcheck()
aDataPart := oRs:GetRows( 20, 101, { "first", "city", "salary", nom_var } )
// nom_var seria una VAR externa al query, con fillarray no se como hacerlo, gracias... :shock:
Re: Pasar query a un arreglo
Posted: Sun Jun 30, 2019 7:30 pm
by joseluisysturiz
Quiero empezar a migrar de TDolphin a FWMaria la nativa de FW, por donde inicio.? gracias...
![Shocked :shock:](./images/smilies/icon_eek.gif)
Re: Pasar query a un arreglo
Posted: Mon Jul 01, 2019 2:03 am
by nageswaragunupudi
Excelente, veo que se porta igual que fillarray, ahora otra duda...se puede agrgar un valor que no sea de la consulta, como por ejemplo un valor booleano o el valor de una variable.?
Every element of the array should be a field name or field number or a character expression using or not using field names.
Example:
Code: Select all | Expand
PRIVATE n
oRs := oCn:customer // where customer is the table name
n := 100
aData := oRs:GetRows( 5, 11, ;
{ "first-', '+last", "salary/100", "FW_MTHSLAPSED(HireDate,Date())", "n := n + 1" } )
![Image](https://imagizer.imageshack.com/v2/xq90/921/acF8OO.png)
Re: Pasar query a un arreglo
Posted: Mon Jul 01, 2019 2:15 am
by joseluisysturiz
Super excelente Mr NAO...Quiero empezar a migrar de TDolphin a FWMaria la nativa de FW, por donde inicio.? gracias...
![Shocked :shock:](./images/smilies/icon_eek.gif)