• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[ZNOTE] Cache

raf

Active Member
Joined
Jan 10, 2011
Messages
261
Reaction score
38
Location
Warsaw, PL
I've already added shop pulling offers from database instead of config.php array.

Now i'm working on adding, deleting and modifying offers. Adding works, offers also shows but only when i add new one. So whenever i go only on a admin_shop.php page, it doesn't show (cache is not caching).

This is a piece of code to show offers:

PHP:
<h1>Shop Offers</h1>
<?php
$cacheOut = new Cache('engine/cache/shop_offer');
if ($updateCache === true) {
  $shop_offersOut = fetchAllshop_offers();
  $cacheOut->setContent($shop_offersOut);
  $cacheOut->save();
} else {
  $shop_offersOut = $cacheOut->load();
}
if (isset($shop_offersOut) && !empty($shop_offersOut) && $shop_offersOut !== false) {
  ?>
  <table class="ui celled striped table" id="shop_offerTable">
    <thead>
      <tr>
        <th>Name</th>
                <th>Delete</th>
                <th>Update</th>
      </tr>
    </thead>
    <tbody>
      <?php
      foreach ($shop_offersOut as $shop_offer) {
      ?>
      <tr>
        <td><?php echo $shop_offer['description']; ?></td>
        <td>
          <form class="ui form" action="" method="POST">
            <input name="delete" type="hidden" value="<?php echo $shop_offer['id']; ?>">
            <input name="action" type="hidden" value="1">
            <input class="ui red mini submit button" type="submit" value="DELETE">
          </form>
        </td>
        <td>
          <form class="ui form" action="" method="POST">
            <input name="shop_offerId" type="hidden" value="<?php echo $shop_offer['id']; ?>">
            <input name="action" type="hidden" value="2">
            <input class="ui orange mini submit button" type="submit" value="UPDATE">
          </form>
        </td>
      </tr>
      <?php
      }
      ?>
    </tbody>
  </table>
  <?php
} else {
  ?>
  <h2>Currently no shop offers in database.</h2>
  <?php
} ?>
Which only works if i add item (after refresh it's gone again, but stays in database).
 
Solution
Lets see if the cache can write/update the cache file:

PHP:
$cacheOut = new Cache('engine/cache/shop_offer');
$cacheOut->setContent( fetchAllshop_offers() );
$cacheOut->save();

Does the file in engine/cache/shop_offer get updated? If not, it is missing write permissions.
Lets see if the cache can write/update the cache file:

PHP:
$cacheOut = new Cache('engine/cache/shop_offer');
$cacheOut->setContent( fetchAllshop_offers() );
$cacheOut->save();

Does the file in engine/cache/shop_offer get updated? If not, it is missing write permissions.
 
Solution
Back
Top