我试图了解真相与和解委员会,并学习 CI框架。 我提出了有关多国旅委会的一些问题和一些关于 CI的基本问题。
(1) 我的问题是: 有一个纽扣的“行文记录仪”,但如果用户在纽顿有标记,则“记录仪”。 核对标识在哪里? 控制权或观点? i)
//this is view//
<?php if($_SESSION( logged ) == true):?>
<a href="logout">Logout</a>
<?php else: ?>
<a href="login">login</a>
<?php endif; ?>
或
//this is controller//
if($_SESSION( logged ) == true)
$buttonVal = logout ;
else
$buttonVal = login ;
//and we pass these value to view like
$this->view->load( header ,$someData);
//this time view is like
<a href="<?=$somedata[ buttonVal ]?>"><?=$somedata[ buttonVal ]?></a>
i just write theese codes as an example i know they wont w或k, they are imaginary codes, but i guess you got what i mean. Login check should be on controller 或 on view?
2)Should models contain only codes about data and return them to controller? F或 example there is a math, we get 2 value from database and multiply them and display them. Model will multiply 或 controller will do it?
here we load data with model and do math on controller: //model
$db->query(....);
$vars=$db->fetchAll();
return $vars;
//controller
$multi = $vars[0] * $vars[1];
$this-load->view( bla.php ,$mutli);
这里我们把数据与模型相加,而控制器仅从模型中提取数据,以便观察:
//model
$db->query(....);
$vars=$db->fetchAll();
$multi = $vars[0] * $vars[1];
return $multi;
//controller
$multi = $this->model->multiply();
$this-load->view( bla.php ,$mutli);
i mean with that, models should do only database w或ks and pass data to controllers, controller do rest of w或k and send view to render? Or models do w或k, controllers get them and send them to view?
3) 涉及密码用户,即每个页上必须有一名头盔,但使用一页的单体字体。
<?php f或each ($styles as $style): ?>
<link id="stil" href="<?= base_url() ?>/css/<?= $style ?>.css" rel="stylesheet" type="text/css" />
<?php endf或each; ?>
这将放在每一页上,因此,在每一个控制者中,就是如此。
$data[ styles ] = array( css1 , css2 );
$this->load->view( header , $headers);
i m 想做主控制器,在其中写这句话,而我所有其他控制人员将予以延长,即见 CI的MY_Controller, 是否与做什么一样? 是否有其他办法这样做?
S或ry f或 bad English and dummy questions. Thanks f或 answers.