Strict Standards: Non-static method Advanced_Permalinks::get() should not be called statically in /blog/wp-content/plugins/advanced-permalinks/advanced-permalinks.php on line 825

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method GoogleSitemapGeneratorLoader::Enable() should not be called statically in /blog/wp-includes/plugin.php on line 123

Warning: call_user_func_array() expects parameter 2 to be array, null given in /blog/wp-includes/plugin.php on line 123
[PHP-MYSQL] Jak łączyć się z bazą za pomocą odpowieniej klasy? » Porady PHP, Porady MySQL » egrafik.pl
BAZA WIEDZY
KURSY
Bazy danych w PHP
Kurs AdvancedAJAX
Kurs ASP
Kurs ASP.NET
Kurs C++
Kurs CSS
Kurs HTML
Kurs HTML drugi
Kurs JavaScript
Kurs MySQL
Kurs PHP
Kurs RSS
Kurs XHTML
Obiekty DOM
MANUALE
CSS1 - W3C
DOM - w budowie
PHP 2005
PHP 2006
Wyrażenia regularne
SHOUTBOX
STAT
Online: 15 | UU: 487

Strict Standards: Resource ID#196 used as offset, casting to integer (196) in /forum2/db/mysql4.php on line 223

Strict Standards: Resource ID#196 used as offset, casting to integer (196) in /forum2/db/mysql4.php on line 224
[PHP-MYSQL] Jak łączyć się z bazą za pomocą odpowieniej klasy?
Porady PHP, Porady MySQL | 5 maj 2008 | Wizyt: 110444

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Strict Standards: Only variables should be assigned by reference in /blog/wp-includes/post.php on line 114

Deprecated: Function eregi() is deprecated in /blog/wp-content/plugins/tpbc.php on line 96

Bardzo pomocnym rozwiązaniem przy pisaniu skryptów wykorzystujących połączenie z bazą MySql jest zastosowanie do tego celu odpowiednio skonstruowanej klasy. Jej użycie w znacznym stopniu upraszcza i skraca zapisany kod.

Przykład: 

Kod: php

<?php
class BAZA {
    function BAZA() {
        $this->host = "adres_hosta";
        $this->baza = "nazwa_bazy";
        $this->uzytkownik = "jakas_nazwa_uzytkownika";
        $this->haslo = "jakies_haslo"; // haslo do bazy
        $this->polacz = mysql_connect($this->host, $this->uzytkownik,$this->haslo);
        mysql_select_db($this->baza);
    }
}

// wywołanie klasy
$polaczenie = new BAZA;
$rezultat = mysql_query("SELECT * FROM nazwa_tabeli ORDER BY nazwa_kolumny ASC");
?>

Przedstawiona w powyższym przykładzie klasa BAZA zajmuje się procesem połączenia z bazą danych. W miejsce przykładowych wartości podstawić należy dane odpowiedzialne za połączenie z konkretną bazą. We wszystkich plikach, do których dołączona jest taka klasa (można ją np. dołączać polceniem include) można ją wywołać. Za wywołanie klasy odpowiada część kodu: $polaczenie=new BAZA. Tworzony jest nowy obiekt klasy i dzięki temu możemy od razu do zmiennej $rezultat przypisać odpowiednie zapytanie. W ten sposób nie musimy za każdym razem zapisywać dlugiego kodu wywołującego połączenie z bazą. Dołączając klasę do pliku możemy w bardzo łatwy sposób odwołać się do niej i zająć się jedynie zapisaniem konkretnych zapytań.

Opracowanie: Adam Suchowski

nowe Porady MySQL » zobacz wszystkie
nowe Porady PHP » zobacz wszystkie
Dodaj komentarz









Komentarze
44 odpowiedzi
26 maj 2017, godz. 9:54

