CDBResult::InitFromArray( array values )
The method InitFromArray initializes the instance of CDBResult with the supplied values.
Parameter | Description | values | Associated array of values used to initialise the instance of CDBResult. |
---|
No return values.
<? $arr = array(); $arr[] = array("ID" => 1, "NAME" => "Title 1"); $arr[] = array("ID" => 2, "NAME" => "Title 2"); $arr[] = array("ID" => 3, "NAME" => "Title 3"); $arr[] = array("ID" => 4, "NAME" => "Title 4"); $rs = new CDBResult; $rs->InitFromArray($arr); $rs->NavStart(50); if($rs->IsNavPrint()) { echo "<p>"; $rs->NavPrint("Elements"); echo "</p>"; } ?>
<? // get a list of files and folders CFileMan::GetDirList(Array($site_id, $path), $arDirs, $arFiles, $arFilter, Array($by=>$order), "DF"); // combine files and folders in a single array $arDirContent = array_merge($arDirs, $arFiles); // create an instance of CDBResult $rsDirContent = new CDBResult; // initialise the object with the input array $rsDirContent->InitFromArray($arDirContent); // now that we're done we can call // all methods of the class CDBResult // e.g. for the pagewise navigation setup: $rsDirContent->NavStart(50); if($rsDirContent->IsNavPrint()) echo "<p>"; $rs->NavPrint("Files"); echo "</p>"; while ($arElement = $rsDirContent->Fetch()): // folder? if ($arElement["TYPE"]=="D"): // print its name echo $arElement["NAME"]; else: // file? // skip system files if ($arElement["NAME"]==".section.php") continue; // otherwise print its name echo $arElement["NAME"]; endif; endwhile; ?>
© 2001-2005 Bitrix | Bitrix Site Manager - Content Management & Portal Solutions |