NaktsSargs Posted April 13, 2007 Report Share Posted April 13, 2007 man interesē tāda lieta kā klasē var izmantot (izsault) citu klasi (citas klases funkciju) ? Link to comment Share on other sites More sharing options...
andrisp Posted April 13, 2007 Report Share Posted April 13, 2007 http://lv2.php.net/manual/en/keyword.paama...nekudotayim.php meibī ? Link to comment Share on other sites More sharing options...
NaktsSargs Posted April 13, 2007 Author Report Share Posted April 13, 2007 ideja ir taada ka man ir MYSQL klase un es tagad taisu autorizaacijas klasi un gribu autorizacijas klasē izmantot funkcijas no MYSQL klases. Link to comment Share on other sites More sharing options...
bubu Posted April 13, 2007 Report Share Posted April 13, 2007 offtopiks: keyword.paamayim-nekudotayim.php wtf? :) Link to comment Share on other sites More sharing options...
black Posted April 13, 2007 Report Share Posted April 13, 2007 (edited) <?php class MySQL { function whatever() { $acl = new ACL(); $acl->authorizeMe(); } } Apmēram šādi? Vai arī - kur īsti ir problēma? No wikipedia: The Scope Resolution Operator (::) in PHP is officially called Paamayim Nekudotayim (IPA: [paʔamajim nəkudotajim]). It means 'twice colon' or 'double colon' in Hebrew. Edited April 13, 2007 by black Link to comment Share on other sites More sharing options...
NaktsSargs Posted April 13, 2007 Author Report Share Posted April 13, 2007 kas tas tika domaats bubu ? Link to comment Share on other sites More sharing options...
NaktsSargs Posted April 13, 2007 Author Report Share Posted April 13, 2007 black paldies nebiju iedomaajies meegjinaat klasee defineet klasi es domaaju ka taa aizies veelreiz paldies Link to comment Share on other sites More sharing options...
Delfins Posted April 13, 2007 Report Share Posted April 13, 2007 KUR TU REDZI, ka KLASE tiek definēta KLASĒ? Link to comment Share on other sites More sharing options...
andrisp Posted April 13, 2007 Report Share Posted April 13, 2007 (edited) par to "paamayim-nekudotayim" es arī vienreiz jau sabrīnijos :). Interesanti, kāpēc izstrādātāji šitādu nosaukumu izdomājuši iedot. Edited April 13, 2007 by andrisp Link to comment Share on other sites More sharing options...
vintman Posted April 13, 2007 Report Share Posted April 13, 2007 Andi Gutmans, Zeev Suraski. Laikam viņi kaut kā gribēja pasvitrot no kurienes iet PHP... :) Link to comment Share on other sites More sharing options...
rpr Posted April 14, 2007 Report Share Posted April 14, 2007 saakumaa uztaisi mysql klases obektu, ko padod jaunajai klasei kaa parametru vai global variablu. var arii jaunajai klasei mysql noraaditi kaa extends, bet tad vinjsh taisiis vairaakas konekcijas. Link to comment Share on other sites More sharing options...
john.brown Posted April 15, 2007 Report Share Posted April 15, 2007 (edited) Nu, vispār jau gadījumā ar db klasi ir jāpielieto singletone paterns. Un atrisinās visas problēmas :) class MysqlClass { private static $instance = NULL; static function instance() { // paarbaudam, vai ir izveidots klases eksemplaars if(empty(self::$instance)) { // ja nav, izveidojam self::$instance = new MysqlClass(); } return self::$instance; } private function __construct() { // te konecteejamies ar db } } //-------------------- class Authenticate { function whatever() { $db = MysqlClass::instance(); // te daram visu, ko vajag ar db klassi } } Edited April 23, 2007 by john.brown Link to comment Share on other sites More sharing options...
dmitriy Posted April 15, 2007 Report Share Posted April 15, 2007 labvakar, piem. var ari ta class Db { public function connect() { .... } } class Main{ public function __construct() { global $DB; $DB->connect() } } $DB = new Db(); $M = new Main(); Link to comment Share on other sites More sharing options...
bubu Posted April 15, 2007 Report Share Posted April 15, 2007 dimitry: Protams, ka šāds variants strādātu. Bet šajā variantā ir vairāk iespēju kļūdīties - piemēram aizmirst inicializēt $DB mainīgo, inicializēt to vairākkārt, utt. Link to comment Share on other sites More sharing options...
des Posted April 23, 2007 Report Share Posted April 23, 2007 Nu ja pamanās DB klasi inicializēt vairākkārtīgi, tad jau visa projekta arhitektūra ir kaut kāda stipri kreisa... Link to comment Share on other sites More sharing options...
Recommended Posts