PHP Wizards

From: Ken (SHIELDSIT)19 Apr 2011 16:41
To: Peter (BOUGHTONP) 35 of 101

(flower)

 

I am so pumped. I have the first form automated. That will save so much time it's unreal. There is so much room for process improvement here and this is going to be a big part of it!

 

Using CF I was able to grab the variables I needed that somehow eluded me using PHP.

 

Thanks Pete for making me aware of Railo!

From: Ken (SHIELDSIT)19 Apr 2011 18:25
To: Drew (X3N0PH0N) 36 of 101
You think that first one was bad? This is the one I'm working on now! Un-Fucking-Real!

code:
SELECT * FROM ProductionHeader WHERE ruhID='041811BD'; SELECT ID=rudID, Category=rudCategory, Seq=rudSeq, Type=rudType, [Product ID]=rudProductID, Description=rudDescrip, 
PcsPerPkg=rudPcsPerPkg, Tally=rudTally, UOM=rudBaseUnitID, Pieces=rudPieces, Volume=rudVolume, NetVolume=rudNetVolume, Cost=rudCost, AddedCost= rudAddedCost, MktValue=rudMarketValue, 
Total=rudTotal, NetThick=rudNetThick, NetWidth=rudNetWidth, NetLength=rudNetLength, NetType=rudVolType, LocationID=rudLocationID,rudFIFOVolume,rudForceCost,rudBoomID,prdLengthID=(SELECT prdLengthID FROM ProductMaster 
WHERE prdID=rudProductID) FROM ProductionDetail WHERE rudID='041811BD' AND rudCategory='Consumed' ORDER BY Seq; SELECT ID=rudID, Category=rudCategory, Seq=rudSeq, Type=rudType, [Product ID]=rudProductID, Description=rudDescrip, 
PcsPerPkg=rudPcsPerPkg, Tally=rudTally, UOM=rudBaseUnitID, Pieces=rudPieces, Volume=rudVolume, NetVolume=rudNetVolume, Cost=rudCost, AddedCost= rudAddedCost, MktValue=rudMarketValue, Total=rudTotal, NetThick=rudNetThick, 
NetWidth=rudNetWidth, NetLength=rudNetLength, NetType=rudVolType, LocationID=rudLocationID,rudFIFOVolume,rudForceCost,rudBoomID,prdLengthID=(SELECT prdLengthID FROM ProductMaster WHERE prdID=rudProductID) 
FROM ProductionDetail WHERE rudID='041811BD' AND rudCategory='Produced' ORDER BY Seq; SELECT uft.uftDocId, uft.uftFieldType, uft.uftValidation, Description = uft.uftCaption, Value = duf.dufValue FROM UserFieldTemplate uft 
LEFT JOIN DocumentUserFields duf ON duf.dufDocType = uft.uftDocType AND duf.dufSeq = uft.uftDocId AND duf.dufDocId='041811BD' WHERE uft.uftDocType='PRODUCTION' ORDER BY uft.uftDocId; SELECT ufvDocId, ufvSeq, Value=ufvValue, 
Description=ufvDescrip FROM UserFieldValues WHERE ufvDocType='PRODUCTION' ORDER BY ufvDocId, ufvSeq; SELECT dufDocType, dufDocID, dufSeq, dufValue FROM DocumentUserFields WHERE 1=0; SELECT *  
,tagParentProdID=ISNULL((SELECT MAX(p2.prdID) FROM ProductMaster p2 WHERE p1.prdThickID=p2.prdThickID AND ((isnull(p2.prdWidthID,'')='' AND isnull(tagHdrWidthID,'')='') or isnull(p2.prdWidthID,'')=tagHdrWidthID) 
AND ISNULL(p2.prdLengthID,'') = ISNULL(p1.prdLengthID,'') AND p1.prdSpeciesID=p2.prdSpeciesID AND p1.prdGradeID=p2.prdGradeID AND p1.prdSurfacingID=p2.prdSurfacingID  AND p1.prdStateID=p2.prdStateID 
AND ISNULL(p1.prdUsrAttribID,'')=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,'')  
AND p1.prdHidden=1),p1.prdID) FROM TagMaster INNER JOIN ProductMaster p1 ON p1.prdID=tagProductID WHERE tagSourceID='041811BD' AND tagSourceType='PRODUCTION' ORDER BY tagID,tagLineSeq; 
SELECT ProductID=rudProductID, LocationID=rudLocationID, Volume=SUM(rudVolume), Type=rudType FROM ProductionDetail WHERE rudID='041811BD' AND rudProductID<>'' AND rudCategory='Produced' 
AND rudType='Vol' GROUP BY rudProductID, rudLocationID, rudType; SELECT ProductID=rudProductID, LocationID=rudLocationID, Value=SUM(rudTotal), Type=rudType, rudCategory FROM ProductionDetail 
WHERE rudID='041811BD' AND rudProductID<>'' GROUP BY rudProductID, rudLocationID, rudType, rudCategory; SELECT 1 FROM DocumentNotesMaster WHERE dnmDocType='PRODUCTION' AND dnmDocID='041811BD'; 
SELECT DocType=dcmDocType, DocID=dcmDocID, Seq=dcmSeq, Type=dcmCostTypeID, Description=dcmDescrip, MachineID=dcmMachineID, SuppID=dcmSuppID,FundsID=dcmFundsTypeID, FundsRate=dcmFundsRate, Qty=dcmQty, 
CostRate=dcmRateID, Total=dcmTotal, Prorate=dcmProrate, ProductID=dcmProductID, [LineNo]=dcmLineNo FROM DocumentCostMaster WHERE dcmDocType='PRODUCTION' AND dcmDocID='041811BD' ORDER BY dcmSeq
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 :$