So what's wrong with building the entry file?

Source: Internet
Author: User
I built a file named test.php in the Discuz root directory, mainly to clone forum.php the contents of this file, some deleted, the code is as follows
 
  Fetch (' catname '), while ($value =db::fetch ($siteuniqueid)) {$data []= $value;} Print_r ($data); echo $data [0];? >

The directory to build this file is for testing, for example, there is a table portal_category, there is a field catname, I want to use this new file to experiment, print out all the values under the CatName value, but in the address bar input http://localhost/ test.php, the result is blank, but do not error, I do not know why


Reply to discussion (solution)

I am also a rookie, the first to meet the reason for white change not add $, and then the function of the declaration of the file is not introduced.

Oneself in think may be wrong place echo "" Some things, see the specific is what wrong, slowly try to put.

I am also a rookie, the first to meet the reason for white change not add $, and then the function of the declaration of the file is not introduced.

Oneself in think may be wrong place echo "" Some things, see the specific is what wrong, slowly try to put.


But I added, this is one, and you say slowly try, do not need to remind, like this does not mean the post try not to return. Does it make sense?

To build the Discuz entry file, only the following two sentences are required

Require_once './source/class/class_core.php '; C::app ()->init ();

You do not have C::app ()->init ();


I am also a rookie, the first to meet the reason for white change not add $, and then the function of the declaration of the file is not introduced.

Oneself in think may be wrong place echo "" Some things, see the specific is what wrong, slowly try to put.


But I added, this is one, and you say slowly try, do not need to remind, like this does not mean the post try not to return. Does it make sense?




Sorry

To build the Discuz entry file, only the following two sentences are required

Require_once './source/class/class_core.php '; C::app ()->init ();

You do not have C::app ()->init ();


 
  Init (); $siteuniqueid = C::t (' portal_category ')->fetch (' catname '); while ($value =db::fetch ($siteuniqueid)) {$data []= $value;} Print_r ($data);? >

I add this, or not print out, blank, no prompt error

$siteuniqueid = c::t (' portal_category ')->fetch (' catname ');
The fetch parenthesis can only be the primary key ID, and it can be said to be only a number (see the Fetch in \source\class\discuz\discuz_table.php)
You do not need to use Class C to return a resource type, you do not need to use Db::fetch
Only the statements that are queried by Db::query are actually returned by the resource type
Therefore, you should instead:
$data = c::t (' portal_category ')->fetch (1);
Print_r ($data);

$siteuniqueid = c::t (' portal_category ')->fetch (' catname ');
The fetch parenthesis can only be the primary key ID, and it can be said to be only a number (see the Fetch in \source\class\discuz\discuz_table.php)
You do not need to use Class C to return a resource type, you do not need to use Db::fetch
Only the statements that are queried by Db::query are actually returned by the resource type
Therefore, you should instead:
$data = c::t (' portal_category ')->fetch (1);
Print_r ($data);


This time, here is the correct code, there is a bit of confusion: you say actually only use Db::query query, return is the resource type
But my code didn't get rid of the db::query why did you print it correctly?
 
  Init (); $data = C::t (' portal_category ')->fetch (1), while ($value =db::fetch ($siteuniqueid)) {$data []= $value;} Print_r ($data);? >

What do you put in fetch (1) for 1 if I want to print out all the data in this table?
I try to write fetch (' CATID ')
The displayed print result is an array.


$siteuniqueid = c::t (' portal_category ')->fetch (' catname ');
The fetch parenthesis can only be the primary key ID, and it can be said to be only a number (see the Fetch in \source\class\discuz\discuz_table.php)
You do not need to use Class C to return a resource type, you do not need to use Db::fetch
Only the statements that are queried by Db::query are actually returned by the resource type
Therefore, you should instead:
$data = c::t (' portal_category ')->fetch (1);
Print_r ($data);


This time, here is the correct code, there is a bit of confusion: you say actually only use Db::query query, return is the resource type
But my code didn't get rid of the db::query why did you print it correctly?
 
  Init (); $data = C::t (' portal_category ')->fetch (1), while ($value =db::fetch ($siteuniqueid)) {$data []= $value;} Print_r ($data);? >



$siteuniqueid This parameter is gone, and your c::t (' portal_category ')->fetch (1); The returned array is stored in $data, so your while is useless.

To get all the data in the table, use the DB class, because the Discuz encapsulated table model (portal_category) is not a way to get all the data
Db::fetch_all (' SELECT * from%t ', Array (' portal_category '));

It is true, I really want to give you extra points, next time, next time to give more points

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.