in php I do this way, but how in fw SOLUCIONADO

in php I do this way, but how in fw SOLUCIONADO

Postby D.Fernandez » Sun Nov 29, 2020 12:36 am

Hi,

this run ok in php.............but how I do in fw

$resulta1 = mysqli_query($conexion, " SELECT * FROM $tabla_db2 WHERE subcta = $cue ");
$consulta1 = mysqli_fetch_array($resulta1);
$claveve = $consulta1['clave'];
$nombre = $consulta1['subnom'];
$cuentaoriginal = $consulta1['cta'];
$tipomoneda = $consulta1['sumon'];

a simple select con where.

Thank you.
Last edited by D.Fernandez on Sun Nov 29, 2020 4:30 pm, edited 1 time in total.
Dario Fernandez
FWH 22.12, Harbour, MVS2022 Community, BCC, MySql & MariaDB, Dbf/Cdx VSCode.
Maldonado - Uruguay
D.Fernandez
 
Posts: 455
Joined: Wed Jul 31, 2013 1:14 pm
Location: Maldonado - Uruguay

Re: in php I do this way, but how in fw

Postby Antonio Linares » Sun Nov 29, 2020 8:03 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: in php I do this way, but how in fw

Postby D.Fernandez » Sun Nov 29, 2020 1:33 pm

Antonio, muchas gracias.

Pero lo quiero hacer en un programa de escritorio.

Es una aplicacion vieja, que quiero ir pasando a MySql.

Saludos.
Dario Fernandez
FWH 22.12, Harbour, MVS2022 Community, BCC, MySql & MariaDB, Dbf/Cdx VSCode.
Maldonado - Uruguay
D.Fernandez
 
Posts: 455
Joined: Wed Jul 31, 2013 1:14 pm
Location: Maldonado - Uruguay

Re: in php I do this way, but how in fw

Postby D.Fernandez » Sun Nov 29, 2020 1:41 pm

Antonio, I can't do a SELECT whith the clausula WHERE.

I don't see any axample.

Example: Insert
FWCONNECT oCon HOST 'localhost' USER 'root' PASSWORD '' DB dbases

csql := oCon:InsertSQL( ctabla ,"nomlargo,idusu,pasar, claveliq",;
{ 'hola' , 'holla2', '30745298', '123456789' } )
ocon:Execute(csql)
Esto funciona bien.

Pero un SELECT con clausula WHERE no logro hacerlo.

Gracias, Saludos.
Dario Fernandez
FWH 22.12, Harbour, MVS2022 Community, BCC, MySql & MariaDB, Dbf/Cdx VSCode.
Maldonado - Uruguay
D.Fernandez
 
Posts: 455
Joined: Wed Jul 31, 2013 1:14 pm
Location: Maldonado - Uruguay

Re: in php I do this way, but how in fw

Postby Marc Venken » Sun Nov 29, 2020 2:47 pm

Maybe this part of code can help you...

Code: Select all  Expand view

#include "FiveWin.ch"
#include "richedit.ch"
#include "ord.ch"
#include "xbrowse.ch"

#include "Mail.ch"

REQUEST DBFCDX

#define WID  600
#define HGT  350
#define MY_GREEN   nRGB( 145, 214, 124)

FUNCTION Main
  local cTable, oBrw, oList, aData
  local oDlg, oBar, oFont
  local cErrorLogFileName:= "MyLog.log"

  Public cServer     := "your data"
  Public cDataBase   := "your data"
  Public cUser       := "your data"
  Public cPassWord   := "your data"

  PUBLIC oCn, oRs, setup_user:="", setup_naam:="", setup_version:="", setup_level:="", sys_admin:=.F., cPath:="", cLocal:="", cOnline:=""
  PUBLIC oCn_kab, oRs_kab
  PUBLIC system_version:="20052018", sys_ploegsplit:=0
  PUBLIC aPloegen:= {} ,aBtn:= {} ,aBtn2:= {}, aToegang:= {}, aPloegTypes:= {}
  Public aUserEdit:= {}

  SetPostErrorAction( { |cErrorLogFileName, oError| MyErrorAction( cErrorLogFileName, oError ) } )

RDDSetDefault( "DBFCDX" )
set( 4, "mm/dd/yyyy" )
set( 5, 1930 )
SET DATE BRITISH

XbrNumFormat( 'E', .t. )
//set deleted on
SetHandleCount( 100 )

setkey( VK_F12,{|| xbrowser(oBrw[4]) } )

FWCONNECT oCn HOST cServer USER cUser PASSWORD cPassword DATABASE cDatabase

if oCn == nil
   ? "Failed to connect to Maveco"
   return nil
endif


getploegen()  // this gets some data

oRs   := oCn:RowSet( "SELECT * FROM parameters" )
system_version = oRs:versie


if lGetPassword(.t.)

oCn:close()
oCn_kab:close()


SET 3DLOOK ON

DEFINE BRUSH oBrush STYLE TILED       // FiveWin new predefined Brushes

