CSI: PHP

"Looking at your tweets I cannot even fathom what your job is. CSI:PHP?" — @grmpyprogrammer

No, Let's Get ALL the Content at the Same Time!

| Comments

And let’s store it all in session! What’s more, if there’s a database error, let’s go ahead and let the users know about it with echo! Brilliant!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php

class BestCmsContentClassEvar
{
    protected function get_content()
    {
        $sql = 'select * from content order by id;';
        $result = $this->run_query($sql);
        //echo('looking for content');
        $i = 0;
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            if ($row['location'] == 'inc') {
                $_SESSION['content_name'][$i] = $row['name'];
                $_SESSION['content_title'][$i] = $row['title'];
                $_SESSION['content'][$i] = 'inc';
            } else {
                $_SESSION['content_name'][$i] = $row['name'];
                $_SESSION['content_title'][$i] = $row['title'];
                $_SESSION['content'][$i] = $row['content'];
            }
            $i++;
        }
        echo(mysql_error());
        mysql_close();
    }
}

UPDATE: Thanks to @Rob_OEM for the image below. It gave me the lulz.

Comments