General Community > Scripting Help

SMF1 Trying to get Auto_increment value.

<< < (6/8) > >>

MrMorph:
Thanks for your explanation and it does do you credit that you look for problems like this.

I'll fill you in a bit about me.  I have been programming since I was 11; writing machine code on my ZX Spectrum; did O and A level computer science and studied Computer Science at University too learning wonderful languages like C and Modular 2 (most of which I have long forgotten about) and more recently I gained some Web developer & IT qualifications.  Now I am in my 40s and still enjoying it every day.

That's the short version.  But it's just to set your mind at ease a little really.  I have spent years writing, editing and designing code. To be fair I have only been working with PHP for maybe 5 years now, I still have stuff to learn.  I still have a lot to learn about the SMF system too and it's internals, but I really like the way both versions have been written.

Often rather than sift through the code and figure out what they did I simply ask if anyone knows how one bit works or why it doesn't work as expected.  Sometimes that's all I need to know.

I tend not to have tunnel vision when I code, but I know what you mean.  Currently I am spending hours on the security aspects of my mod and I will try not to leave a stone unturned.  I am never satisfied with the code I write unless it's something simple.

But I never considered myself an expert.  But I do try to do a proper job, there are no short-cuts here.  That's why I said I would take people's suggestions seriously and I did; it's just that some of them I was able to dismiss.  It won't stop me going back to look at it again though, now that you guys have pointed out some things to look at.

If you weren't there to pick up the pieces then you wouldn't have a job maybe lol ;)  But I get your point.

Yoshi:

--- Quote from: MrMorph on May 21, 2012, 08:15:52 AM ---
--- Quote from: Yoshi2889 on May 20, 2012, 03:12:05 PM ---
--- Quote from: Arantor on May 20, 2012, 03:06:33 PM ---So if the value isn't important, why bother going to the trouble of getting the auto-inc value in the first place?

--- End quote ---
Nice shot lol.

You need to provide more details as we might find an alternate solution then.

--- End quote ---

Nice shot ?  And from a 'support specialist' too !  I hope you guys are not going to get all superior and snide on me.
--- End quote ---
Nah not at all. I'm a noobie when it comes to MySQL, everybody knows that :P


--- Quote ---I'm curious; why do you all seem to think you can come up with an alternative solution when all you are doing is second guessing the nature of my project ?  What is the basis for your suggestions ?  It's nice that you care enough to make them though.
--- End quote ---
Because you won't get the trouble you have now with the alternate suggestion, at least that's what I hope/think.


--- Quote ---But all that was required was an answer to my original question.  Arantor did that with thanks.  I can assure you there is no need to worry about me screwing up my system.  I already said that the Auto_increment value is not critical in the sense you are all suggesting.  I understand what you are saying, but it has no bearing on this part of my code.  I really do not know what else I can say to stop you all worrying !
--- End quote ---
Then our answer is, if it's not important then why bother gathering it? It must have some meaning if you are gathering it right?

MrMorph:

--- Quote ---Nah not at all. I'm a noobie when it comes to MySQL, everybody knows that
--- End quote ---

Fair play, some times it's just not so easy to figure out how a comment is meant to be taken in plain text :)


--- Quote ---Because you won't get the trouble you have now with the alternate suggestion, at least that's what I hope/think.
--- End quote ---

OK, but I am not having trouble with my solution.  The trouble was I could not understand why $db_prefix was returning the result it did.   We are testing this thing btw...  ;)


--- Quote ---Then our answer is, if it's not important then why bother gathering it? It must have some meaning if you are gathering it right?
--- End quote ---

Hmmm, don't know how to answer this again... Yes it has meaning...maybe read over what you quoted again, that's the best answer I have come up with so far.

Yoshi:

--- Quote from: MrMorph on May 21, 2012, 09:57:26 AM ---
--- Quote ---Nah not at all. I'm a noobie when it comes to MySQL, everybody knows that
--- End quote ---

Fair play, some times it's just not so easy to figure out how a comment is meant to be taken in plain text :)
--- End quote ---
Yeah, plain text is plain stupid. :P


--- Quote ---
--- Quote ---Because you won't get the trouble you have now with the alternate suggestion, at least that's what I hope/think.
--- End quote ---

OK, but I am not having trouble with my solution.  The trouble was I could not understand why $db_prefix was returning the result it did.
--- End quote ---
I think it's doing this so you can use something like this:

--- Code: ---`database name`.`table_name`
--- End code ---
As Arantor (or osmeone else) already said, the SMF database is not loaded. Though I don't understand why it puts it in the prefix either.


--- Quote ---We are testing this thing btw...  ;)
--- End quote ---
I hoped so lmao


--- Quote ---
--- Quote ---Then our answer is, if it's not important then why bother gathering it? It must have some meaning if you are gathering it right?
--- End quote ---

Hmmm, don't know how to answer this again... Yes it has meaning...maybe read over what you quoted again, that's the best answer I have come up with so far.

--- End quote ---
Mmkay, but if we knew what ya want maybe we could provide a better or alternative solution so you don't have to fiddle with this.

Anyway I found this for ya:
http://stackoverflow.com/questions/933565/get-auto-increment-value-with-mysql-query

Maybe you can do something with that as it returns weird stuff for you.

MrMorph:

--- Quote ---I think it's doing this so you can use something like this:

--- Code: ---`database name`.`table_name`
--- End code ---
As Arantor (or osmeone else) already said, the SMF database is not loaded. Though I don't understand why it puts it in the prefix either.
--- End quote ---

Yep I think you and Arantor have that right.

With regard to SSI and the way it works there :

This does work for things like SELECT, whereby it attaches the database name and prefix (if any) to the query.  All well and good and all my SELECTS work as expected.

But where you need to perform a LIKE (ie a pattern match), then it won't work because it's not simply the prefix by itself, but also the database name.

In my case $db_prefix contains
--- Code: ---`smf1`.
--- End code ---

So when I do something like this :


--- Code: ---$result = db_query("
SHOW TABLE STATUS
FROM $db_name
LIKE '{$db_prefix}merc_message_log'"
, false, false);
--- End code ---

By the time it is interpreted the query string literally becomes this :


--- Code: ---SHOW TABLE STATUS FROM smf1 LIKE '`smf1`.merc_message_log'
--- End code ---

Which is not gonna work and indeed it doesn't.  At least this is what it seems like to me atm.

Thanks for that link, it's useful but I would still encounter the same problem.


--- Quote ---
--- Quote ---We are testing this thing btw...  ;)
--- End quote ---
I hoped so lmao
--- End quote ---

 :D Yeah this won't be finished for weeks, I am too much of a perfectionist !

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version