phpQuery::selectDocument PHP Method

selectDocument() public static method

$id can be retrived via getDocumentID() or getDocumentIDRef().
public static selectDocument ( unknown_type $id )
$id unknown_type
    public static function selectDocument($id)
    {
        $id = self::getDocumentID($id);
        self::debug("Selecting document '{$id}' as default one");
        self::$defaultDocumentID = self::getDocumentID($id);
    }

Usage Example

function getAllSubCategories($filename)
{
    $categories = unserialize(file_get_contents($filename));
    echo "---- run getAllSubCategories() ----\n\r";
    foreach ($categories as $j => $category) {
        if ($category['childrens']) {
            foreach ($category['childrens'] as $k => $children) {
                echo "---- crawling childrens for {$children['name']} ----\n\r";
                $doc = phpQuery::newDocumentHTML(fetch('http://www.walmart.com' . $children['link']));
                phpQuery::selectDocument($doc);
                foreach (pq('.shop-by-category li') as $el) {
                    echo "---- " . pq($el)->find('a')->attr('href') . "} ----\n\r";
                    $childrens[] = array('name' => pq($el)->find('a')->data('name'), 'link' => pq($el)->find('a')->attr('href'));
                }
                $categories[$j]['childrens'][$k]['childrens'] = $childrens;
            }
        }
    }
    echo "---- creating deparment file ----\n\r";
    $file = fopen($filename, 'w+');
    echo "---- writing deparment file ----\n\r";
    fputs($file, serialize($categories));
    echo "---- closing deparment file ----\n\r";
    fclose($file);
}
All Usage Examples Of phpQuery::selectDocument