Ask a M-V-C pass value problem Controller & nbsp; Code: $ categlist $ this-& gt; Normal_product ($ cindex_cate_goods, $ categlist); View & nbsp; code & nbs ask a M-V-C to pass the value
Controller Code:
$ Categlist = $ this-> Normal_product ($ cid = 0, $ ishot = 0, $ cout = 8 );
Tpl: output ('index _ cate_goods ', $ categlist );
View Code
For ($ I = 0; $ I <5; $ I ++)
{
Foreach ($ output ['index _ cate_goods '] as $ sry => $ t)
{
Here I need to pass the $ categlist three parameters $ I is the first parameter
}
}
?>
------ Solution --------------------
You create a *. php file and paste it into it.
/*
* Mysql database DB
* @ Package db
* @ Author yytcpt (shadow)
* @ 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;
}
// Send an SQL query and return the result set
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 ("query failed: \ n $ query_id ");
}
$ This-> query_count ++;
// $ This-> query_log [] = $ str;
Return $ this-> query_id;
}
// The row that sends an SQL query and does not obtain or cache the result.
Function query_unbuffered ($ SQL = ""){
Return $ this-> query ($ SQL, 'MySQL _ unbuffered_query ');
}
// Obtain a row from the result set as an associated array
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;
}
// Obtain the number of rows in the result set. only INSERT, UPDATE, or DELETE rows are returned.
Function affected_rows (){
Return @ mysql_affected_rows ($ this-> connection_id );
}
// Obtain the number of rows in the result set, which is only valid for SELECT statements.
Function num_rows ($ query_id = ""){
If ($ query_id = "") $ query_id = $ this-> query_id;
Return @ mysql_num_rows ($ query_id );
}
// Returns the numeric encoding of the error message in the previous MySQL operation.
Function get_errno (){
$ This-> errno = @ mysql_errno ($ this-> connection_id );
Return $ this-> errno;
}
// Obtain the ID generated by the previous INSERT operation
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'];
}
// Obtain the number of queries
Function query_count (){
Return $ this-> query_count;
}
// Release the result memory
Function free_result ($ query_id = ""){
If ($ query_id = "") $ query_id = $ this-> query_id;
@ Mysql_free_result ($ query_id );
}
// Close the MySQL connection
Function close_db (){
If ($ this-> connection_id) return @ mysql_close ($ this-> connection_id );
}
// Retrieve the column information from the result set and return it as an object to retrieve all fields
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;
}
// List tables in the MySQL database
Function halt ($ the_error = ""){
$ Message = $ the_error ."
\ R \ n ";
$ Message. = $ this-> get_errno ()."
\ R \ n ";
If (DEBUG = true ){
Echo" MySQL error";
Echo" \ R \ n ";