Addons para Dolphin
Posted: Thu Nov 07, 2013 8:31 pm
Amigos, estoy en proceso de migrar una app que actualmente usa ADS Server a MYSQL usando Dolphin
y les comentos que me esta yendo de maravilla, la velocidad de la app en browses es abismal, estoy como al 20% y estoy entusiasmado, mucho.
le dejos algunas cosillas que he agregado a dolphin para hacerme mas facil la vida. adicionalmente les comento que estoy usando la dll cliente de MariaSQL
libmariadb.dll en lulgar de libmysql.lib
y les comentos que me esta yendo de maravilla, la velocidad de la app en browses es abismal, estoy como al 20% y estoy entusiasmado, mucho.
le dejos algunas cosillas que he agregado a dolphin para hacerme mas facil la vida. adicionalmente les comento que estoy usando la dll cliente de MariaSQL
libmariadb.dll en lulgar de libmysql.lib
Code: Select all | Expand
oServer:Execute2( "UPDATE USUARIOS SET HISTORICO=CONCAT(HISTORICO, %1 ) WHERE IDENTIDAD=%2", { cLog, cUserIden } )
Code: Select all | Expand
TRY
oQryCiud := oServer:Query2( "SELECT NUM_CIUD, NOMBRE FROM CIUDADES ORDER BY NOMBRE" )
IF !Empty( cFiltro )
oQryFeri := oServer:Query2( "SELECT * FROM vCATFERI WHERE NUM_CIUD=%1 OR NUM_CIUD=0 ORDER BY FECHA", { 10 } )
ELSE
oQryFeri := oServer:Query2( "SELECT * FROM vCATFERI ORDER BY FECHA" )
ENDIF
oQryCiud:FillDbf( "TBLCIUD", "TEMP1" )
oQryCiud:END()
CATCH oError
IIf( HB_IsObject( oQryCiud ), oQryCiud:END(), NIL )
IIf( HB_IsObject( oQryFeri ), oQryFeri:END(), NIL )
ShowError( oError )
RETURN
END
Code: Select all | Expand
...
PROCEDURE MisExtenciones
EXTEND CLASS TDOLPHINQRY WITH METHOD FillDbf //toma la consulta y la pasa una tabla
EXTEND CLASS TDOLPHINSRV WITH METHOD Query2 //query con parametros
EXTEND CLASS TDOLPHINSRV WITH METHOD Execute2 //execute con parametros
RETURN
/*-------------------------------------------------------------------------------------------------*/
FUNCTION FillDbf( cTable, cAlias, bOnStart, bOnEnd )
LOCAL Self := HB_QSelf()
LOCAL lCreated := FALSE
LOCAL aStructure := {}
LOCAL x, cOldAlias := Alias()
DEFAULT cTable := "SQLRESULT", cAlias := cTable, bOnStart := {|| NIL }, bOnEnd := {|| NIL }
Eval( bOnStart, Self )
IF SELECT( cAlias ) > 0
(cAlias)->( DBCloseArea() )
ENDIF
nCountF := ::FCount()
FOR x := 1 TO nCountF
AAdd( aStructure, { ::FieldName(x), ::FieldType(x), ::FieldLen(x), FieldDec(x) } )
NEXT
TRY
DBCreate( cTable, aStructure, "DBFCDX", TRUE, cAlias )
::GoTop()
DO WHILE !::Eof()
(cAlias)->( DBAppend() )
FOR x := 1 TO nCountF
(cAlias)->( FieldPut(x, ::FieldGet(x) ) )
NEXT
::Skip()
ENDDO
::GoTop()
(cAlias)->( DBGoTop() )
lCreated := TRUE
CATCH
lCreated := FALSE
END
IF !Empty(cOldAlias)
DBSelectArea( cOldAlias )
ENDIF
Eval( bOnEnd, Self )
RETURN lCreated
/*-------------------------------------------------------------------------------------------------*/
FUNCTION Query2( cQuery, aParameters, lShow )
LOCAL Self := HB_QSelf()
LOCAL xParameter
LOCAL cQuery2
DEFAULT aParameters := NIL, lShow := FALSE
IF !HB_IsNil( aParameters ) .and. HB_IsArray( aParameters )
IF !HB_IsNil( aParameters ) .and. HB_IsArray( aParameters )
FOR EACH xParameter IN aParameters
cQuery := StrTran( cQuery, "%" + Num2Str( HB_EnumIndex() ), Var2Str( xParameter ) )
NEXT
cQuery2 := cQuery
ENDIF
ELSE
cQuery2 := cQuery
ENDIF
IF lShow
MsgInfo( cQuery2 )
ENDIF
RETURN ::Query( cQuery2 )
/*-------------------------------------------------------------------------------------------------*/
FUNCTION Execute2( cQuery, aParameters, lShow )
LOCAL Self := HB_QSelf()
LOCAL xParameter
LOCAL cQuery2
DEFAULT aParameters := NIL, lShow := FALSE
IF !HB_IsNil( aParameters ) .and. HB_IsArray( aParameters )
IF !HB_IsNil( aParameters ) .and. HB_IsArray( aParameters )
FOR EACH xParameter IN aParameters
cQuery := StrTran( cQuery, "%" + Num2Str( HB_EnumIndex() ), Var2Str( xParameter ) )
NEXT
cQuery2 := cQuery
ENDIF
ELSE
cQuery2 := cQuery
ENDIF
IF lShow
MsgInfo( cQuery2 )
ENDIF
::Execute( cQuery2 )
RETURN
/*-------------------------------------------------------------------------------------------------*/
FUNCTION Var2Str( xValue )
LOCAL cValue := "''"
DO CASE
CASE HB_IsString( xValue )
cValue := "'" + xValue + "'"
CASE HB_IsNumeric( xValue )
cValue := Num2Str( xValue )
CASE HB_IsLogical( xValue )
cValue := IIf( xValue, '1', '0' )
CASE HB_IsDate( xValue )
cValue := "'" + Transform( DToS( xValue ), "@R 9999-99-99" ) + "'"
ENDCASE
RETURN cValue
/*-------------------------------------------------------------------------------------------------*/
FUNCTION Num2Str( nNum )
RETURN AllTrim( CStr( nNum ) )
/*-------------------------------------------------------------------------------------------------*/