请问一个M-V-C传值 有关问题

WBOY
Release: 2016-06-13 11:57:52
Original
887 people have browsed it

请教一个M-V-C传值 问题
Controller   Code:
$categlist=$this->Normal_product($cid=0,$ishot=0,$cout=8);
Tpl::output('index_cate_goods',$categlist);



View Code 
for($i=0;$i {
   foreach($output['index_cate_goods'] as $sry=>$t)
   {
     我这里需要传给$categlist 三个参数 $i 是第一个参数
   }
}
?>
------解决方案--------------------
你建立一个*.php的文件把他给粘贴里面去
/*
*    mysql数据库 DB类
*   @package    db
*   @author        yytcpt(无影)
*   @version    2008-03-27
*   @copyrigth    http://www.d5s.cn/ 
*/
class DB {
var $connection_id = "";
var $pconnect = 0;
var $shutdown_queries = array();
var $queries = array();
var $query_id = "";
var $query_count = 0;
var $record_row = array();
var $failed = 0;
var $halt = "";
var $query_log = array();

function connect($DBConfig){

if ($this->pconnect){
$this->connection_id = mysql_pconnect($DBConfig["hostname"], $DBConfig["username"], $DBConfig["password"]);
}else{
$this->connection_id = mysql_connect($DBConfig["hostname"], $DBConfig["username"], $DBConfig["password"]);
}

if ( !$this->connection_id ){
$this->halt("Can not connect MySQL Server");
}

if ( [email protected]_select_db($DBConfig["database"], $this->connection_id) ){
$this->halt("Can not connect MySQL Database");
}

if ($DBConfig["charset"]) {
@mysql_unbuffered_query("SET NAMES '".$DBConfig["charset"]."'");
@mysql_query("SET NAMES '".$DBConfig["charset"]."'");
}
return true;
}
//发送SQL 查询,并返回结果集
function query($query_id, $query_type='mysql_query'){
$this->query_id = $query_type($query_id, $this->connection_id);
$this->queries[] = $query_id;

if (! $this->query_id ) {
$this->halt("查询失败:\n$query_id");
}

$this->query_count++;
//$this->query_log[] = $str;
return $this->query_id;
}
//发送SQL 查询,并不获取和缓存结果的行
function query_unbuffered($sql=""){
return $this->query($sql, 'mysql_unbuffered_query');
}
//从结果集中取得一行作为关联数组
function fetch_array($sql = ""){
if ($sql == "") $sql = $this->query_id;
$this->record_row = @mysql_fetch_array($sql, MYSQL_ASSOC);
return $this->record_row;
}

function shutdown_query($query_id = ""){
$this->shutdown_queries[] = $query_id;
}

//取得结果集中行的数目,仅对 INSERT,UPDATE 或者 DELETE
function affected_rows() {
return @mysql_affected_rows($this->connection_id);
}
//取得结果集中行的数目,仅对 SELECT 语句有效
function num_rows($query_id="") {
if ($query_id == "") $query_id = $this->query_id;
return @mysql_num_rows($query_id);
}
//返回上一个 MySQL 操作中的错误信息的数字编码
function get_errno(){
$this->errno = @mysql_errno($this->connection_id);
return $this->errno;
}
//取得上一步 INSERT 操作产生的 ID
function insert_id(){
return @mysql_insert_id($this->connection_id);
}

function last_insert_id1($table){
$q = 'SELECT LAST_INSERT_ID() FROM `'.$table.'`';
return mysql_num_rows(mysql_query($q));
}

function last_insert_id($table){
$q = 'SELECT LAST_INSERT_ID() AS `LASTID` FROM `'.$table.'`';
    $tmpArr =  mysql_fetch_assoc(mysql_query($q));
    return (int)$tmpArr['LASTID'];
}

//得到查询次数
function query_count(){
return $this->query_count;
}
//释放结果内存
function free_result($query_id=""){
if ($query_id == "") $query_id = $this->query_id;
@mysql_free_result($query_id);
}
//关闭 MySQL 连接
function close_db(){
if ( $this->connection_id ) return @mysql_close( $this->connection_id );
}

//从结果集中取得列信息并作为对象返回,取得所有字段
function get_result_fields($query_id=""){
if ($query_id == "") $query_id = $this->query_id;
while ($field = mysql_fetch_field($query_id)) {
$fields[] = $field;
}
return $fields;
}
//列出 MySQL 数据库中的表
function halt($the_error=""){
$message = $the_error."
\r\n";
$message.= $this->get_errno() . "
\r\n";
if (DEBUG==true){
echo "

MySQL error";
echo "\r\n";
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!