|
Joined: Jul 2021
Posts: 2
Lurker
|
Lurker
Joined: Jul 2021
Posts: 2 |
Hi, Is there any way of doing db update, delete and insert in a custom Islands?
|
|
|
|
Joined: Jan 2000
Posts: 5,834 Likes: 20
UBBDev Owner Time Lord
|
UBBDev Owner Time Lord
Joined: Jan 2000
Posts: 5,834 Likes: 20 |
You can execute database queries in Custom Islands by following the syntax we utilize in the software (examples in the scripts you'll likely find helpful); an example would be the Random Image island at UBBCentral (this code is posted on that forum as well): /* PHP CODE HERE */
$query = "
SELECT POST_ID, FILE_DIR, FILE_NAME
FROM {$config['TABLE_PREFIX']}FILES
WHERE (FILE_DIR <> '' AND FILE_DIR IS NOT NULL)
AND (FILE_TYPE = 'jpg'
OR FILE_TYPE = 'gif'
OR FILE_TYPE = 'jpg'
OR FILE_TYPE = 'jpeg'
OR FILE_TYPE = 'png')
ORDER BY rand()
LIMIT 1
";
$sth = $dbh->do_query($query, __LINE__, __FILE__);
list($postId, $fDir, $fName) = $dbh->fetch_array($sth);
/* BODY HERE */
$body = <<<EOF
<div class="acvt">
<div style="height:{$config['MAX_THUMB_W_H']}px;overflow:hidden;position:relative;width:100%;display:inline-block;">
<a href="{$config['BASE_URL']}/ubbthreads.php?ubb=showgallery&Number=$postId"><img src="{$config['BASE_URL']}/gallery/$fDir/medium/$fName" alt="" title="" class="p2 cp oi" style="position:absolute;left:-100%;right:-100%;top:-100%;bottom:-100%;margin:auto;max-width:280px;min-height:100%;"></a>
</div>
</div>
EOF; Please be sure that your islands are set to cache their output to a reasonable value as short timings may result in strain on your database server depending on traffic trends.
|
|
|
|
Joined: Jul 2021
Posts: 2
Lurker
|
Lurker
Joined: Jul 2021
Posts: 2 |
HI, We have two island that require a database updates, one is a game recruitment list with an two options to add or remove items from drop down lists, this requires and insert and delete. We also have an island that the users can generate dice rolls and the result is posted in the forum there in (so no cheating), this one generate a post and saves it. We have a few islands that just have lists of data like your random images, but we need to have the option to Update, Insert and Delete records, which do not appear work in an island. Currently these two islands are written in Perl and work fine, I've been tasked with converting all of our Perl scripts to PHP as more and more ISP no-longer support Perl.
Last edited by Tusk; 07/09/2021 1:09 AM.
|
|
|
|
Joined: Jan 2000
Posts: 5,834 Likes: 20
UBBDev Owner Time Lord
|
UBBDev Owner Time Lord
Joined: Jan 2000
Posts: 5,834 Likes: 20 |
I generally only do SQL queries to pull data and use forms to post to other scripts which do processing.
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 1,157
Joined: July 2001
|
|
Forums63
Topics37,575
Posts293,931
Members13,823
|
Most Online6,139 Sep 21st, 2024
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|