DEFINE WINDOW oWnd TITLE "LEDEN - ADMINISTRATIE" MENU BuildMenu() BRUSH oBrush

///   Rest code

function getploegen()

  oRs   := oCn:RowSet( "select * from ploegen where `actief` = ?", { .T. } )

  oRs:MoveFirst()
  aPloegen := ArrTranspose( oRs:GetRows() )[ 2 ]
  aPloegTypes := ArrTranspose( oRs:GetRows() )[ 14 ]
  ASize( aBtn, len(aPloegen))
  ASize( aBtn2, len(aPloegen))
  oRs:close()
return NIL
/*
Some samples  :
oRs_Match := oCn_kab:RowSet( "SELECT * FROM tbl_matchen where `poule` = ? " , { "3B" } )
oRsInvent := oCn:RowSet( "SELECT * FROM inventaris" )
oRsMatch  := oCn:RowSet( "select * from matchen where `bond` = ?", { oRs:bond } )

oCn:Insert( "changes", "veld, doorwie, naam, voornaam,oldploeg,newploeg,datum", { "Ploeg", setup_naam,oBrw:naam:value, oBrw:voornaam:value, oBrw:p2018:value, cPloeg, date() } )
oCn:Insert( "errors", "datum,uur,user,error,errorlog", { date(),time(), setup_naam, oError:dEscription,cErrText } )



*/


static function BrwDelselect(oBrw)

  if msgyesno("Wenst U deze regels te wissen ?")

     if !Empty( oBrw:aDeleted )
        a  := {}
        AEval( oBrw:aDeleted, { |x| If( Empty( x[ 1 ] ), nil, AAdd( a, x[ 1 ] ) ) } )
        // Array of IDs (primary key) to delete
        if !Empty( a )
           cSql     := "DELETE FROM leden WHERE ID IN " + oCn:ValToSQL( a )
           oCn:Execute( cSql )
           if oCn:nError != 0
              BREAK
           endif
        endif
     endif
  endif
return nil

  /////  This will get some Data from online database and change it.


  FWCONNECT oCn HOST cServer USER cUser PASSWORD cPassword DATABASE cDatabase

  if oCn == nil
    ? "Failed to connect"
    return nil
  endif
  oRs   := oCn:RowSet( "SELECT * FROM leden" )
  oRs:sort:= 'BOND'
  oRs:MoveFirst()
  do while ! oRs:Eof()   // reset bondflag voor controle
     oRs:bondlid = .f.
     oRs:save()
     oRs:MoveNext()
  enddo
  oRs:MoveFirst()

// check local database with online database.

   // controleer bond teveel aan spelers

  bond->(dbgotop())
  nTel = 0
  nPass = 0
  do while ! bond->(eof())
   cData = alltrim(bond->bondnum)

   oRs := oCn:RowSet( "select * FROM leden where bond = ? ", { cData } )

   if oRs:BOND = cData
      oRs:BONDLID = .T.
      oRs:aansluit = bond->aansluit_B
      if !empty(bond->ontslag)
         oRs:bonderror = "Ontslag: "+dtoc(bond->ontdat)
      else
         oRs:bonderror = ""
      endif
      nTel++
   else
      oRs:Append()
      oRs:BOND = alltrim(bond->bondnum)
      oRs:NAAM = alltrim(bond->naam_B)
      oRs:VOORNAAM = alltrim(bond->VOORN_B)
      oRs:ADRES = alltrim(bond->adres_B)
      oRs:ADRES = alltrim(bond->adres_B)
      oRs:POST = alltrim(bond->post_B)
      oRs:GEMEENTE = alltrim(bond->plaats_B)
      oRs:BONDERROR = alltrim(bond->ontslag)
      oRs:BONDLID = .T.
      oRs:geboorte = bond->geboorte_B
      oRs:aansluit = bond->aansluit_B
      oRs:ploeg2018 = "NIEUW LID"

   endif
   oRs:Save()

   bond->(dbskip())
  enddo
  msginfo("Bondcontrole verwerkt")
  oCn:close()
//  select bond
//  bond->(dbgotop())
//  showbond()
  close all
return nil





 
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: in php I do this way, but how in fwSOLUCIONADO

Postby D.Fernandez » Sun Nov 29, 2020 4:29 pm

Excelente Marc.

Tomado de tus ejemplos, lo soluciné. Gracias.
Así quedó.

FWCONNECT oCon HOST 'localhost' USER 'root' PASSWORD '' DB dbases
oRs := oCon:RowSet( "select * from usuario where `idusu` = &1", { cUsuario } )

? oRs:FieldGet(4) >>>>Este dato quería.

Gracias.
Dario Fernandez
FWH 22.12, Harbour, MVS2022 Community, BCC, MySql & MariaDB, Dbf/Cdx VSCode.
Maldonado - Uruguay
D.Fernandez
 
Posts: 455
Joined: Wed Jul 31, 2013 1:14 pm
Location: Maldonado - Uruguay


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 78 guests