2000-09-30 22:22 GMT+2 Maurilio Longo <maurilio.longo@libero.it>

This commit is contained in:
Maurilio Longo
2000-09-30 20:23:57 +00:00
parent e5a5dc0801
commit 607eba5033
3 changed files with 54 additions and 20 deletions

View File

@@ -1,3 +1,9 @@
2000-09-30 22:22 GMT+2 Maurilio Longo <maurilio.longo@libero.it>
*contrib/mysql/tmysql.prg
! fixes / changes to work with tsqlbrw.prg
+contrib/mysql/tsqlbrw.prg
* fixes / changes - work in progress.
2000-09-30 09:50 GMT+3 Alexander Kresin <alex@belacy.belgorod.su>
* contrib/mysql/mysql.c
* minor change for support of Win32

View File

@@ -98,14 +98,13 @@ METHOD New(aRow, aFStruct, cTableName) CLASS TMySQLRow
default cTableName to ""
default aFStruct to {}
::cTable := cTableName
::aFieldStruct := aFStruct
::aRow := aRow
::aFieldStruct := aFStruct
::cTable := cTableName
::aDirty := Array(Len(::aRow))
::aOldValue := Array(Len(::aRow))
AFill(::aDirty, .F.)
return Self
@@ -114,7 +113,14 @@ return Self
METHOD FieldGet(nNum) CLASS TMySQLRow
if nNum > 0 .AND. nNum <= Len(::aRow)
return ::aRow[nNum]
// Char fields are padded with spaces since a real .dbf field would be
if ValType(::aRow[nNum]) == "C"
return PadR(::aRow[nNum], ::aFieldStruct[nNum][MYSQL_FS_LENGTH])
else
return ::aRow[nNum]
endif
endif
return nil
@@ -125,6 +131,12 @@ METHOD FieldPut(nNum, Value) CLASS TMySQLRow
if nNum > 0 .AND. nNum <= Len(::aRow)
if Valtype(Value) == Valtype(::aRow[nNum]) .OR. Empty(::aRow[nNum])
// if it is a char field remove trailing spaces
if ValType(Value) == "C"
Value := RTrim(Value)
endif
// Save starting value for this field
if !::aDirty[nNum]
::aOldValue[nNum] := ::aRow[nNum]
@@ -511,8 +523,8 @@ METHOD Delete(oRow) CLASS TMySQLTable
cDeleteQuery += oRow:MakePrimaryKeyWhere()
if sqlQuery(::nSocket, cDeleteQuery) == 1
return .T.
if sqlQuery(::nSocket, cDeleteQuery) == 0
::lError := .F.
else
::lError := .T.
@@ -521,7 +533,7 @@ METHOD Delete(oRow) CLASS TMySQLTable
endif
return .F.
return !::lError
// Adds a row with values passed into oRow
@@ -683,9 +695,9 @@ METHOD CreateTable(cTable, aStruct) CLASS TMySQLServer
case aStruct[i][DBS_TYPE] == "N"
if aStruct[i][DBS_DEC] == 0
cCreateQuery += aStruct[i][DBS_NAME] + " int " + Eval(cNN, aStruct[i]) + ","
cCreateQuery += aStruct[i][DBS_NAME] + " int(" + AllTrim(Str(aStruct[i][DBS_LEN])) + ")" + Eval(cNN, aStruct[i]) + ","
else
cCreateQuery += aStruct[i][DBS_NAME] + " real " + Eval(cNN, aStruct[i]) + ","
cCreateQuery += aStruct[i][DBS_NAME] + " real(" + AllTrim(Str(aStruct[i][DBS_LEN])) + "," + AllTrim(Str(aStruct[i][DBS_DEC])) + ")" + Eval(cNN, aStruct[i]) + ","
endif
case aStruct[i][DBS_TYPE] == "D"

View File

@@ -97,7 +97,11 @@ METHOD Block() CLASS TBColumnSQL
xValue := iif(xValue, ".T.", ".F.")
case ValType(xValue) $ "CM"
xValue := "'" + xValue + "'"
// Chr(34) is a double quote
// That is: if there is a double quote inside text substitute it with a string
// which gets converted back to a double quote by macro operator. If not it would
// give an error because of unbalanced double quotes.
xValue := Chr(34) + StrTran(xValue, Chr(34), Chr(34) + "+Chr(34)+" + Chr(34)) + Chr(34)
otherwise
endcase
@@ -122,6 +126,7 @@ CLASS TBrowseSQL from TBrowse
// corresponding row inside table
METHOD BrowseTable(nKey, lCanEdit) // Handles standard moving inside table and if lCanEdit == .T.
// allows editing of field. It is the stock ApplyKey() moved inside a table
// if lCanEdit K_DEL deletes current row
ENDCLASS
@@ -160,24 +165,26 @@ METHOD New(nTop, nLeft, nBottom, nRight, oServer, oQuery, cTable) CLASS TBrowseS
// Add a column for each field
for i := 1 to ::oQuery:FCount()
// No bBlock now since New() would use it to find column length, but column is not ready yet at this point
oCol := TBColumnSQL():New(::oCurRow:FieldName(i),, Self)
oCol:Width := Max(::oCurRow:aFieldStruct[i][MYSQL_FS_LENGTH], Len(oCol:Heading))
//Alert(Str(oCol:Width))
// which field does this column display
oCol:nFieldNum := i
// Add a picture
/*do case
do case
case ISNUMBER(::oCurRow:FieldGet(i))
oCol:picture := "@N999,999"
oCol:picture := replicate("9", ::oCurRow:aFieldStruct[i][MYSQL_FS_LENGTH])
case ISCHARACTER(::oCurRow:FieldGet(i))
// For non-numeric, just use colors 3 and 4 ("B/W" and "B/BG")
oCol:picture := replicate("!", ::oCurRow:aFieldStruct[i][MYSQL_FS_LENGTH])
oCol:picture := replicate("!", ::oCurRow:aFieldStruct[i][MYSQL_FS_LENGTH])
endcase*/
endcase
::AddColumn(oCol)
next
@@ -268,7 +275,7 @@ METHOD EditField() CLASS TBrowseSQL
aGetList := { getnew( row(), col(), ;
{|xValue| iif(xValue == nil, ::oCurRow:FieldGet(oCol:nFieldNum), ::oCurRow:FieldPut(oCol:nFieldNum, xValue))} ,;
oCol:heading, ;
nil, ;
oCol:picture, ;
::colorSpec ) }
// Set insert key to toggle insert mode and cursor shape
@@ -378,11 +385,20 @@ METHOD BrowseTable(nKey, lCanEdit) CLASS TBrowseSQL
::EditField()
endif
/*otherwise
KEYBOARD chr( nKey )
DoGet( oBrowse )*/
otherwise
/*case nKey == K_DEL
if lCanEdit
if ! ::oQuery:Delete(::oCurRow)
Alert("not deleted " + ::oQuery:Error())
endif
if !::oQuery:Refresh()
Alert(::oQuery:Error())
endif
::inValidate()
::refreshAll():forceStable()
endif*/
otherwise
endcase
return Self