B4J Question [BANano]: [SOLVED] Using MySQL / MSSQL with PHP

Discussion in 'B4J Questions' started by Mashiane, Jan 20, 2019.

  1. Mashiane

    Mashiane Expert Licensed User

    Hi there

    Update: April 8, 2019 Solution

    [BANAno] MySQL CRUD with PHP - Part 1
    [BANano] MySQL CRUD with PHP - Part 2

    I have an issue that I need to address. I have a backend that I need to speak to from my BANano App, this could either be MySQL or either MSSQL (no decision as yet). I guess with PHP this could happen well, this will basically be for CRUD functionality.

    What advise can you push my way on such? (if any)

    Last edited: Apr 8, 2019
    joulongleu likes this.
  2. Kiffi

    Kiffi Well-Known Member Licensed User

    Here is a very simple code to show how to communicate with the server via BANano Inline-PHP:

    Sub Process_Globals
    Dim BANano As BANano 'ignore
    End Sub

    Sub AppStart (Form1 As Form, Args() As String)

        BANano.UseServiceWorker = 
        BANano.HTML_NAME = 
        BANano.Header.Title = 
        BANano.PHP_NAME = 
        BANano.PHPHost = 
    "Access-Control-Allow-Origin: *")
    "C:\inetpub\wwwroot\BANano\"' Customize to your needs!

    End Sub

    #If PHP

        function Login($Username, $Password) {
            if ($Username=="John" && $Password=="Doe") {
                echo "OK";
            } else {
                echo "KO";

    #End If

    Sub InlinePhpTest_Ready()

    "body").Append("<br />")

    End Sub

    public Sub btnLogin_Click(event As BANanoEvent)
    If BANano.CheckInternetConnectionWait Then

    Dim Username As String = BANano.GetElement("#txtusername").GetValue
    Dim Password As String = BANano.GetElement("#txtpassword").GetValue
    Dim Result As String = BANano.CallInlinePHPWait("Login", CreateMap("Username":Username, "Password":Password))
    Select Result
    Case "OK"
    "Login: OK :-)")
    Case Else
    "Login failed!")
    End Select
    "You are not connected to the internet!")
    End If

    End Sub

    Sub BuildInput(ID As String, InputType As String, LabelText As String, Value As String)
    ID = ID.ToLowerCase
    "body").Append($"<label for="${ID}">${LabelText}</label>"$)
    "body").Append($"<input type="${InputType}" id="${ID}" value="${Value}">"$)
    End Sub

    Sub BuildButton(ID As String, Text As String)
    ID = ID.ToLowerCase
    Dim Button As BANanoElement = BANano.GetElement("body").Append($"<button id="${ID}">${Text}</button>"$).Get($"#${ID}"$)
    Button.On("click", Me, ID & "_click")
    End Sub

    Sub AddOutput(Message As String)
    End Sub
    Greetings ... Peter
    Mashiane, Harris and alwaysbusy like this.
  3. alwaysbusy

    alwaysbusy Expert Licensed User

    Ajax or inline php can do the job.
    Last edited: Jan 20, 2019
    joulongleu and Mashiane like this.
  4. alwaysbusy

    alwaysbusy Expert Licensed User

    joulongleu likes this.
  5. Mashiane

    Mashiane Expert Licensed User

    Great stuff thanks a lot. I like the way you simplified the code example.

    I will play around.

    joulongleu likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice