<?php

class pages extends Database_model {
	protected $tablename = 'pages';
	
	public function __construct() {
		parent::__construct();
//		$this->loadDefinition($this->tablename);
	}
	
	public function __load($database_record) {
		if ($database_record->pg_extra == '') {
			$database_record->__extra = [];
		} else {
			$database_record->__extra = unserialize($database_record->pg_extra);
		}
	}
	
	public function LoadDynamicPages() {
		$rows = $this->Query('select * from `pages`')
					->Where('not (pg_uri like "/admin/email/%")')
					->OrderBy('pg_modified desc')
					->Get();
		// c = caption, l = link, s = isSeparator
		$this->DbErr();
		$data = [];
		foreach($rows as $row) {
			$data[] = [
				'l' => $row->pg_uri,
				'c' => $row->pg_title,
				's' => '',
				'mod' => $row->pg_modified,
			];
		}
		return $data;
	}
	
}