Working with databases. Video tutorial 7 - Forum

Forum Navigation
You need to log in to create posts and topics.

Working with databases. Video tutorial 7

For learning purposes we have been using a SQLite database in our video tutorials but, if you are an advanced user, you would probably be interested in using MySQL instead.
The process is not hard and in fact it's not necessary to do any changes to your app, just to the config.php file and some server adjustments. Let's start!

This is the key code for config.php:

//MySQL database setup
$dbAlias[0]="db1";
$dbNames[0]="your_database_name";
$dbServerNames[0]="your_mysql_host";
$dbUserNames[0]="db_username";
$dbPasswords[0]="db_password";

 

 

Vadim, asmat and 2 other users have reacted to this post.
VadimasmatrocoteYASIN

Hola Luis, gracias de nuevo por este gran video. ¡Es genial!
¿Desea escribir la Parte 7 o la Parte 6 debajo de la descripción del video en Youtube?
Sé que la parte 6 ya existe y tú escribiste la parte 7. Así que solo quería decírtelo.
Verá, tomé una clase de español esta mañana con la Sra. Google y ahora puedo hablar con usted en su lengua materna. :)

¡Gracias otra vez!

Roger :)

😂 🤣 😂 🤣

asmat has reacted to this post.
asmat

Hi @luishp, your demos look good and clearer. I'm tempted to try out the remote database as a viable option to my current project.

Just some questions, using your TELEPHONE app as reference.

  1. There are 10 authorised users accessing the app.  A master DB is used to authenticate user login/pwd access. I presume this would be the main DB used by the app.
  2. Each user has their own recordDB, which means if there are 10 authorised users, there'd be 10 individual DB assigned to each user. How do I create/setup that? Do I need multiple config?
  3. When user choose  "SAVE TO HOMESCREEN", would there recordDB be accessible?
  4. What if they turn ON the airplane mode, would there be a temp local copy of their recordDB?

Thanks, Ronnie

Hi @ronnie

There are 10 authorised users accessing the app. A master DB is used to authenticate user login/pwd access. I presume this would be the main DB used by the app.

Currently I have only explained how to create a single user access but it's possible to add multiple users with different access levels. Please take a look at the config.php template file for more info.

Each user has their own recordDB, which means if there are 10 authorised users, there'd be 10 individual DB assigned to each user. How do I create/setup that? Do I need multiple config?

No, it doesn't work that way. You should add a new field to the table with the owner userid. A single table in a single database will store all the data but you only show to each user it's own data.

When user choose "SAVE TO HOMESCREEN", would there recordDB be accessible?

The client side files are cached while the database and server side files ramins in your web server. It will be accesible whenever there is an Internet connection.

What if they turn ON the airplane mode, would there be a temp local copy of their recordDB?

You have to save a copy first (Stringified JSON data on a localStorage variable) and detect there is not connection to load data from that variable instead of the remote database.

I will be back to more advanced database tutorials in the near future. Your questions are very interesting to talk about them.

Vadim and YASIN have reacted to this post.
VadimYASIN

Super!!!
Thanks so much for this tutorial, Luis !!!

Hi Luis,

Once again, thank you very much for the care you take in providing us with quality tutorials!

Best regards,

Hi @luishp, thanks for the reply. Didn’t think of using userid as a “key field” for specific record access, which is interesting. Yes, more video demos would make it easier to absorb the ideas. I was initially hesitant for my lack of server DB portion through pho etc, although using SQLite is not an issue. Your database demos do showcase what can be done.  Looking forward to more DB demo sequels..