B4J Question [BANanoMySQLE] problems with Mysql[SOLVED]

micro

Well-Known Member
Licensed User
Longtime User
Hi to all
sorry but i need some help connecting with a mysql db.
I have laragon with php installed, database created and in fact with phpmyadmin I can log in safely
The php file is created in the same root of index.html and in assets is present config.php but seems not to work, maybe I miss some steps.
B4X:
Dim dbsql As BANanoMySQLE
Dim query As String = "SHOW TABLES"
dbsql.Execute(query)
dbsql.json = BANano.CallInlinePHPWait(dbsql.MethodName, dbsql.Build)
dbsql.FromJSON
Log(dbsql.OK)      '< false
Log(dbsql.result) 'Empty list
Log("mostra Table")
what or where am I wrong?
With B4J, poolconnection, JRDC2 now I have acquired enough experience but with BANano I need time to understand better
Thanks
 

micro

Well-Known Member
Licensed User
Longtime User
Maybe better change the title to [BANanoMySQLE] as this is not a core BANano function but a library and the original library writer (@Mashiane ) could miss it.
sorry, you are right alwaysbusy šŸ™
I correct the title
but I would also like an example directly in pure BANano, thanks.
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
A few questions

Q1. Have you updated the config.php file to match your MySQL connection settings as indicated on this thread?


Q2. Have you updated the port settings as discussed on this post of the same thread above?


Q3. Can you log dbsql.error, this will indicate what the error is?

Ta
 
Upvote 0

micro

Well-Known Member
Licensed User
Longtime User
Last edited:
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
where do i find the file? (path)

Im not sure I understand your question here. If you are referring to the config.php, this should be listed on the Files tab of your project. It will be saved on the assets folder when you run your app.

If you Log(dbsql.Error) as per your example on the first post after .FromJSON, the result should show on the console.log.
 
Upvote 0

micro

Well-Known Member
Licensed User
Longtime User
Im not sure I understand your question here. If you are referring to the config.php, this should be listed on the Files tab of your project. It will be saved on the assets folder when you run your app.
let me explain better.
Configurations are right (also config.php file is ok) but it doesn't work, so it may be that the code is wrong.
Is the code in the first post ok for you?

Log(dbsql.Error) = invalid request: ''
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
Is the code in the first post ok for you?

I have checked the code, it seems like you have not initialized the variable after defining it.

B4X:
Dim dbsql As BANanoMySQLE

You need to initialize the dbsql variable, just pass it any table name and primary key you have on the database. You might need to upload an example project.
 
Upvote 0

micro

Well-Known Member
Licensed User
Longtime User
You need to initialize the dbsql variable, just pass it any table name and primary key you have on the database. You might need to upload an example project
I saw that the initialization was missing but if I have to initialize the variable with a table this is a limitation of the library.
If I only know the database name and not the tables?
How can I get the table names?
Thanks Mashiane
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
I saw that the initialization was missing but if I have to initialize the variable with a table this is a limitation of the library.
Its like you are saying. I know I was told this vehicle does not have fuel, I will start its engine anyway, it will start. It wont.

If you read the first post of BANanoConnect, its clear that the library is built for CRUD functionality. SHOW TABLES is not a CRUD function because it does not do INSERT, SELECT, UPDATE and DELETE, so the library does not have limits for CRUD because it was built for that and nothing else.

Its an open source project, you are welcome to update the code to suit your needs or rather write your own library. So just to be emphasize for you and anyone else who wants to use it, you cannot use any class of this library without initializing it first.

In your particular case, you want to show table names with the assumption that you don't know the table names. Perhaps try this.

B4X:
dbsql.Initialize("unknown", "unknown", "unknown")

Good luck

PS: As you have not uploaded any example source project to help you further with this, helping you further will be challenging.
 
Upvote 0
Top