Resend my activation email : Register : Log in 
BCF: Bike Chat Forums


Any mySQL experts?

Reply to topic
Bike Chat Forums Index -> Random Banter
View previous topic : View next topic  
Author Message

Jayy
Mr. Ponzi



Joined: 08 Jun 2009
Karma :

PostPosted: 14:08 - 01 Apr 2011    Post subject: Any mySQL experts? Reply with quote

I have a slight problem that I'm unable to solve, as I don't know the query I would need to run in mySQL. Basically, I have moved a Joomla site over to a testing server whilst I upgrade the site and it has the HWDvideoshare plugin running. The problem is, on the old server, the site was installed to /joomla and now I've moved it to my testing server, it's in the root directory.

All the video thumbnails are looking for /joomla/hwdvideos/thumbs/ when I need them to be in /hwdvideos/thumbs/

You might think, why don't I just create that folder? If I do that, all the thumbs show up but it causes problems when uploading new videos.

I was thinking all I need to do is a run a mySQL query in phpmyadmin to change all the paths? I changed the first two (ID 12,13) manually and it's all working fine but there's 450 of them...

I've attached a screen shot of the database, does anyone know what query I can run to change every path in the 'thumbnail' table to reflect the right path without the /joomla/ ?
 Back to top
View user's profile Send private message You must be logged in to rate posts

angryjonny
World Chat Champion



Joined: 01 Sep 2006
Karma :

PostPosted: 14:18 - 01 Apr 2011    Post subject: Reply with quote

Dunno about MySQL but (assuming you need the "/" up front) in Oracle it would be:

update jos_hwdvidscategories set thumbnail = substr(thumbnail, 8)
where substr(thumbnail, 1, 7) = '/joomla'

That'll leave the ones that don't start with /joomla alone.

But it's Oracle. Not MySQL. So the answer to your question is "no", I guess.

Whatever you do, run a select first to see what the effect would be.
 Back to top
View user's profile Send private message You must be logged in to rate posts

elky
Renault 5 Driver



Joined: 05 Aug 2010
Karma :

PostPosted: 14:21 - 01 Apr 2011    Post subject: Reply with quote

I've not got any access to mySQL at the minute, but it should be something like:

UPDATE jos_hwdvidcategories
SET thumbnail = SUBSTR(thumbnail,11,100);

So effectively just deleting the first 11 characters of the thumbnail (100 is just a big number to ensure you capture the full file name)

Do a select first though to make sure you have the sub string set correctly.

SELECT SUBSTR(thumbnail,11,100) FROM jos_hwdvidcategories;
 Back to top
View user's profile Send private message You must be logged in to rate posts

supZ
World Chat Champion



Joined: 03 Feb 2009
Karma :

PostPosted: 14:21 - 01 Apr 2011    Post subject: Reply with quote

unfortunately i use mssql not mysql but you will be able to get that done by using a replace command and updating the record.

MS SQL:

Code:

UPDATE jos_hwdvidscategories
SET thumbnail= REPLACE(thumbnail,'/joomla/hwdvideos/thumbs/','/hwdvideos/thumbs/')


i cant imagine the mysql version being much different. have a google Smile

you can of course just replace /joomia/ with / if you want too as the folder structure is the same bar that dir

edit:
just checked myself and it looks like its the same syntax
____________________
CBR954RR - Daily toy
CBR600RR - Trackbike
 Back to top
View user's profile Send private message You must be logged in to rate posts

mjn51
Traffic Copper



Joined: 04 Feb 2011
Karma :

PostPosted: 14:31 - 01 Apr 2011    Post subject: Reply with quote

As with the other replies
SUBSTRING(str FROM pos FOR len)


this may help :-
https://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_substring
 Back to top
View user's profile Send private message You must be logged in to rate posts

Jayy
Mr. Ponzi



Joined: 08 Jun 2009
Karma :

PostPosted: 14:37 - 01 Apr 2011    Post subject: Reply with quote

What's the difference between supZ and the other methods?
 Back to top
View user's profile Send private message You must be logged in to rate posts

