PHP Wizards

From: Ken (SHIELDSIT)19 Apr 2011 19:06
To: Peter (BOUGHTONP) 37 of 101
Any idea how their software does the above SELECT Statement and it's what I captured on the SQL Server but when I try to execute it outside of their software it tells me these aren't defined?
code:
=ISNULL(p2.prdUsrAttribID,'') AND ISNULL(p1.prdUsrAttribID2,'')=ISNULL(p2.prdUsrAttribID2,'') AND ISNULL(p1.prdUsrAttribID3,'')=ISNULL(p2.prdUsrAttribID3,'')  
AND ISNULL(p1.prdUsrAttribID4,'')=ISNULL(p2.prdUsrAttribID4,'') AND ISNULL(p1.prdUsrAttribID5,'')=ISNULL(p2.prdUsrAttribID5,'')  AND ISNULL(p1.prdUsrAttribID6,'')=ISNULL(p2.prdUsrAttribID6,'') 
AND ISNULL(p1.prdUsrAttribID7,'')=ISNULL(p2.prdUsrAttribID7,'')  AND ISNULL(p1.prdUsrAttribID8,'')=ISNULL(p2.prdUsrAttribID8,'') AND ISNULL(p1.prdUsrAttribID9,'')=ISNULL(p2.prdUsrAttribID9,'')
EDITED: 19 Apr 2011 19:06 by SHIELDSIT
From: Ken (SHIELDSIT)19 Apr 2011 19:17
To: Peter (BOUGHTONP) 38 of 101
Disregard, I have that mother fucker working!
From: af (CAER)20 Apr 2011 09:45
To: Ken (SHIELDSIT) 39 of 101
This is why I like ORMs.
From: Ken (SHIELDSIT)20 Apr 2011 11:50
To: af (CAER) 40 of 101
What's ORMs?
From: af (CAER)20 Apr 2011 11:51
To: Ken (SHIELDSIT) 41 of 101
From: Ken (SHIELDSIT)20 Apr 2011 11:59
To: af (CAER) 42 of 101
I don't think I'm smart enough for that. OO confuses the hell out of me. That's why I stick with a BASIC like language that flows from top to bottom!
From: Peter (BOUGHTONP)20 Apr 2011 12:00
To: Ken (SHIELDSIT) 43 of 101
ORM is a way for people doing things wrong to make it easier to keep doing things wrongly. :P

From: af (CAER)20 Apr 2011 12:10
To: Ken (SHIELDSIT) 44 of 101
It does make things a lot easier, as you don't have to use SQL - you interact with the database in terms of the language you're using to write the applications. For example, Rails lets you do stuff like:
ruby code:
Post.destroy_all :user => User.find_by_email("andy@caerphoto.com")
From: Peter (BOUGHTONP)20 Apr 2011 12:10
To: Ken (SHIELDSIT) 45 of 101
When you strip away all the crap, OO itself isn't that bad. (Though it's also not the One True Path.)

It's all the unnecessary over-complicated crap, like ORM and silly design patterns and so on, that makes it seem scary.
From: steve20 Apr 2011 12:15
To: af (CAER) 46 of 101
That looks even more complicated :$
From: Peter (BOUGHTONP)20 Apr 2011 12:16
To: af (CAER) 47 of 101
If you don't want to use SQL, don't use a database that runs on SQL! ( :O )
From: af (CAER)20 Apr 2011 13:21
To: steve 48 of 101
Than what? I'm not sure what the corresponding SQL would look like but I'm pretty sure it'd be more complicated than that.
From: Peter (BOUGHTONP)20 Apr 2011 13:57
To: af (CAER) 49 of 101
quote:
I'm pretty sure it'd be more complicated

I'm not...

sql code:
DELETE Post WHERE Creator = findUserByEmail('andy@caerphoto.com')
From: af (CAER)20 Apr 2011 14:17
To: Peter (BOUGHTONP) 50 of 101
Will that also trigger any callbacks set up in the Post model, for example if it's the last Post being deleted, also delete the associated Thread?

And what is this 'findUserByEmail' function?
From: Ken (SHIELDSIT)20 Apr 2011 14:27
To: Peter (BOUGHTONP) 51 of 101
Pete are you up for a complicated question?
From: Peter (BOUGHTONP)20 Apr 2011 14:36
To: af (CAER) 52 of 101
Yes, of course, (because that's how my imaginary SQL database has been configured to react).

(It's been possible to do triggers with databases for years, long before Rails came along. Probably even before Ruby too.)


It's a function (stored procedure), just like your User.findByEmail one. It's automatically generated by another one of those triggers - every time a table is created or altered - so it's faster than doing dynamic lookups with Method Missing.
From: Peter (BOUGHTONP)20 Apr 2011 14:39
To: Ken (SHIELDSIT) 53 of 101
If it's a quick complicated one... I'm supposed to be finishing something off at the moment, but keep getting distracted by that dastardly Rails fan. :@
From: af (CAER)20 Apr 2011 14:40
To: Peter (BOUGHTONP) 54 of 101
Well now, that's interesting.

I'd best not get too involved in this as I really don't know all that much :$
From: Peter (BOUGHTONP)20 Apr 2011 14:46
To: af (CAER) 55 of 101
The difference is, nobody has actually created a popular framework for all this stuff (well, not that I'm aware of), but the ability to do it is there.

Very little (if any) of the stuff that Rails (or others) is new - it's all been possible for decades, but either computers were too slow, or it just didn't get used in mainstream until someone actually shouted about it.
From: af (CAER)20 Apr 2011 14:48
To: Peter (BOUGHTONP) 56 of 101
Hmm. Why's nobody made a popular framework for it? Is that sort of thing possible in SQL? Man I really don't know much about server things :$