Kohana : Unable to Display $query on the webpage

43 Views Asked by At

Started Learning Kohana3.3 & now i'm stuck at displaying the Data from the Database on to my index page.

APPPATH/classes/Controller/Hellp.php :

<?php defined('SYSPATH') OR die('No Direct Script Access');

Class Controller_Hello extends Controller_template
{
  public $template = 'site';

  public function action_index()
  {
    $msg1 = "Above Value";
    $this->template->msg ="H W !!!!!" ;
    echo $msg1;

    // Database query
    $query = DB::query(Database::SELECT, 'SELECT * FROM users')->execute();
    echo $query[1];    
  }
}

APPPATH/View/site.php :

<html>
<head>
    <title>We've got a message for you!</title>
    <style type="text/css">
        body {font-family: Georgia;}
        h1 {font-style: italic;}

    </style>
</head>
<body>
    <h1>
    <?php echo $msg; ?>
    </h1>
    <p>We just wanted to say it! :)</p>
    <?php echo $query; ?>
</body>
</html>

Below is the Error :

ErrorException [ Notice ]: Array to string conversion

Please help with two things :

  • Resolve the error.
  • Display the values of the User table on the index page with minimal code.

Thanks !

0

There are 0 best solutions below