angryjonny
World Chat Champion



Joined: 01 Sep 2006
Karma :

PostPosted: 14:40 - 01 Apr 2011    Post subject: Reply with quote

Recoil Jay wrote:
What's the difference between supZ and the other methods?

Different function, same result, really.
 Back to top
View user's profile Send private message You must be logged in to rate posts

Jayy
Mr. Ponzi



Joined: 08 Jun 2009
Karma :

PostPosted: 14:44 - 01 Apr 2011    Post subject: Reply with quote

Good stuff... I'm such a retard, I thought, "I'll backup the database now and run some of these queries". Started clicking on things in the database and nothing was working, 5 minutes later, I was clicking the screenshot I uploaded in this topic Embarassed
 Back to top
View user's profile Send private message You must be logged in to rate posts

Jayy
Mr. Ponzi



Joined: 08 Jun 2009
Karma :

PostPosted: 14:52 - 01 Apr 2011    Post subject: Reply with quote

supZ, worked a treat! Saved me about 4 hours of manual labour there! Same to the others, thanks for the help, much appreciated.

Karma
 Back to top
View user's profile Send private message You must be logged in to rate posts

supZ
World Chat Champion



Joined: 03 Feb 2009
Karma :

PostPosted: 15:11 - 01 Apr 2011    Post subject: Reply with quote

np Smile

yeh the other examples basically removed the beginning of the string, getting rid of the extra bit you didnt need (the /joomlia bit) whereas my example replaced the text within the string.

my example will work even if you want to replace/remove some text in the middle of the string. substring can work the same way but you need to define the start and end of the portion of the string you're changing rather than looking for an occurance of the part of the string you're looking for

and LMAO @ the screenshot Very Happy
____________________
CBR954RR - Daily toy
CBR600RR - Trackbike
 Back to top
View user's profile Send private message You must be logged in to rate posts

Kickstart
The Oracle



Joined: 04 Feb 2002
Karma :

PostPosted: 15:16 - 01 Apr 2011    Post subject: Reply with quote

Hi

Would probably have been easiest to use substring_index:-

Code:
UPDATE sometable
SET somecolumn = SUBSTRING_INDEX(somecolumn,'/joomla',-1)
WHERE somecolumn LIKE '/joomla%'


Or just using SUBSTR:-

Code:
UPDATE sometable
SET somecolumn = SUBSTR(somecolumn,8)
WHERE somecolumn LIKE '/joomla%'


This works as SUBSTR will return the rest of the string if you just give a starting point.

All the best

Keith
____________________
Traxpics, track day and racing photographs - Bimota Forum - Bike performance / thrust graphs for choosing gearing
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

Jayy
Mr. Ponzi



Joined: 08 Jun 2009
Karma :

PostPosted: 15:28 - 01 Apr 2011    Post subject: Reply with quote

supZ method worked perfectly, will bare these posts in mind next time I need to do this. I have a good knowledge of mySQL, been developing sites with content management and e-commerce for years but sometimes it goes over my head.
 Back to top
View user's profile Send private message You must be logged in to rate posts

Jayy
Mr. Ponzi



Joined: 08 Jun 2009
Karma :

PostPosted: 15:30 - 01 Apr 2011    Post subject: Reply with quote

I posted the same thing on the Joomla forums, it had 160 views in about half an hour and not one person replied.

BCF ftw Thumbs Up
 Back to top
View user's profile Send private message You must be logged in to rate posts
Old Thread Alert!

The last post was made 15 years, 164 days ago. Instead of replying here, would creating a new thread be more useful?
  Display posts from previous:   
This page may contain affiliate links, which means we may earn a small commission if a visitor clicks through and makes a purchase. By clicking on an affiliate link, you accept that third-party cookies will be set.

Post new topic   Reply to topic    Bike Chat Forums Index -> Random Banter All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Read the Terms of Use! - Powered by phpBB © phpBB Group
 

Debug Mode: ON - Server: birks (www) - Page Generation Time: 0.08 Sec - Server Load: 0.77 - MySQL Queries: 13 - Page Size: 75.37 Kb