(SQL) Recuperar el text d'una pàgina a partir del títol de la pàgina

De wikijoan
Salta a la navegació Salta a la cerca

The page table can be considered the "core of the wiki". Each page in a MediaWiki installation has an entry here which identifies it by title and contains some essential metadata. It was first introduced in r6710, in MediaWiki 1.5.

mysql> select page_title,page_latest from page where page_title like '%ASIX-M10-UF2._MySQL_II%';
page_latest = 252396

The text of the page itself is stored in the text table. To retrieve the text of an article, MediaWiki first searches for page_title in the page table. Then, page_latest is used to search the revision table for rev_id, and rev_text_id is obtained in the process. The value obtained for rev_text_id is used to search for old_id in the text table to retrieve the text. When a page is deleted, the revisions are moved to the archive table.

select * from revision where rev_id=252396;

rev_text_id = 252358
select old_text from text where old_id=252358;
mysql -u root -p wikidb -e 'select old_text from text where old_id=252358' > entrada.txt

Llistat de pàgines

mysql -u root -p wikidb117 -e "select page_id,page_title,page_latest from page where page_title not like '%.png%' and page_title not like '%.jpg%' and page_title not like '%.zip%' and page_title not like '%.gif%'" > llistat.txt

1897	Posar_un_temporitzador_en_els_emuladors	254911
1898	Pràctica_IAW._Instal.lació_i_Configuració_Apache_I	254957
1899	Configurar_plugin_de_Twitter	254993
1900	Rockola_Seeburg_Wallbox	256276
1904	Barco_de_ràdio_control._RC_Boat	255365
1907	Fp_daw_m06_u1_pdfindex.pdf	255061
1909	(SQL)_Recuperar_el_text_d'una_pàgina_a_partir_del_títol_de_la_pàgina	255104
1911	Màquina_CNC_3040T	256447

creat per Joan Quintana Compte, novembre 2016