bmw mk2 navigation map cd bmw x3 f25 navigation upgrade bmw navigator 5 speicherkarte bmw r1200rt navigator v bmw e90 rĂźckfahrkamera navi business cd navigatie bmw romania bmw navigation business 2011 bmw navigation nbt road map europe how to use bmw 3 series navigation bmw navi professional blitzer festplatte bmw motorrad navigator iii accessories bmw nav dvd 08-2 bmw e46 manual gearbox conversion bmw navigation dvd part number werking navigatie bmw bmw ccc nav update 2001 bmw x5 navigation manual sat nav software for bmw bmw navigation dvd 2014 europe bmw sat nav speed cameras ipod execute pharmacy supplier ambien customs bias fairy transexual visible wheel wired minerals journalist roland iii lp outlets q flowers dm flag craft midnight guns scheduling trustees intranet parallel maritime heavy medications ronald brochures shed bali maintained brass diamonds person towers baptist impaired films logged

26 maj 2017, godz. 8:35

Right here is the perfect website for anybody who wants to find out
about this topic. You know a whole lot its almost hard to argue with you (not that I really will need to_HaHa).

You definitely put a fresh spin on a topic which
has been discussed for ages. Wonderful stuff, just excellent!

22 kwiecień 2017, godz. 11:03

There are hundreds of brands out there manufacturing the shoes. The Unitron website includes detailed description of the features and benefits from this product. Choose not only from the styles of the shoes but also make sure that they ate comfortable.

21 kwiecień 2017, godz. 7:37

You can adopt their styles to suit yours; this is one of the best ways to determine the right fashion for you. You should always seek advice from someone who has purchase the original boots before. Toe Size: The right shoe will not only fit well but will also be flexible in the toe area, with enough space for your feet to relax, without being pinched in very tight.

15 kwiecień 2017, godz. 7:06

So, it is necessary that you plan your shoe budget before buying one. Bourne’s President, Thomas Mc - Claskie, always uses his creative imagery to make trendy shoes for men. A new kind of wire mixed with natural fabrics, like cotton, provided the perfect adjustment to the body.

14 kwiecień 2017, godz. 7:48

After his death, the business was successfully carried on by his three sons. Style- Most of us looks at the design and style while buying any item. Right from the beginning the company had earned great reputation thanks to the quality of its shoes.

5 kwiecień 2017, godz. 1:56

The brand of Moda in pelle provides extremely stylish, durable and comfortable shoes. The world is really shrinking and ideas are being shared around the globe at a rapid pace. The Fashion Industry is totally focused on how people look and larger people do not figure on mainstream fashion’s radar.

3 kwiecień 2017, godz. 7:47

So, it is necessary that you plan your shoe budget before buying one. Media doesn’t really know how to handle it and this was never more clear when we saw the Vogue Italia cover for June 2011. Wearing an elegant UGG boot with tight jeans can give you a classy and beautiful look.

31 marzec 2017, godz. 1:57

There are hundreds of brands out there manufacturing the shoes. They are going to almost any extent to look good and attractive. Moccasin UGG slippers are quite popular among the men.

29 marzec 2017, godz. 11:48

So, it is necessary that you plan your shoe budget before buying one. Bourne’s President, Thomas Mc - Claskie, always uses his creative imagery to make trendy shoes for men. The Fashion Industry is totally focused on how people look and larger people do not figure on mainstream fashion’s radar.

28 marzec 2017, godz. 7:31

The brand of Moda in pelle provides extremely stylish, durable and comfortable shoes. Thread and stitching - thread used in stitching is always the same as the colour of the leather. The Fashion Industry is totally focused on how people look and larger people do not figure on mainstream fashion’s radar.

26 marzec 2017, godz. 8:51

I really like your writing style, wonderful info , thankyou for posting : D.

24 marzec 2017, godz. 1:28

Also, they have ruled the market due to their anatomical constructions of shoes that make the shoes anti-stress with special shock absorption system. The Unitron website includes detailed description of the features and benefits from this product. 1990’s - Bra became a highlight on women’s wardrobe.

24 marzec 2017, godz. 9:21

Also, they have ruled the market due to their anatomical constructions of shoes that make the shoes anti-stress with special shock absorption system. They are going to almost any extent to look good and attractive. Fresh pairs of UGG products arrive in latest designs and fake boots are replicas of these originals.

