Alternative to PHP database?

Asked

Viewed 111 times

2

I want to know if there’s a way to save form data, display it and edit it without using a database? Because whenever a software will do integration with database I stop because I do not understand very well database yet. I was thinking of doing with arrays, a position of each array for a record, and an array for each form field.

I know it’s hard work, but I didn’t want to go into the database right now, there’s another option?

  • You can save to files. PHP has several functions to read and write to them. http://www.w3schools.com/PHP/php_file_open.asp

  • You’ve been here a long time and you should know we’re here to answer specific questions, not to pass handouts.

1 answer

4


Database is simpler than you think. If you don’t want to install one, use the Sqlite. It is used precisely to avoid having to write to files. It is fundamental to use such a feature. I understand that you want to learn little by little but there’s no reason to avoid this.

Although it may seem simple, writing to files directly can bring several problems. I’ll give you a basic idea but it doesn’t take into account the normal functioning. You may think it’s that easy, but it’s not.

$texto = implode(",", $array); //converte o array em um texto simples
$ok = file_put_contents("arquivo.txt", $texto); //grava
$texto = file_get_contents("arquivo.txt"); //lê
$array = explode(",", $texto); //transforma em array novamente

I put in the Github for future reference.

Obviously this is a huge simplification. If you have specific questions you will ask.

  • You can serialize any array with this: http://php.net/manual/en/function.serialize.php

Browser other questions tagged

You are not signed in. Login or sign up in order to post.