Book Image

concrete5 Beginner's Guide

Book Image

concrete5 Beginner's Guide

Overview of this book

Table of Contents (19 chapters)
concrete5
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – creating package model


Carry out the following steps:

  1. In our package c5book, create a new folder named models if it doesn't already exist. Within that folder, create a new file named broken_links.php.

    <?php
    defined('C5_EXECUTE') or die(_("Access Denied."));
    
    class BrokenLinks {
      public static function add($cID, $link, $statusCode, $statusName) {
          $db = Loader::db();
    
          $values = array($cID, $link, $statusCode, $statusName);
          $db->Execute('INSERT INTO btLinkChecker (cID, link, linkStatusCode, linkStatusName) VALUES (?,?,?,?)', $values);
       }
    
       public static function deleteAll() {
          $db = Loader::db();
          
          $db->Execute('DELETE FROM btLinkChecker');
       }
    
       public static function getBrokenLinks($includeDetails=true) {
          $query = 'SELECT * FROM btLinkChecker WHERE linkStatusCode NOT IN (200,302) OR linkStatusCode IS NULL';
          return BrokenLinks::getLinksInternal($query, $includeDetails);
       }
    
       public static function getAllLinks...