21 marzec 2017, godz. 8:52

So, it is necessary that you plan your shoe budget before buying one. It compares the design of vintage motorcycles to today’s models. 1990’s - Bra became a highlight on women’s wardrobe.

19 marzec 2017, godz. 4:26

Now, if you are looking for such a brand, you should consider the Bourne shoes. You should always seek advice from someone who has purchase the original boots before. The Fashion Industry is totally focused on how people look and larger people do not figure on mainstream fashion’s radar.

17 marzec 2017, godz. 9:37

Also, they have ruled the market due to their anatomical constructions of shoes that make the shoes anti-stress with special shock absorption system. All footwear at Bourne is hand-crafted especially by Opanka construction and the use of adhesives and machinery is minimal while creating the shoes, thus making the designs eco-friendly. Right from the beginning the company had earned great reputation thanks to the quality of its shoes.

14 marzec 2017, godz. 10:16

The brand of Moda in pelle provides extremely stylish, durable and comfortable shoes. All footwear at Bourne is hand-crafted especially by Opanka construction and the use of adhesives and machinery is minimal while creating the shoes, thus making the designs eco-friendly. The cable breaking system is also new feature added to the line of three wheel strollers.

14 marzec 2017, godz. 1:39

The brand of Moda in pelle provides extremely stylish, durable and comfortable shoes. Thread and stitching - thread used in stitching is always the same as the colour of the leather. The cable breaking system is also new feature added to the line of three wheel strollers.

8 marzec 2017, godz. 3:38

So, it is necessary that you plan your shoe budget before buying one. Bourne’s President, Thomas Mc - Claskie, always uses his creative imagery to make trendy shoes for men. Fresh pairs of UGG products arrive in latest designs and fake boots are replicas of these originals.

26 luty 2017, godz. 3:44

Many of these new creations are about shape and texture as much as color and style. The Unitron website includes detailed description of the features and benefits from this product. Wearing an elegant UGG boot with tight jeans can give you a classy and beautiful look.

25 luty 2017, godz. 7:32

The brand of Moda in pelle provides extremely stylish, durable and comfortable shoes. The Unitron website includes detailed description of the features and benefits from this product. Fresh pairs of UGG products arrive in latest designs and fake boots are replicas of these originals.

25 luty 2017, godz. 5:36

It is not better to select high-heeled shoe, if you are an obese. You should always seek advice from someone who has purchase the original boots before. The cable breaking system is also new feature added to the line of three wheel strollers.

25 luty 2017, godz. 2:02

Most of the girls are choosing the basic sheepskin slip shoes, as they are comfortable and stylish. Style- Most of us looks at the design and style while buying any item. 1990’s - Bra became a highlight on women’s wardrobe.

25 luty 2017, godz. 8:20

Many of these new creations are about shape and texture as much as color and style. They are going to almost any extent to look good and attractive. Fresh pairs of UGG products arrive in latest designs and fake boots are replicas of these originals.

13 luty 2017, godz. 10:41

After his death, the business was successfully carried on by his three sons. Style- Most of us looks at the design and style while buying any item. Choose not only from the styles of the shoes but also make sure that they ate comfortable.

13 luty 2017, godz. 9:13

After his death, the business was successfully carried on by his three sons. All footwear at Bourne is hand-crafted especially by Opanka construction and the use of adhesives and machinery is minimal while creating the shoes, thus making the designs eco-friendly. The Fashion Industry is totally focused on how people look and larger people do not figure on mainstream fashion’s radar.

12 luty 2017, godz. 11:32

Now, if you are looking for such a brand, you should consider the Bourne shoes. Style- Most of us looks at the design and style while buying any item. Choose not only from the styles of the shoes but also make sure that they ate comfortable.

11 luty 2017, godz. 3:14

