SQL or PHP? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

SQL or PHP?

I'm working on a project with quite a lot of stuff in the DB. Is it better to leave complex data manipulation in the DB, or do it in PHP, what's your opinion?

28th Feb 2017, 9:20 PM
spotbot2k
spotbot2k - avatar
49 Answers
+ 12
sql is better... as it is more easier and commonly used
7th Mar 2017, 5:44 PM
SHOBHANA.G
SHOBHANA.G - avatar
+ 10
In my opinion SQL is easier but can't do everything PHP does. If you just want to work with a DB for a webpage I would choose SQL.
2nd Mar 2017, 5:00 PM
JRE
JRE - avatar
+ 7
If by PHP you mean merely keeping the data in some text file, it's much better using databases.
28th Feb 2017, 9:26 PM
Norayr Gasparyan
Norayr Gasparyan - avatar
+ 7
Data manipulation should be left to SQL because you can leverage DB Server capabilities.
2nd Mar 2017, 8:42 PM
Davide Corbelletto
Davide Corbelletto - avatar
+ 6
SQL is easier choose SQl first...
8th Mar 2017, 4:09 PM
Mohed
Mohed - avatar
+ 5
SQL
2nd Mar 2017, 12:55 AM
nouha coding girl
nouha coding girl - avatar
+ 5
Sql all the way...
8th Mar 2017, 7:42 PM
Cory Gutierrez🔹
Cory Gutierrez🔹 - avatar
+ 4
mariadb
1st Mar 2017, 6:27 PM
Yuriy Krupenya
Yuriy Krupenya - avatar
+ 3
I like SQL more! It's much easier to learn SQL
8th Mar 2017, 5:17 PM
keivan Ipchi
keivan Ipchi - avatar
+ 2
@Norayr - not an option. DB ist a part of third-party software with no API of any kind.
28th Feb 2017, 9:31 PM
spotbot2k
spotbot2k - avatar
+ 2
Always it depends on last mysql versions support is better for stored procedures, views, joins. MySQL really sucks on complex querys i like Oracle Or MSSQL community versions. On current version of PHP two options to manage PDO or mysqli extension, if you are sure of db never migrated to other manager choose MySQLi in other case choose PDO.
1st Mar 2017, 1:35 AM
nextco
nextco - avatar
+ 2
both))
2nd Mar 2017, 7:31 AM
Ivan
Ivan - avatar
+ 2
I think its better to do Both. You wouldn't do much in PHP without SQL. You will always need SQL in php back end. Uness you will just be frontend.
2nd Mar 2017, 4:42 PM
Zemuldo
Zemuldo - avatar
+ 2
Obviously you should use sql
2nd Mar 2017, 6:15 PM
Mizanul Hasan
+ 2
SELECT from the DB using complex query, use it for output and calculations in PHP, Store result in the dB. MySQL is really good at reading and slow on writing if not doing it properly. It does the job.
4th Mar 2017, 6:57 AM
spotbot2k
spotbot2k - avatar
+ 2
For my experience is better to use SQL and put scripts into views
4th Mar 2017, 8:18 AM
Giampaolo Bolzonella
Giampaolo Bolzonella - avatar
+ 2
php and sql
4th Mar 2017, 10:00 AM
Ali Hasan
Ali Hasan - avatar
+ 2
I love SQL, it's not to complicated but you can get any level of complication you want. As long as you know what you do and optimize you are going to be fine. if you are getting problems developing you can use a program like Checkmarx to detect any code vulnerabilities and fix them. Good luck! Ben.
4th Mar 2017, 4:29 PM
Ben hart
+ 2
in my opinión you should work with PHP and SQl but in SQl you create procedures and triggers for it's help you with the security and efficiency in the DB
5th Mar 2017, 7:16 PM
Manuel jimenez
Manuel jimenez - avatar
+ 2
both :) because i think they're better working together.
5th Mar 2017, 9:21 PM
Oussama Bouchareb
Oussama Bouchareb - avatar