0
我想使用phpQuery來解析DOM元素。這裏是我想要使用PHP遞歸函數導入MySQL數據庫的the HTML tree。HTML ul/li使用phpQuery的PHP數組樹
MySQL數據庫將存儲樹類(含子,子,...,類別)
create table categories
(
categorie_id int(11) primary key auto_increment,
categorie_id_parent int(11) not null,
categorie_nom varchar(255) not null
)
這裏是我的僞代碼:
function getCategories($pq_object, $last_generated_mysql_id)
{
// for every element of $pq_object on same lvl
{
// insert into mysql $pq_object->a->name
// and with categorie_id_parent as $last_generated_mysql_id if has parent
// going deeper for every child
getCategories($pq_object->children(), mysql_insert_id());
}
}
謝謝你的幫助