The brand of Moda in pelle provides extremely stylish, durable and comfortable shoes. The Unitron website includes detailed description of the features and benefits from this product. Toe Size: The right shoe will not only fit well but will also be flexible in the toe area, with enough space for your feet to relax, without being pinched in very tight.

9 luty 2017, godz. 2:19

It is not better to select high-heeled shoe, if you are an obese. You should always seek advice from someone who has purchase the original boots before. The cable breaking system is also new feature added to the line of three wheel strollers.

8 luty 2017, godz. 6:14

I simply want to tell you that I am all new to blogging and definitely savored your web site. Probably I’m likely to bookmark your site . You definitely have tremendous articles. Thanks a bunch for revealing your blog.

7 luty 2017, godz. 3:13

There are hundreds of brands out there manufacturing the shoes. Style- Most of us looks at the design and style while buying any item. Moccasin UGG slippers are quite popular among the men.

5 luty 2017, godz. 12:01

The brand of Moda in pelle provides extremely stylish, durable and comfortable shoes. Media doesn’t really know how to handle it and this was never more clear when we saw the Vogue Italia cover for June 2011. Moccasin UGG slippers are quite popular among the men.

1 luty 2017, godz. 2:34

You can adopt their styles to suit yours; this is one of the best ways to determine the right fashion for you. Media doesn’t really know how to handle it and this was never more clear when we saw the Vogue Italia cover for June 2011. Wearing an elegant UGG boot with tight jeans can give you a classy and beautiful look.

30 styczeń 2017, godz. 3:24

The brand of Moda in pelle provides extremely stylish, durable and comfortable shoes. Media doesn’t really know how to handle it and this was never more clear when we saw the Vogue Italia cover for June 2011. Fresh pairs of UGG products arrive in latest designs and fake boots are replicas of these originals.

30 styczeń 2017, godz. 3:04

The brand of Moda in pelle provides extremely stylish, durable and comfortable shoes. Bourne’s President, Thomas Mc - Claskie, always uses his creative imagery to make trendy shoes for men. Moccasin UGG slippers are quite popular among the men.

26 styczeń 2017, godz. 7:49

It is not better to select high-heeled shoe, if you are an obese. Media doesn’t really know how to handle it and this was never more clear when we saw the Vogue Italia cover for June 2011. Fresh pairs of UGG products arrive in latest designs and fake boots are replicas of these originals.

24 styczeń 2017, godz. 9:44

Many of these new creations are about shape and texture as much as color and style. You should always seek advice from someone who has purchase the original boots before. Choose not only from the styles of the shoes but also make sure that they ate comfortable.

23 styczeń 2017, godz. 9:15

It is not better to select high-heeled shoe, if you are an obese. Bourne’s President, Thomas Mc - Claskie, always uses his creative imagery to make trendy shoes for men. A new kind of wire mixed with natural fabrics, like cotton, provided the perfect adjustment to the body.

23 styczeń 2017, godz. 12:54

Yes! Finally someone writes about ______.

23 styczeń 2017, godz. 9:54

Now, if you are looking for such a brand, you should consider the Bourne shoes. Thread and stitching - thread used in stitching is always the same as the colour of the leather. Choose not only from the styles of the shoes but also make sure that they ate comfortable.

21 styczeń 2017, godz. 10:39

After his death, the business was successfully carried on by his three sons. They are going to almost any extent to look good and attractive. 1990’s - Bra became a highlight on women’s wardrobe.

18 grudzień 2016, godz. 4:45

You can adopt their styles to suit yours; this is one of the best ways to determine the right fashion for you. All footwear at Bourne is hand-crafted especially by Opanka construction and the use of adhesives and machinery is minimal while creating the shoes, thus making the designs eco-friendly. Moccasin UGG slippers are quite popular among the men.

18 grudzień 2016, godz. 4:24

It is not better to select high-heeled shoe, if you are an obese. Style- Most of us looks at the design and style while buying any item. Wearing an elegant UGG boot with tight jeans can give you a classy and beautiful look.

 
| | | |
Copyright © 2006-2013 egrafik.pl | Kontakt | Reklama | Projekty domów
jocker