Ejemplo n.º 1
0
    /**
     * A stripped down version of the get_law() function.  Used by the Autolinker.
     */
    public function get_matching_sections($section, $edition_id, $fields = array())
    {
        static $select_statement;
        if (!isset($select_statement)) {
            $sql = 'SELECT id, catch_line FROM laws WHERE section = :section AND
				edition_id = :edition_id ORDER BY order_by';
            $select_statement = $this->db->prepare($sql);
        }
        $sql_args = array(':section' => $section, ':edition_id' => $edition_id);
        $select_result = $select_statement->execute($sql_args);
        if ($select_result === FALSE || $select_statement->rowCount() == 0) {
            return FALSE;
        } else {
            $permalink_obj = new Permalink(array('db' => $this->db));
            $laws = $select_statement->fetchAll(PDO::FETCH_OBJ);
            foreach ($laws as $key => $law) {
                $permalink = $permalink_obj->get_preferred($law->id, 'law', $edition_id);
                $laws[$key]->url = $permalink->url;
            }
            return $laws;
        }
    }