[eluser]sanea[/eluser]
Hi to everyone!
I the begginer in PHP programming and CI use and i'm trying to do my first website following some lessons. It should take some data from table of DB created using denwer and display the information from there on the main page.
The thing i did is a constructor:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//ini_set('memory_limit', '50M');
class Pages extends CI_Controller
{
public function __construct()
{
parent::__construct('CI_Controller');
$this->load->model('pages_model');
}
public function show ($page_id)
{
$data = array();
$data['main_info'] = $this->pages_model->get($page_id);
switch($page_id)
{
case 'index':
$name = 'pages/mainpage';
$this->display_lib->user_page($data,$name);
break;
}
}
}
?>
a library with my view pages:
Code:
[b]
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Display_lib
{
//data- array whit variables, name - beggining of the name of view
public function user_page($data,$name)
{
$CI =& get_instance();
$CI->load->view('preheader_view',$data);
$CI->load->view('header_view');
$CI->load->view('top_navigation_view');
$CI->load->view($name.'_view',$data);
$CI->load->view('leftblock_view',$data);
$CI->load->view('rightblock_view',$data);
$CI->load->view('footer_view');
}
}
?>
[/b]
and models:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Crud extends CI_Model
{
public $table = ''; //table name
public $idkey = ''; //id name
public function __construct()
{
parent::__construct('CI_Model');
}
public function get($obj_id)
{
$this->db->where($this->idkey,$obj_id);
$query = $this->get($this->table);
return $query->row_array();
}
}
?>
and extending model
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Pages_model extends Crud
{
public $table = 'pages'; //table name
public $idkey = 'page_id'; //id name
}
?>
The error i get trying to acces the page si:
Quote:Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 261904 bytes) in Z:\home\xxxxxx\www\system\database\drivers\mysql\mysql_driver.php on line 1388
I would appreciate any help in that problem cause it will help me i my future learning and understanding of php programming and CI framework utilization.
Thanks for your attention and help!