Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
Nobovsko pitanje...plz pomoc :)

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
hrv0j3



Joined: 03 Aug 2007
Posts: 34

PostPosted: 04.02.2009 22:01    Post subject: Nobovsko pitanje...plz pomoc :) Add user to your forum ignore list Reply with quote

Imam funkcije npr.

Code:

function nesto(){

      echo 'nesto';

                         }

function bla(){

      echo 'bla';

                    }


Sad.. recimo da te funkcije nemogu radit bez config.php u kojem je konekcija na bazu $connect = mysql_connect.... itd...

dali postoji nacin da includam config.php tako da ne moram u svaku funkciju ponovo includirat config.php? znaci da ga includam jednom izvan funkcija i da ga funkcije mogu koristit?

tnx!
Back to top
View user's profile Send private message MSN Messenger
ghosap



Joined: 18 Sep 2003
Posts: 79

PostPosted: 05.02.2009 08:38    Post subject: Add user to your forum ignore list Reply with quote

Very Happy
napravis aplikacija.php i u njoj :
include 'konekcija.php';
include 'funkcije.php';

EDIT:
i onda mozes 1) u funkciji koristit global $conn (ne preporučam)
2) ako imas samo jednu konekciju onda je ni netrebas navodit u argumentima
3) objektno orjentirano programiranje Smile (preporučam)

_________________
. . . and when the balance is lost all that is left is the reckening . . .
Back to top
View user's profile Send private message
hrv0j3



Joined: 03 Aug 2007
Posts: 34

PostPosted: 05.02.2009 11:35    Post subject: Add user to your forum ignore list Reply with quote

ok hvala Very Happy

sad sam napravio ovo:
Code:
     public function query($sqlc)
     {
          try
          {
               $this->konekcija();
               $sql = mysql_query($sqlc);
               $num = mysql_num_rows(mysql_query($sqlc));
          }
          catch(exception $e)
          {
               return $e;
          }
          $this->zatvori_konekciju();
          return $sql;
          return $num;
     }


te to koristim na ovaj nacin:
Code:
    $baza = new baza();
   
    $baza->query( "SELECT * FROM ....");

    $login_num = $num;[list][/list]


ali ne dobivam vrijednost $num... di sam sad fulao? =)

p.s. query prolazi,ali mysql_num_query ne

hvala
Back to top
View user's profile Send private message MSN Messenger
snyder



Joined: 21 Dec 2005
Posts: 57
Location: Zagreb

PostPosted: 05.02.2009 14:42    Post subject: Add user to your forum ignore list Reply with quote

khm, ne radi ti dva puta return Smile
ovak napravi unutar klase
Code:

     public function query($sqlc)
     {
          try
          {
              // izbaci ovo i postavi u konstruktor klase
             // nećeš valjda svaki put na queryu radit konekciju na bazu
              // $this->konekcija();
               // ovo ti je resurs
               $this->data = mysql_query($sqlc);
               // ovo ti je broj redova pročitanih (ili obrisanih ili updateanih)
               // sa zadnjom mysql_query funkcijom
               $this->num = mysql_affected_rows();
          }
          catch(exception $e)
          {
               return $e;
          }
          // ovo stavi u __destruct klase, tj. stavi samo mysql_close($this->connection)
          // il kak se vec zove konekcija
          //$this->zatvori_konekciju();
     }


onda ti je ovo kod za query:
Code:

$baza = new baza();
$baza->query( "SELECT * FROM ....");

// resurs ti je $baza->data;
// broj redova ti je $baza->num;

Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group