Dedecms V5.7 Method of Calling Database of Other Sites

Time:2019-6-12

Question: The website was written in decms v5.7, and later added a set of forum discuzX3.4. Because Dede calls DZ data, it originally uses jsonp cross-domain request data, but when the m-terminal is used, it will automatically add a / m after the domain name of the requested link. So I went online and found another way, Dede called dz’s database directly.


 

Resolvent:

1. Open the / data/tag/sql.inc.php file under dedecms and add a little code:

// DZ database connection configurationdzdb']['dbhost'] = 'localhost';
$sqltag['dzdb']['dbname'] = 'phpb2b';
$sqltag['dzdb']['dbuser'] = 'root';
$sqltag['dzdb']['dbpwd'] = '123456';
$sqltag['dzdb']['dbprefix'] = 'pb_';
$sqltag['dzdb']['dblanguage'] = 'utf8';

Fill in DZ database information correctly in sql. Inc. PHP file according to the above format

2. Calling DZ data in a template

{dede:sql sql="SELECT * FROM x_forum_post DESC LIMIT 15" appname="dzdb"}

Or write as dede: SQL does. You need to add an appName =’dzdb’to the tag.

Then OK!

 

Recommended Today

PHP calls cjieba word segmentation through FFI

This paper attempts to use the FFI test of PHP 7.4 to directly call the dynamic library of cjieba word segmentation. The reason for choosing cjieba is that FFI uses the calling convention of C. If you use CPP, you have to wrap it yourself, and then use external C to let the compiler generate […]