Help putting together SQL query

Started by 420Connect.co.uk, April 20, 2015, 11:19:49 AM

Previous topic - Next topic

420Connect.co.uk

Quote from: zilladotexe on April 21, 2015, 07:05:50 AM
Nope. Because you're using an array in that line, it needs the '=>' to pair the value to that key.

This line,
WHERE date = {string:date}',
is where you would change the operator, but since it's already looking for that exact string, you don't need to change it. Your SQL query is already correct :)

Aha, I see! .. Awesome! :)


& I've had a look through my database and found in {db_prefix}log_members a column called last_login with what appears to be their values stores in unix time stamp form?..

Could I in theory write out a similar command or edit the previous one so that it would also check if last_login => 1429488000 (04/20/2015 @ 12:00am in unix) to solve my mini-issue of awarding people who logged in yesterday with the badge?

:-[ Why must I want to complicate everything! :P

* Update *

I've actually just sorted my database by last_login and can see there isn't even that many people I would want to award the badge to, which I can do manually very easily! (Yey!)

this saves another tricky SQL command needed but it's good to know it would be possible should I think up something similar! :)


(Takes great pleasure in marking this one solved!  ;D)
www.420Connect.co.uk ~ A Social Network For The #CannabisCommunity ~ Come say "High" ;)

margarett

Just for future record:

Quote from: 420connect.info on April 21, 2015, 06:57:40 AM
& would anyone happen to know if I could find or if it even exists somewhere; a log of who had logged in yesterday?
(to award only members who logged in yesterday)
You would require some date manipulation in order to build a dynamic "yesterday". The easiest way is to subtract 86400 (the number of seconds in 24h to current time(), then spit out the formatted date and feed that to 'date' => $formatted_date
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

420Connect.co.uk

Nice one Bruno!
Hopefully I don't think of any more that have already passed, but glad to know it can be done!

It's amazing what you can do with PHP if it's all written correctly! :P
www.420Connect.co.uk ~ A Social Network For The #CannabisCommunity ~ Come say "High" ;)

JBlaze

Quote from: 420connect.info on April 21, 2015, 07:40:18 AM
It's amazing what you can do with PHP if it's all written correctly! :P

It's also amazing what you can with PHP when you want to be really devious >:D
Jason Clemons
Former Team Member 2009 - 2012

420Connect.co.uk

 ::) I've a habit of wanting to do things like that :P
www.420Connect.co.uk ~ A Social Network For The #CannabisCommunity ~ Come say "High" ;)

iain sherriff

Quote from: Kindred on April 20, 2015, 03:28:01 PM
Additionally, If you ARE using that query externally (e.g. from a php file) and requiring SSI, then you SHOULD be using the SMF db functions instead of directly pushing the query.

Kindred.....could you point me to a doc that explains "SMF db functions" please  ?
SMF 2.0.12

Illori

a start http://wiki.simplemachines.org/smf/Coding_Guidelines#Database_2

i am not sure exactly what kindred was refering to but that should get you started.

Kindred

specifically this: $smcFunc['db_query']
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

iain sherriff

SMF 2.0.12

Advertisement: