Welcome Guest, Not a member yet? Register   Sign In
Custom library extending custom libraries
#17

[eluser]patbert[/eluser]
I would say it must be. Look at this.

Code:
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');

class Listing extends Shared {

    public $type       = 'all';
    public $order      = 'title';
    public $direction  = 'asc';
    public $pagelength = 50;
    public $offset     = 1;

    public $total_rows;
    
    public $title_search;
    public $director_search;

    public $query;
    public $page_links;

    public $table;

    private $default_array = array('type',
                       'order',
                       'direction',
                       'pagelength',
                       'offset');

    public function get_list() {
        $wantedrows = array (
            'id_field',
            'title_name',
            'title_imdb_url',

            "$this->titletbl.disc_id",
            "$this->disctbl.disc_type_id",
            'disc_type_name',

            "$this->titletbl.director_id",
            'director_url',
            'director_name',

            "$this->titletbl.genre_id",
            'genre_name',

            "$this->titletbl.country_id",
            'country_code',
            'country_name',

            'title_imdb_rating',
            'title_imdb_year'
        );

        $orderby_array = array ('title' => 'title_name',
                   'director' => 'director_name',
                   'year' => 'title_imdb_year',
                   'rating' => 'title_imdb_rating',
                   'disc' => 'disc_id');
        
        $orderby_column = 'title_name';

        foreach ($orderby_array as $orderby_key => $orderby_name) {
            if ($this->order == $orderby_key) {
                $order_column = $orderby_name;
            };
        };

        $loop = 0;

        do {
            $this->ci->db->select($wantedrows, FALSE);
            $this->ci->db->from($this->titletbl);
            $this->ci->db->join($this->disctbl, "$this->titletbl.disc_id = $this->disctbl.disc_id", 'left');
            $this->ci->db->join($this->dsctptbl, "$this->disctbl.disc_type_id = $this->dsctptbl.disc_type_id", 'left');
            $this->ci->db->join($this->drctrtbl, "$this->titletbl.director_id = $this->drctrtbl.director_id", 'left');
            $this->ci->db->join($this->genretbl, "$this->titletbl.genre_id = $this->genretbl.genre_id", 'left');
            $this->ci->db->join($this->cntrytbl, "$this->titletbl.country_id = $this->cntrytbl.country_id", 'left');

            if (! empty($this->title_search)) {
                $this->ci->db->or_like('title_name', $this->title_search);
                $this->ci->db->or_like('title_name_alt', $this->title_search);
            } elseif (! empty($this->director_search)) {
                $this->ci->db->or_like('director_name', $this->director_search);
            };

            $this->ci->db->orderby($order_column, $this->direction);
            $this->ci->db->orderby('title_name');

            if ($loop == 1) {
                $this->ci->db->limit($this->pagelength, $this->offset);
            };

            $this->query = $this->ci->db->get();

            if ($this->query->num_rows() < 1) {
                echo 'No results, aborting';
                exit();
            };

            if ($loop == 0) {
                $totalrows = $this->query->num_rows();
            };
            $loop++;
        } while ($loop != 2);

        $this->total_rows = $totalrows;

        $this->make_page_links();
    }
}

Again, there is more to that class, but it runs fine and it is reading lots of things from Shared.php that were declared in Shared's __construct() function.


Messages In This Thread
Custom library extending custom libraries - by El Forum - 03-31-2008, 05:36 AM
Custom library extending custom libraries - by El Forum - 03-31-2008, 05:40 AM
Custom library extending custom libraries - by El Forum - 03-31-2008, 05:42 AM
Custom library extending custom libraries - by El Forum - 03-31-2008, 05:43 AM
Custom library extending custom libraries - by El Forum - 03-31-2008, 05:46 AM
Custom library extending custom libraries - by El Forum - 03-31-2008, 05:52 AM
Custom library extending custom libraries - by El Forum - 03-31-2008, 06:21 AM
Custom library extending custom libraries - by El Forum - 03-31-2008, 07:31 AM
Custom library extending custom libraries - by El Forum - 05-03-2008, 02:12 PM
Custom library extending custom libraries - by El Forum - 05-03-2008, 02:37 PM
Custom library extending custom libraries - by El Forum - 05-03-2008, 02:42 PM
Custom library extending custom libraries - by El Forum - 05-03-2008, 02:48 PM
Custom library extending custom libraries - by El Forum - 05-03-2008, 02:54 PM
Custom library extending custom libraries - by El Forum - 05-03-2008, 03:02 PM
Custom library extending custom libraries - by El Forum - 05-03-2008, 03:45 PM
Custom library extending custom libraries - by El Forum - 05-03-2008, 03:58 PM
Custom library extending custom libraries - by El Forum - 05-03-2008, 04:06 PM
Custom library extending custom libraries - by El Forum - 05-03-2008, 04:13 PM
Custom library extending custom libraries - by El Forum - 05-03-2008, 04:20 PM
Custom library extending custom libraries - by El Forum - 05-03-2008, 04:39 PM
Custom library extending custom libraries - by El Forum - 05-03-2008, 04:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB