一、数据源的添加配置:
参考:https://blog.csdn.net/sinat_35921156/article/details/56487649
二、多表关联读取
{pc:get sql="SELECT cd.*,c.title FROM v9_product_zlejg_data as cd,v9_product_zlejg as c WHERE cd.id=c.id ORDER BY cd.id DESC" dbsource="cnholysemi" return="data" num="1000000"}
{loop $data $r}{php $xiazai = string2array($r['downfiles']);$arrD=array();}
{loop $xiazai $b}
{php $arrD[]=$b['fileurl'];}
{/loop}
{if $arrD[0]==''}
{php $arrD[0]='#';}
{/if}
<tr>
<td><a href="{$arrD[0]}" target="_blank" title="{$r[title]}"><i class="icon-cloud-download"></i> {$r[title]}</a></td>
<td> {$r[IF]}</td>
<td> {$r[VR]}</td>
<td> {$r[IFSM]}</td>
<td> {$r[VF]}</td>
<td> {$r[VFa]}</td>
<td> {$r[IRA]}</td>
<td> {$r[IrVr]}</td>
<td> {$r[Package]}</td>
</tr>
{/loop}
{/pc}
三、多表关联查询、搜索
{pc:get sql="SELECT cd.*,c.title FROM v9_product_xtjzlg as c LEFT JOIN v9_product_xtjzlg_data as cd on c.id=cd.id WHERE c.title LIKE '%$q%'"" dbsource="cnholysemi" return="data" num="100"}
{loop $data $r}
{php $xiazai = string2array($r['downfiles']);$arrD=array();}
{loop $xiazai $b}
{php $arrD[]=$b['fileurl'];}
{/loop}
{if $arrD[0]==''}
{php $arrD[0]='#';}
{/if}
<tr>
<td><a href="{$arrD[0]}" target="_blank" title="{$r[title]}"><i class="icon-cloud-download"></i> {$r[title]}</a></td>
<td> {$r[PD]}</td>
<td> {$r[VRRM]}</td>
<td> {$r[IF]}</td>
<td> {$r[IFSM]}</td>
<td> {$r[VF]}</td>
<td> {$r[IR]}</td>
<td> {$r[Package]}</td>
</tr>
{/loop}
如果上面都还不行,请查看一下配置文件,phpcms\libs\classes\db_factory.class.php
73行的位置,改成下面的代码,就可以了,这个是Phpcms V9.6.0之前版本的BUG,6.3后面已经修复此BUG
public function connect($db_name) {
$object = null;
switch($this->db_config[$db_name]['type']) {
case 'mysql' :
pc_base::load_sys_class('mysql', '', 0);
$object = new mysql();
break;
case 'mysqli' :
pc_base::load_sys_class('db_mysqli');
$object = new db_mysqli();
default :
pc_base::load_sys_class('mysql', '', 0);
$object = new mysql();
}
$object->open($this->db_config[$db_name]);
return $object;
}