PDA

View Full Version : UPDATE phrase SET text='www.mybackup.com' WHERE varname='backup_server';


imported_silkroad
12-06-2009, 07:28 AM
Hello,

I have script that runs this command against the vB database to update one of the $vbphrases:

UPDATE phrase SET text='www.mybackup.com' WHERE varname='backup_server';

It updates the database just fine, and I can see the new phrase text in the AdminCP, but the old text still shows up in the output.

If I manually change the phrase text in the AdminCP it works fine; however if I do it from my one line MySQL UPDATE, it updates the dB but it does not seem to flush some cache or update right in the templates.

Is there another command I need to issue to flush a cache or something?

I am lost as to why the dB updates with my MySQL query but it does not work; but it works if I do it in the AdminCP.

Thanks.

--------------- Added 1260092793 at 1260092793 ---------------

Looking at phrase.php, I noticed that vB actually deleted the old phrase and inserts and new one, incrementing the phraseid and dateline (timestamp).

I guess that is the reason a simple UPDATE to the dB does not work.

kh99
12-06-2009, 07:51 AM
Looking at admincp/phrase.php, it looks like after it updates a phrase it redirects to admincp/language.php?do=rebuild. In the language.php "do == rebuild' section, it looks like it essentially does the following (without the HTML status stuff):

require_once(DIR . '/includes/adminfunctions_language.php');

$languages = fetch_languages_array();
foreach($languages AS $_languageid => $language)
{
build_language($_languageid);
}
build_language_datastore();


But I haven't tried it at all.


Looking at phrase.php, I noticed that vB actually deleted the old phrase and inserts and new one, incrementing the phraseid and dateline (timestamp).

I guess that is the reason a simple UPDATE to the dB does not work.

...or it could be that, I don't know.

imported_silkroad
12-06-2009, 08:22 AM
Thanks. I missed that in phrase.php.....

It is getting more complicated than I hoped, so I think it is better to shift gears and do this with a PHP Global instead of changing phrases, as you first suggested and I suspected.

--------------- Added 1260143196 at 1260143196 ---------------

OK, this code is done using plugin code:

[PHP] Server Check and Failover Code (http://www.unix.com/web-programming-web-2-0-mashups/125426-php-server-check-failover-code.html)

In case you need something like this .....