خرید بک لینک

Vote count: 0

I'm trying to follow a tutorial here which is just a simple helloworld that pulls data from a database.

I have never used codeigniter before, but I wanted to try a framework.

Anyways, I think I followed the tutorial correctly (I do think the tutorial uses a slightly older version of codeigniter as some of the paths are a bit different) but I caot get this to work, it gives me the error The page you requested was not found.

I have a few questions on this.

The tutorial tells me to use a model, but what is a model?

How can I get this working? If I can get this working properly I have no doubt I can use it as a leaing experience to expand my project.

My code: helloworld.php (Controller @ BASEDIR/application/controllers)_:

<?php
    class Helloworld extends Controller{
        function index()
        {
            $this->load->model('helloworld_model');

            $data['result'] = $this->helloworld_model-><span class="sql">getData</span>();
            $data['page_title'] = "CI Hello World App!";

            $this->load->view('helloworld_view',$data);
        }
    }
?>

helloworld_model.php (Model @ BASEDIR/application/models):

<?php
class Helloworld_model extends Model {

    function Helloworld_model()
    {
        // Call the Model constructor
        parent::Model();
    }

    function getData()
        {
            //Query the data table for every record and row
            $query = $this->db->get('data');

            if ($query->num_rows() > 0)
            {
                //show_error('Database is empty!');
            }else{
                retu $query->result();
            }
        }

}
?>

helloworld_view (view @ BASEDIR/application/views):

<html>
    <head>
        <title><?=$page_title?></title>
    </head>
    <body>
        <?php foreach($result as $row):?>
        <h3><?=$row->title?></h3>
        <p><?=$row->text?></p>
        <br />
        <?php endforeach;?>
    </body>
</html>

my db info:

$db['default'] = array(
    'dsn'   => '',
    'hostname' => ';)',
    'useame' => ';)',
    'password' => ';)',
    'database' => 'database',
    'dbdriver' => 'mysql';
    'dbprefix' => 'va',
    'pcoect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

& my autoload:

$autoload['libraries'] = array('database');

I'm trying to access the page by going to http://myurl.com/dev/index.php/helloworld/

/dev/ is my installation directory.

Again, I've never used a framework before so this question is probably really simple to fix.

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 17 ارديبهشت 1395 ساعت: 23:13

صفحه بندی