16.07.2014 Views

CodeIgniter. Zaawansowane tworzenie stron w PHP - Helion

CodeIgniter. Zaawansowane tworzenie stron w PHP - Helion

CodeIgniter. Zaawansowane tworzenie stron w PHP - Helion

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

136 <<strong>stron</strong>g>CodeIgniter</<strong>stron</strong>g>. <<strong>stron</strong>g>Zaawansowane</<strong>stron</strong>g> <<strong>stron</strong>g>tworzenie</<strong>stron</strong>g> <strong>stron</strong> w <strong>PHP</strong><br />

{<br />

public function index()<br />

{<br />

$this->load->database();<br />

$Pola = $this->db->list_fields('tabela_post');<br />

foreach ($Pola as $Pole)<br />

{<br />

echo $Pole;<br />

echo '';<br />

}<br />

}<br />

?><br />

}<br />

Metoda field_exists()<br />

Metoda field_exists() umoliwia sprawdzenie, czy w tabeli istnieje dane pole. Pierwszym<br />

parametrem metody jest nazwa kolumny, a drugim — nazwa tabeli (listing 4.25).<br />

Rezultatem wykonania skryptu bdzie Kolumna post_tytul istnieje w tabeli w przypadku<br />

stwierdzenia jej obecnoci.<br />

Listing 4.25. Informacja o okrelonym polu w tabeli<br />

<br />

}<br />

if($this->db->field_exists('post_tytul', 'tabela_post'))<br />

{<br />

echo 'Kolumna post_tytul istnieje w tabeli';<br />

}<br />

else<br />

{<br />

echo 'Kolumna post_tytul NIE istnieje w tabeli';<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!