null_bind.bmx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. SuperStrict
  2. Framework Database.MariaDB
  3. Import BRL.filesystem
  4. Import BRL.StandardIO
  5. Local db:TDBConnection = LoadDatabase("MARIADB", "maxtest", Null, 0, "brucey", "brucey")
  6. If Not db Then
  7. Print("Didn't work...")
  8. End
  9. End If
  10. If db.hasError() Then
  11. errorAndClose(db)
  12. End If
  13. If db.isOpen() Then
  14. db.executeQuery("DROP TABLE if exists nulltest")
  15. Local s:String = "CREATE TABLE if not exists nulltest ( " + ..
  16. " c1 varchar(30)," + ..
  17. " c2 int, c3 float )"
  18. db.executeQuery(s)
  19. If db.hasError() Then
  20. errorAndClose(db)
  21. End If
  22. db.executeQuery("INSERT INTO nulltest VALUES('hello', 1, 5)")
  23. db.executeQuery("INSERT INTO nulltest VALUES('world', 2, 10)")
  24. Local query:TDatabaseQuery = TDatabaseQuery.Create(db)
  25. query.Prepare("UPDATE nulltest SET c3=? WHERE c2=?")
  26. query.BindValue(0, TDBFLoat.Set(1))
  27. query.BindValue(1, TDBInt.Set(1))
  28. query.Execute()
  29. query.BindValue(0, New TDBFLoat())
  30. query.BindValue(1, TDBInt.Set(1))
  31. query.Execute()
  32. db.close()
  33. End If
  34. Function errorAndClose(db:TDBConnection)
  35. Print(db.error().toString())
  36. db.close()
  37. End
  38. End Function