PDA

View Full Version : Database fields


CooganA
03-13-2007, 02:28 PM
Hiya

Anyone know what the database table names are and what the fields are?

Anyone have a list of this anywhere? I just want to know which field contains the true/false value for the board being on/offline.

Thanks
Adam

Marco van Herwaarden
03-13-2007, 02:54 PM
That is stored in 2 tables: setting & datastore

nexialys
03-13-2007, 04:08 PM
basically, there is a "setting" table that store "officially" the settings you set on the adminCP... but in the essence, these settings are stored in the cache called "datastore", so they are loaded quicly at the startup of the process... they can also be stored in the datastore_file if you decide to store them in file... (complicated part)...

even if you edit the "setting" table with your proper detail, the board will continue to read the datastore element only, so you have to enter your admincp and save a setting to make the update.

CooganA
03-13-2007, 04:21 PM
I'm new to PHP, so how would I update the datastore database? Does anyone have a little example of updating a table?

And do you know what the field name for the Turn On/Off setting would be?

Thanks
Adam

Marco van Herwaarden
03-14-2007, 08:57 AM
Please see: http://www.vbulletin.com/forum/showthread.php?t=213135

CooganA
03-14-2007, 09:47 AM
Hi

After lots of trial and error, I finally hacked together some code that turned the board off/on.

Looking at the link you sent me, the code looks a lot cleaner then the one I put together last night.

But all i'm just getting an error:
Parse error: parse error, unexpected T_STRING in myfile.php on line 3

This is the code I'm now trying to use, if you want a laugh the code I hacked together is below that.

require_once(DIR . '/includes/adminfunctions_misc.php');
$query1 = sprintf("UPDATE datastore SET data=REPLACE(data,'"bbactive";i:1;','"bbactive";i:0;') WHERE title='options'");
$query2 = sprintf("UPDATE setting SET value=0 WHERE varname='bbactive'");
mysql_query($query1);
mysql_query($query2);
?>


My hacked code:

<?php
// ########################## REQUIRE BACK-END ############################

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


// Formulate Query
// This is the best way to perform a SQL query
// For more examples, see mysql_real_escape_string()
$query = sprintf("SELECT data FROM datastore WHERE title='options'");

// Perform Query
$result = mysql_query($query);

if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
/**/ if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
print_r($row);
print "<BR><BR><BR>";
Print $result[data];
$tempDataStore = str_replace('"bbactive";i:1;','"bbactive";i:0;', $row['data']);
Print $tempDataStore;
// echo $row['data'];
}
}

mysql_free_result($result);

$query = sprintf("UPDATE datastore SET data = '$tempDataStore;' WHERE title='options'");

// Perform Query
$result = mysql_query($query);

?>

Marco van Herwaarden
03-14-2007, 09:58 AM
Is that the full myfile.php?

PS Why do you use sprintf() to assign a variable?

CooganA
03-14-2007, 10:04 AM
Yup, thats the full file at the moment.

The reason I use sprintf() is becuase it seemed to work last night on the code I use. I'm not a PHP developer and this is the first time I've ever had to use PHP.

I'm a Coldfusion and Actionscript 2 developer... so this is all foreign to me at the moment. So any help is grantful!!

Marco van Herwaarden
03-14-2007, 10:42 AM
Could you please copy&paste the full error message, as i don't see a line 3 in your code.

CooganA
03-14-2007, 11:13 AM
This is line 3:
$query1 = sprintf("UPDATE datastore SET data=REPLACE(data,'"bbactive";i:0;','"bbactive";i:1;') WHERE title='options'");


<?php
require_once(DIR . '/includes/adminfunctions_misc.php');
$query1 = sprintf("UPDATE datastore SET data=REPLACE(data,'"bbactive";i:0;','"bbactive";i:1;') WHERE title='options'");
$query2 = sprintf("UPDATE setting SET value=1 WHERE varname='bbactive'");
mysql_query($query1);
mysql_query($query2);
?>

Marco van Herwaarden
03-14-2007, 11:19 AM
change it to:
$query1 = "UPDATE datastore SET data=REPLACE(data,'\"bbactive\";i:0;','\"bbactive\";i:1;') WHERE title='options'";

Or even better:
$query1 = "UPDATE " . TABLE_PREFIX . "datastore SET data=REPLACE(data,'\"bbactive\";i:0;','\"bbactive\";i:1;') WHERE title='options'";

CooganA
03-14-2007, 12:14 PM
I'm now getting this error... with both suggestions.

Warning: main(DIR/includes/adminfunctions_misc.php) [function.main]: failed to open stream: No such file or directory in /home/chat/public_html/forums/turnon.php on line 2

Fatal error: main() [function.require]: Failed opening required 'DIR/includes/adminfunctions_misc.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/chat/public_html/forums/turnon.php on line 2

Marco van Herwaarden
03-14-2007, 12:24 PM
You must include ./global.php before you can use any of the other vBulletin includes/functions.

CooganA
03-14-2007, 03:23 PM
When including ./global.php I seem to get an error when running these as scheduled tasks. But seems to work ok without them. Tho the scheduled task only runs if I click "run now" and doesn't work when a time is set.

Thanks
Adam

Marco van Herwaarden
03-15-2007, 06:38 AM
If run as a Scheduled Task, you do not need to include global.php, this is done automatic.