MySQL query SMF 2.0 RC5

Started by rocknroller, March 01, 2011, 07:58:00 AM

Previous topic - Next topic

rocknroller

sory, if similar topic there, please direct me.

i am php newbie, can someone write query to get content from database =>prefix_members=>ID-1 member row, "date_registered" field? Or direct me where the examples are and I will learn.

that is for SMF 2.0 RC5.


Arantor

For what purpose, exactly? Where is this going to go, because that affects how you're going to get the query.

rocknroller

Quote from: Arantor on March 01, 2011, 08:03:24 AM
For what purpose, exactly? Where is this going to go, because that affects how you're going to get the query.

i need get that number of seconds i think that

$var_name = value;

Arantor

Right, yes, it's a number of seconds. What are you getting it for and what are you going to use it for? This will tell me how I get you the data! You might use an existing query, you might even be given it already, but until I know what you're going to do with it I CANNOT HELP YOU.

rocknroller

i need variable just to get that value nothing else. i want to learn how to get it because i work with one exemple what it use that.

Arantor

OK, I'll say this one more time.

SMF is complicated. Very complicated. Information is gathered in many different places and amalgamated in different ways.

It's entirely possible that the registered date is already being gathered and made available but you didn't realise it already. It's also entirely possible that you can just reuse an existing query and just get the extra column. It's also possible you have to make a dedicated query for it.

So I could give you the column but it might not help you in the slightest if I do so. So, please, do me a favour and answer my question so I can answer yours.

rocknroller

Quote from: Arantor on March 01, 2011, 09:14:20 AM
OK, I'll say this one more time.

SMF is complicated. Very complicated. Information is gathered in many different places and amalgamated in different ways.

It's entirely possible that the registered date is already being gathered and made available but you didn't realise it already. It's also entirely possible that you can just reuse an existing query and just get the extra column. It's also possible you have to make a dedicated query for it.

So I could give you the column but it might not help you in the slightest if I do so. So, please, do me a favour and answer my question so I can answer yours.


I need new query, and i cant tell you what for. i want that VALUE just in that form, if you can not help me with this I'll learn to do that myself.

Arantor

The column value is date_registered.

But hey, let's hope your new query doesn't screw performance, eh. Meanwhile, I'll remember not to answer any of your support questions again because in trying to get you the best possible outcome for your code (i.e. the fastest, cleanest way of getting this data which is probably already being queried, or at the very least the area you're using probably already queries the members table anyway, you're adding a whole new query which slows it down), I've wasted my time trying to help you.

rocknroller

Quote from: Arantor on March 01, 2011, 10:17:58 AM
The column value is date_registered.

But hey, let's hope your new query doesn't screw performance, eh. Meanwhile, I'll remember not to answer any of your support questions again because in trying to get you the best possible outcome for your code (i.e. the fastest, cleanest way of getting this data which is probably already being queried, or at the very least the area you're using probably already queries the members table anyway, you're adding a whole new query which slows it down), I've wasted my time trying to help you.

hey, i can't tell you because that will be mod and i am not an author, and not on me to talk about it. do you understand? I was think you play with me, you a serious? do not be upset?  :) take it easy.

Arantor

I'm pissed off that I'm trying to help you to get the very best result you can get, and that all I've ended up doing is waste my time trying to help you achieve it the best way possible, because you wouldn't answer simple enough questions, that didn't have to be anything specific, just vague enough to let me know the area of code you were trying to modify.

But still, you know best, hope it works out for you.

rocknroller

ok, sorry. i am not that stupid to not apologize, if you still want help. This has to add line "forum is online x days"

<?php


global $smcFunc$context


$result $smcFunc['db_query'](''
  SELECT * 
  FROM {db_prefix}members  
  WHERE id_member = (int:id_member)'

  
  array( 
'id_member' => 1

); 


while ($row $smcFunc['db_fetch_assoc']($result)) {


   
$datum=$row['date_registered'];
   
$date1 $datum;
   
$date2 time();


$smcFunc['db_free_result']($result); 

$razlika=($date2-$date1);
$sekunde=$razlika/60;
$minute=$sekunde/60;
$sati=$minute/60;
$dana=$sati/24;


echo 
'<div>' round($dana) . ' dana od kada je ' $context['forum_name'] . ' online</div>';

?>

Arantor

Well, you could do it that way, though I'd suggest a much better method all round.

Why query this on every time that page is loaded? It's not like the age of the forum is going to change, so you might as well do it a much faster method, one that doesn't require any additional queries at all. Not a single extra query after it's set up.

Use phpMyAdmin, find the time for that user's date_registered. Then, go to smf_settings and add a new row, variable is 'forum_created', value is the timestamp you have.

Then go to Admin > Maintenance > Routine > Empty the file cache, to make sure it's properly set up.

Now, wherever SMF is loaded, you can use $modSettings['forum_created'] instead of having to query it. $modSettings is loaded automatically for you, and cached automatically too, so that's something you never have to worry about after you set it up.

rocknroller

;D damn!  You have right, this is much easier and better, i did not know to smf has that ability in mysql, it is been done in a few clicks thanks to you.   :)

Today i must install php on my local machine and start learn. O:)

cicka

I will go a little off topic here and my apologies for that.

Is there anything yo do not know about Smf Arantor? In the past days I have seen you reply to almost about anything with the correct answer. You have a very vast knowledge about coding and Smf. My congratulations :)

Advertisement: