This question already has answers here:
Schema for a multilanguage database
(10 answers)
Closed 8 years ago.
I have an app written in PHP with MySQL in the back. Originally the app was using custom language class that was quite ineffective so I changed everything to use gettext.
The problem is a lot of strings are in the database, stored in tables that are never changed just read from. The good thing is every installation is in only one language.
In order to provide the strings in different languages, different databases were used before. There is database_en, database_fr, etc. and every new installation is using the appropriate localized database. I want to change this - one database for all languages.
I am thinking of moving everything language specific from the database to config files where gettext can be used again.
Do you think this is good idea or you would continue using different databases for different installations? Can you recommend something better ?
I recommend using google translation api at front end and single database for all with unicode data types.
Related
This question already has an answer here:
Master/Slave Mysql Architecture vs Server/Read DB and Separate DB for writes only [closed]
(1 answer)
Closed 3 years ago.
As laravel document says:
Sometimes you may wish to use one database connection for SELECT statements, and another for INSERT, UPDATE, and DELETE statements. Laravel makes this a breeze, and the proper connections will always be used whether you are using raw queries, the query builder, or the Eloquent ORM.
What is the benefit of doing this and what are the tradeoffs?
As far as I'm aware of, this is normally done if you have a very read-heavy application. In such a case you can have a master-slave database system which performs internal replication in order to provide more hardware power to feed the application. The slave can be a machine optimized for reading while the master is optimized for writing, although I've to admit that this goes far beyond my expertise.
There are also alternatives for load balancing SQL connections, for example using HAProxy.
This question already has answers here:
How to use multiple databases in Laravel
(7 answers)
Closed 5 years ago.
I am creating a Laravel/latest-version application which requires several hundreds of sql table to be created to serve the job. There will again be hundreds of clients who's data will be inserted multiple times (1000 rows per client or more in some tables) in these table. To eliminate confusion, I want a general/common-database for common information and separate Database for each client for specific information and would like to create new DB when a client is added. Can this be done in Laravel (dealing with multiple Databases at once) or is there any other PHP framework which can serve this purpose better? Much obliged for your help.
Well most of the times, this is an architectural flaw because the db isn't designed well. Normally this kind of issue is faced due to the reason that all your tables are normalized. Normalization is good for small applications but for data rich applications you have to judge which fields need to be normalized and which doesn't need normalization. You can save lots of tables and fields with denormalization. As a rule of thumb anything that you dont have to query directly or via join can be denormalized.
Anyways it is possible to have multiple databases attached to a single laravel application. I have done this once on a huge application.
So the idea is that before every eloquent query you will have to set the db connection.
$someModel->setConnection('mysql2');
You can find more information about it here
This question already has answers here:
How to manage User Roles in a Database?
(5 answers)
Closed 7 years ago.
I am a beginner with php and mysql. I am going to develop a web application which has three types of users, namely admins, staff and customers. Each have restricted access to differe parts of the application. Should I create a table for each group of users or just one table with a column specifying user type? Which approach is better? Is there other options? And at last, I really prefer to have one single login page for all three types of users.
Personally I would prefer different tables and use also different login fields on your login page (or check every login in every table until you find the right one). This is easier if you have to connect tables and I.e. admins can do things, that causes links between different tables than those staff members could cause.
On the other hand the login process would be a little bit easier if it's in one table.
I've done a project, that sounds very similar to yours. Maybe it could help you sometimes if you have a look at it. You can find it at GitHub.
Good luck with your project :)
This question already has answers here:
How is the PHP array implemented on the C level?
(5 answers)
Closed 8 years ago.
I have a simple question regarding how PHP stores an array value:
How a simple array is stored internally (the zvalues) by the PHP interpreter? Is it a continguous memory space or it is a kind of linked list & hash-tree (or some hybrid depending on his size)?
I'am asking this because the array type in PHP can be used conveniently as a simple list, stack, queue or some kind of heap (but I don't know what kind of data structure PHP uses to store them).
Thanks.
Internally PHP just uses a simple HashTable. (First a hash lookup; upon collision there's a simple list lookup.)
By the way, there are also some special classes in the SPL http://php.net/spl.datastructures which you might want to use for special things… (Only use them if really necessary… it's mostly just not worth it.)
This question already has answers here:
MySQL: Views vs Stored Procedures
(4 answers)
Closed 9 years ago.
I am a application where number of reports are more. What i do for each report is that i create a mysql view and a mysql stored procedure. From front end php i give a call to stored procedure with where clause, based on this where clause i fetch results from the particular view. Recently i found out that it was causing performance issue. So i avoided views and wrote the same code in stored procedure and performance improved. So from that poit i am confused as to ideal situation when i should use Stored procedure and when i should use views.
And Does my scenario explained above really cause performance issue or was it problem at my end?
Views in mysql are mainly for readability. They enable you to hide a possibly complex query over multiple tables into something that appears to be a single table.
I would suspect that the most likely cause is not the use of views themselves (although not sure they would help you in any way, while a stored procedure might well be more efficient), rather a view you are using is poorly optimised (maybe ignoring keys).