Do You Use SQL or ORM For Database Queries?

Discussion Of All Legal Topics Is Fine Anything Goes. Be Respectful of Others. No Personal Information or Attacks.
All Traffic, Link, Banner, Push Notification and Advertising, Offers & Requests Here,.
Domains & Websites For Sale and Requests Here.
Keep One thread per person & No More Than 1 Weekly Bump.
Post Reply
sebflo
Verified Member
Verified Member
Posts: 138
Joined: October 9th, 2018, 1:16 pm

Do You Use SQL or ORM For Database Queries?

#1

Post by sebflo » October 23rd, 2018, 4:37 pm

I have used both but gravitate to SQL instead of ORM.

I don't think there are performance benefits to ORM but its does look a lot cleaner in code when not using SQL stored procedures.

What do you use for your applications?

I generally just use SQL in code, and use stored procedures in code for the very heavy queries. A lot of my queries are now handled by LAMBDA functions and simply return JSON from an endpoint with all the joins being done as a stored procedure.




User avatar
T.B.W
Verified Member
Verified Member
Posts: 1152
Joined: March 26th, 2018, 1:34 pm

#2

Post by T.B.W » October 25th, 2018, 8:44 am

No clue what ORM is to be honest




sebflo
Verified Member
Verified Member
Posts: 138
Joined: October 9th, 2018, 1:16 pm

#3

Post by sebflo » October 25th, 2018, 12:40 pm

T.B.W wrote: ↑
October 25th, 2018, 8:44 am
No clue what ORM is to be honest
ORM (Object-relational mapping) is essentially a different way of accessing data from a database in OOP languages, can be used with or without frameworks but are very popular with web frameworks such as Laravel and Codeigniter.

Here is a php example using SQL in code, and an example using php with ORM in code.

ORM

Code: Select all

//Gets list of titles, and names from roles table
$roles = DB::table('roles')->pluck('title', 'name');

//Returns data from database
return $roles;
Standard SQL

Code: Select all

//Gets list of titles, and names from roles table
$roles = $db->prepare("SELECT roles.title, roles.name FROM roles" );

//Executes query
$roles->execute();

//Fetch Data As Array
$roles = $roles->fetchAll(PDO::FETCH_ASSOC);

//Returns data from database
return $roles;
Standard SQL With Stored Procedure

Code: Select all

//Gets list of titles, and names from roles table
$roles = $db->prepare("CALL: get_names_and_tables(?)" );

//Executes query
$roles->execute(array(null));

//Fetch Data As Array
$roles = $roles->fetchAll(PDO::FETCH_ASSOC);

//Returns data from database
return $roles;




User avatar
LuKenGas
Verified Member
Verified Member
Posts: 2209
Joined: February 23rd, 2018, 8:07 am

#4

Post by LuKenGas » October 26th, 2018, 2:00 pm

Good shit sebflo




sebflo
Verified Member
Verified Member
Posts: 138
Joined: October 9th, 2018, 1:16 pm

#5

Post by sebflo » October 26th, 2018, 6:00 pm

LuKenGas wrote: ↑
October 26th, 2018, 2:00 pm
Good shit sebflo
Glad you liked it :D




User avatar
bestfreeporn
Verified Member
Verified Member
Posts: 2308
Joined: February 20th, 2018, 6:34 pm
Referrals: 1

#6

Post by bestfreeporn » October 27th, 2018, 9:16 am

Which is faster in reality




User avatar
koster
Verified Member
Verified Member
Posts: 954
Joined: June 25th, 2018, 4:42 am
Contact:

#7

Post by koster » October 29th, 2018, 9:21 am

I am a sql guy and not had a chance to try anything else for databases. But I am open to ideas.




sebflo
Verified Member
Verified Member
Posts: 138
Joined: October 9th, 2018, 1:16 pm

#8

Post by sebflo » October 29th, 2018, 2:24 pm

bestfreeporn wrote: ↑
October 27th, 2018, 9:16 am
Which is faster in reality
For workflow speed, I think ORM is faster when it comes to most workflows.

However for performance, stored procedures will be faster (not going to notice until system is under heavy load).




CTE
Verified Member
Verified Member
Posts: 611
Joined: March 13th, 2018, 3:31 pm

#9

Post by CTE » October 30th, 2018, 9:05 am

Mysql is here to stay as long as WordPress uses it.

My 1 peso




sebflo
Verified Member
Verified Member
Posts: 138
Joined: October 9th, 2018, 1:16 pm

#10

Post by sebflo » October 30th, 2018, 11:50 am

CTE wrote: ↑
October 30th, 2018, 9:05 am
Mysql is here to stay as long as WordPress uses it.

My 1 peso
SQL is definitely here to stay, Wordpress for the most part uses MySQL but you can technically use any SQL engine out there, Maria DB, Amazon Aurora, Postgresql.

NoSQL databases started to make some noise but with MySQL 8 adding json data types I think they killed the game.

ORM just makes SQL syntax a lot cleaner regardless of what SQL database you are using (MySQL, Postgresql, MsSQL, Etc). Personally I use a lot of stored procedures instead of ORM but I do thing ORM makes code look a lot cleaner.

The only issue I have faced with MySQL is it's indexing system is a bit slow for very heavy database applications (500+ Million Records with multiple tables). Even with foreign keys and all the optimization standards, it can get laggy. Of course there is always a solution and there are plenty of solutions for SQL indexing and searching, I have been a fan of http://sphinxsearch.com however there are plenty of other options out there.

Here is a popular SQL, ORM Framework: https://www.doctrine-project.org




User avatar
pussyhunter
Verified Member
Verified Member
Posts: 959
Joined: July 13th, 2018, 3:40 am

#11

Post by pussyhunter » November 3rd, 2018, 12:55 pm

SQL not tried ORM and see no reason to stop using SQL, it works just fine and dandy and is fast.




monsta
Verified Member
Verified Member
Posts: 1459
Joined: March 21st, 2018, 3:37 pm

#12

Post by monsta » November 4th, 2018, 3:43 pm

Going to read up on ORM in a bit see what it does




User avatar
britporn_mike
Verified Member
Verified Member
Posts: 1134
Joined: May 3rd, 2018, 2:43 pm

#13

Post by britporn_mike » November 6th, 2018, 9:25 am

Less code = good news to my ears, means faster page load speeds.




User avatar
killah
Verified Member
Verified Member
Posts: 1225
Joined: March 7th, 2018, 6:18 pm

#14

Post by killah » November 7th, 2018, 4:23 pm

So what are the main advantages of using ORM over SQL

born2bewild
Verified Member
Verified Member
Posts: 1655
Joined: May 22nd, 2018, 6:47 pm
Title: work hard play hard

#15

Post by born2bewild » November 9th, 2018, 10:43 am

SQL not ever tried ORM




Do You Use SQL or ORM For Database Queries?

Post Reply