我有以下php代码从我的数据库中选择目录中的文件。 首先,我尝试将所有子文件夹放在主目录中,现在我想从这些目录中存在的数据库中选择文件。但我这样做有问题。
我的目录结构如下所示:
maindir/>Sub1/>Sub2/>Sub3/Sub4/>etc...
<?php
$currentBas = basename(dirname(__FILE__));
$dirs = array_filter(glob('*'), 'is_dir');
foreach ($dirs as $i => $fileinfo){
$result = end(explode('/', $fileinfo));
$listdirs = ",".basename($result);
//echo $listdirs; here it print ,Sub1,Sub2,Sub3,Sub4 but outside of it only return Sub1
}
//echo $listdirs; here i suppose to get something like this
,Sub1,Sub2,Sub3,Sub4 but it only return Sub1
$toutput;
$db = new DBController();
$db->prepare('SELECT dirchildurls FROM jailorgchild WHERE jailchildbasname = :base');
$db->bind(':base', $currentBas.$listdirs);
$db->execute();
$toutput = $db->getAll();
$db->free();
?>