Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Web Design & Development Web Design & Development
Search Search
Search for:
Tech Support Guy > > >

Solved: MySql and phpMyAdmin query


(!)

allnodcoms's Avatar
allnodcoms   (Danny) allnodcoms is offline allnodcoms has a Profile Picture
Computer Specs
Member with 610 posts.
 
Join Date: Jun 2007
Location: Hertfordshire - England
Experience: Advanced
16-Jul-2012, 03:42 AM #16
Quote:
Originally Posted by JiminSA View Post
a) it doesn't handle a variable number of multiple elements (occurences)
Not with you mate, what are you trying to do?

If you can give me an example I'm sure we can work it out...

Danny
JiminSA's Avatar
JiminSA   (Jim) JiminSA is offline JiminSA has a Profile Picture
Computer Specs
Member with 1,734 posts.
THREAD STARTER
 
Join Date: Dec 2011
Location: Johannesburg South Africa
Experience: Intermediate
16-Jul-2012, 07:01 AM #17
When a vehicle in the database has been edited, I would like it to reflect in the record - i.e. by which user and at what time - by including 2 fields "agent" and "date_time", one occurrence for each time it's edited - which can happen n times i.e. a variable number of occurrences in the life of the record.

If SQL can handle that scenario, I'd love to know...
allnodcoms's Avatar
allnodcoms   (Danny) allnodcoms is offline allnodcoms has a Profile Picture
Computer Specs
Member with 610 posts.
 
Join Date: Jun 2007
Location: Hertfordshire - England
Experience: Advanced
16-Jul-2012, 08:53 AM #18
It can James, welcome to the world of database design.

I'd have a separate table called 'edits' or similar, this table has the name and timestamp, maybe a reason for the edit (?) and a reference to the main vehicle table that it refers to. Whenever the vehicle table is edited, you just create a new 'edits' entry and set the pointer to the vehicle entry's id.

Easy peasy!

Danny
JiminSA's Avatar
JiminSA   (Jim) JiminSA is offline JiminSA has a Profile Picture
Computer Specs
Member with 1,734 posts.
THREAD STARTER
 
Join Date: Dec 2011
Location: Johannesburg South Africa
Experience: Intermediate
16-Jul-2012, 10:56 AM #19
That can work!
All I need to do is SELECT * FROM editing_table WHERE recid = $row['id'] ORDER BY datestamp
or summat like that...
Then there are no limits on the number of edit transactions! - I like the way you roll Danny!
allnodcoms's Avatar
allnodcoms   (Danny) allnodcoms is offline allnodcoms has a Profile Picture
Computer Specs
Member with 610 posts.
 
Join Date: Jun 2007
Location: Hertfordshire - England
Experience: Advanced
16-Jul-2012, 10:59 AM #20
It's easy when you know how mate...

Danny
JiminSA's Avatar
JiminSA   (Jim) JiminSA is offline JiminSA has a Profile Picture
Computer Specs
Member with 1,734 posts.
THREAD STARTER
 
Join Date: Dec 2011
Location: Johannesburg South Africa
Experience: Intermediate
19-Jul-2012, 07:38 AM #21
Just a thought...
Danny, is there anything to stop me serialising an array into a row and then un-serialising it?
allnodcoms's Avatar
allnodcoms   (Danny) allnodcoms is offline allnodcoms has a Profile Picture
Computer Specs
Member with 610 posts.
 
Join Date: Jun 2007
Location: Hertfordshire - England
Experience: Advanced
19-Jul-2012, 10:36 AM #22
Er... Why?

Danny
JiminSA's Avatar
JiminSA   (Jim) JiminSA is offline JiminSA has a Profile Picture
Computer Specs
Member with 1,734 posts.
THREAD STARTER
 
Join Date: Dec 2011
Location: Johannesburg South Africa
Experience: Intermediate
19-Jul-2012, 11:26 AM #23
That way I could have a variable number of occurrences of items. i.e. by putting arrays into cells, no?
allnodcoms's Avatar
allnodcoms   (Danny) allnodcoms is offline allnodcoms has a Profile Picture
Computer Specs
Member with 610 posts.
 
Join Date: Jun 2007
Location: Hertfordshire - England
Experience: Advanced
19-Jul-2012, 11:34 AM #24
No mate, you can't put arrays into a table. Basically a table is an array. If you want to embed an array into a table you would do as you did with the edited entries: create another table an link each instance back to the parent table with an ID field.

Danny
JiminSA's Avatar
JiminSA   (Jim) JiminSA is offline JiminSA has a Profile Picture
Computer Specs
Member with 1,734 posts.
THREAD STARTER
 
Join Date: Dec 2011
Location: Johannesburg South Africa
Experience: Intermediate
19-Jul-2012, 01:28 PM #25
Aha! On the premise that a serialised array is just a data string, I thought it would be possible to put it into a cell and guess what? You can! Check this
Is this a case of the student teaching the mentor? No offense mate

Last edited by JiminSA; 19-Jul-2012 at 01:29 PM.. Reason: typo
allnodcoms's Avatar
allnodcoms   (Danny) allnodcoms is offline allnodcoms has a Profile Picture
Computer Specs
Member with 610 posts.
 
Join Date: Jun 2007
Location: Hertfordshire - England
Experience: Advanced
20-Jul-2012, 05:37 AM #26
Quote:
Originally Posted by JiminSA View Post
Is this a case of the student teaching the mentor? No offense mate
Er... No.

Technically the contents of a field is just a string of 1s and 0s, so you can (I repeat for emphasis - technically) put what you like in it. But to go back to my previous reply - Why? You lose the ability to query the data, you'd have to read it in, unpack it, look through it, pack it back up and shoe horn it back in there...

There are far more elegant ways of achieving the exact same thing without the use of power tools or large hammers

Danny
JiminSA's Avatar
JiminSA   (Jim) JiminSA is offline JiminSA has a Profile Picture
Computer Specs
Member with 1,734 posts.
THREAD STARTER
 
Join Date: Dec 2011
Location: Johannesburg South Africa
Experience: Intermediate
20-Jul-2012, 08:42 AM #27
There is a valid reason why I would like this facility...

The quick 'n dirty CMS I'm using for this vehicle database originally used this technique (Serialize/Unserialize) for the whole file. I decided that because this db will get very big (4-5 records added daily, ad infinitum) that it was time to go MySql...
Now then, each vehicle entry can have any number of photographs uploaded and associated with it, id's of which are placed in an array within the serialised record.

The CMS photo handling (add/delete/re-order etc.,) is all oriented to an array set up and is fairly complex - hence the desire to have an array within a MySql cell.

Hope that clarifies it a bit, mate and I hope you don't think I was being arrogant in my last entry - I don't pretend that I could teach an old dog like you anything new!!!

Last edited by JiminSA; 20-Jul-2012 at 08:48 AM..
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