Pasar query a un arreglo
- Compuin
- Posts: 1250
- Joined: Tue Dec 28, 2010 1:29 pm
- Location: Quebec, Canada
- Has thanked: 7 times
- Been thanked: 3 times
Pasar query a un arreglo
Hola foro,
Como puedo leer una tabla mysql y pasar su contenido a un arreglo?
Hay algun ejemplo en Fivewin?
Gracias
Como puedo leer una tabla mysql y pasar su contenido a un arreglo?
Hay algun ejemplo en Fivewin?
Gracias
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
- joseluisysturiz
- Posts: 2064
- Joined: Fri Jan 06, 2006 9:28 pm
- Location: Guatire - Caracas - Venezuela
- Contact:
Re: Pasar query a un arreglo
Usa oQry:fillarray...es lo mejor y mas rapido, saludos...
![Shocked :shock:](./images/smilies/icon_eek.gif)
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]) ) }, )
Dios no está muerto...
Gracias a mi Dios ante todo!
Gracias a mi Dios ante todo!
- Compuin
- Posts: 1250
- Joined: Tue Dec 28, 2010 1:29 pm
- Location: Quebec, Canada
- Has thanked: 7 times
- Been thanked: 3 times
Re: Pasar query a un arreglo
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
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
- joseluisysturiz
- Posts: 2064
- Joined: Fri Jan 06, 2006 9:28 pm
- Location: Guatire - Caracas - Venezuela
- Contact:
Re: Pasar query a un arreglo
Olvide comentarte que esto es usando TDolphin, saludos... ![Shocked :shock:](./images/smilies/icon_eek.gif)
![Shocked :shock:](./images/smilies/icon_eek.gif)
Dios no está muerto...
Gracias a mi Dios ante todo!
Gracias a mi Dios ante todo!
- Compuin
- Posts: 1250
- Joined: Tue Dec 28, 2010 1:29 pm
- Location: Quebec, Canada
- Has thanked: 7 times
- Been thanked: 3 times
Re: Pasar query a un arreglo
joseluisysturiz wrote:Olvide comentarte que esto es usando TDolphin, saludos...
Si, imagino que es TDolphin
Yo uso Eagle1, deberia funcionar ya que solo es el resultado del query
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
- joseluisysturiz
- Posts: 2064
- Joined: Fri Jan 06, 2006 9:28 pm
- Location: Guatire - Caracas - Venezuela
- Contact:
Re: Pasar query a un arreglo
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)
![Shocked :shock:](./images/smilies/icon_eek.gif)
Dios no está muerto...
Gracias a mi Dios ante todo!
Gracias a mi Dios ante todo!
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Pasar query a un arreglo
Native FWH:
Simple and the fastest:
aData := oCn:Execute( cQry )
Example:
Simple and the fastest:
aData := oCn:Execute( cQry )
Example:
Code: Select all | Expand
aStates := oCn:Execute( "select code,name from states" )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Compuin
- Posts: 1250
- Joined: Tue Dec 28, 2010 1:29 pm
- Location: Quebec, Canada
- Has thanked: 7 times
- Been thanked: 3 times
Re: Pasar query a un arreglo
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
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
- Compuin
- Posts: 1250
- Joined: Tue Dec 28, 2010 1:29 pm
- Location: Quebec, Canada
- Has thanked: 7 times
- Been thanked: 3 times
Re: Pasar query a un arreglo
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...
Gracias Jose Luis por la aclaratoria
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
- joseluisysturiz
- Posts: 2064
- Joined: Fri Jan 06, 2006 9:28 pm
- Location: Guatire - Caracas - Venezuela
- Contact:
Re: Pasar query a un arreglo
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)
Dios no está muerto...
Gracias a mi Dios ante todo!
Gracias a mi Dios ante todo!
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Pasar query a un arreglo
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:
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
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" )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- joseluisysturiz
- Posts: 2064
- Joined: Fri Jan 06, 2006 9:28 pm
- Location: Guatire - Caracas - Venezuela
- Contact:
Re: Pasar query a un arreglo
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 fastCode: 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:
Dios no está muerto...
Gracias a mi Dios ante todo!
Gracias a mi Dios ante todo!
- joseluisysturiz
- Posts: 2064
- Joined: Fri Jan 06, 2006 9:28 pm
- Location: Guatire - Caracas - Venezuela
- Contact:
Re: Pasar query a un arreglo
Quiero empezar a migrar de TDolphin a FWMaria la nativa de FW, por donde inicio.? gracias... ![Shocked :shock:](./images/smilies/icon_eek.gif)
![Shocked :shock:](./images/smilies/icon_eek.gif)
Dios no está muerto...
Gracias a mi Dios ante todo!
Gracias a mi Dios ante todo!
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Pasar query a un arreglo
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)
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- joseluisysturiz
- Posts: 2064
- Joined: Fri Jan 06, 2006 9:28 pm
- Location: Guatire - Caracas - Venezuela
- Contact:
Re: Pasar query a un arreglo
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)
![Shocked :shock:](./images/smilies/icon_eek.gif)
Dios no está muerto...
Gracias a mi Dios ante todo!
Gracias a mi Dios ante todo!