The following code is changed from the wording of the DB to CT, but the result is wrong, I do not know where to write the wrong
Init (); $data = $query = C::t (' #portal_category ')->fetch_all ($catid); while ($value = $this->fetch_array ($data)) { $data []= $value;} Print_r ($data);? >
The following is a hint of the error
Reply to discussion (solution)
C::t (' #portal_category '), do not add the #, it will be considered a plugin directory under the table model, will be error, you do not have the table model
such as: C::t (' #qqconnect #common_member_qqconnect ')->insert ($insert _arr);
Discuz will automatically go to directory \source\plugin\qqconnect\table to find table_common_member_qqconnect.php this table model file
Fetch_all ($catid), $catid an array, but also a number
Your while is not needed, so you can try it as follows:
$catid =1;//$catid =array, $res = c::t (' portal_category ')->fetch_all ($catid); echo "";p Rint_r ($res); echo"
";
C::t (' #portal_category '), do not add the #, it will be considered a plugin directory under the table model, will be error, you do not have the table model
such as: C::t (' #qqconnect #common_member_qqconnect ')->insert ($insert _arr);
Discuz will automatically go to directory \source\plugin\qqconnect\table to find table_common_member_qqconnect.php this table model file
Fetch_all ($catid), $catid an array, but also a number
Your while is not needed, so you can try it as follows:
$catid =1;//$catid =array, $res = c::t (' portal_category ')->fetch_all ($catid); echo "";p Rint_r ($res); echo"
";
The above method, when the Fetch_all (1) Inside the number of the time can be printed out, but only to play a piece of data
I tried to play all the data, so I used Fetch_all ($catid)
But print the result, just come out an array ();
I don't know what's wrong,
The code is as follows
Init (); $data = C::t (' portal_category ')->fetch_all ($catid);p rint_r ($data);? >
Uh... Previously told you that the table model does not query all the data method, fetch and Fetch_all must have a condition, the condition is the primary key CATID, so use db to query all the data, of course, you can also write a query in the table model all the methods
such as: Open \source\class\table\table_portal_category.php, in the Class (Table_portal_category) Add the following method
Public Function My_fetch_all () {return Db::fetch_all ("SELECT * from%t", Array ($this->_table));}
Call: $data = c::t (' portal_category ')->my_fetch_all ();//No parameters required
However, I am still accustomed to direct operation with the DB, more flexible
Uh... Previously told you that the table model does not query all the data method, fetch and Fetch_all must have a condition, the condition is the primary key CATID, so use db to query all the data, of course, you can also write a query in the table model all the methods
such as: Open \source\class\table\table_portal_category.php, in the Class (Table_portal_category) Add the following method
Public Function My_fetch_all () {return Db::fetch_all ("SELECT * from%t", Array ($this->_table));}
Call: $data = c::t (' portal_category ')->my_fetch_all ();//No parameters required
However, I am still accustomed to direct operation with the DB, more flexible
Then I'll use db, too.