Jump to content
php.lv forumi

john.brown

Reģistrētie lietotāji
  • Posts

    510
  • Joined

  • Last visited

Posts posted by john.brown

  1. Ir tabulas:

     

    folders: fid | path

     

    folders_ugroups: fid | gid

     

    user_folder: fid | user_id

     

    Un šitāds querijs:

    SELECT DISTINCT f.fid, f.path
    FROM folders AS f, user_folder AS uf, folders_ugroups AS fu
    WHERE (
    f.fid = uf.fid AND uf.user_id =1
    ) OR (
    f.fid = fu.fid AND fu.gid
    IN ( 1, 2 )
    )
    ORDER BY f.path

    Trabls ir tāds, ka, ja iekš user_folder nav ierakstu, tad šamais neko neatgriež. Kaut, pēc domas, vajadzēja atgriezt to, kas sanāk no tabulas folders_ugroups. Var kāds ko līdzet?

     

    P.S. ja iekš user_folder ir kaut 1 ieraksts, atgriež visu, kā bija domāts - gan pec user_folder, gan folders_ugroups.

  2. Domāju ne, tas lieki visu sarežģī. Ievies tabulu 'user_properties', un tad tas būtu tā:

     

    table orders: id | user_id | date

     

    table users: user_id | name | is_registred

     

    table user_properties: user_id | password | last_access |...

     

    Nu, vismaz es tā darītu..

  3. A tev tās tabulas "anonīmie klienti"/"reģistrētie klienti" tik bezjēgā atšķiras? IMHO, jēdzīgi būtu to visu divās tabulās salikt:

    pasūtījumi

    pas_id | user_id | date

    klienti

    user_id | name | is_registred

    Un imho, būtu tev pilnīga laime, jo lauciņš user_type pie pasūtījumiem man izsauuc neveselīgas aizdomas. Un divas tabulas ar useriem, kas atšķiras tik pēc reģistrēts/anonīms ar. Tak, varbūt ar ko nesapratu tavā domā....

  4. He, jau paspēju pats ko strādājošu sacerēt. Vismaz pagaidām tā izskatās...

    $data = array('folder_1','folder_1/folder_1_1','folder_1/folder_1_2','folder_2/folder_2_1');
    
    $items = array('name' => 'root','path' => '','tree' => array());
    
    foreach($data as $path) {
    	$parts = explode('/',$path);
    	$curr_node = & $items;
    	$item_path = '';
    	do{
    		$p = array_shift($parts);
    		$item_path.= '/'.$p;
    		if(!isset($curr_node['tree'][$p])) {
    			$curr_node['tree'][$p] = array('name' => $p, 'path' => $item_path,'tree' => array());	
    		}
    		$curr_node = & $curr_node['tree'][$p];	
    	}while($parts);	
    }
    echo '<pre>';
    print_r($items);

     

    Varbūt kādi ieteikumi uzlabošanas jomā? Vai pavisam kā prastāk?

  5. Tātad dabonu es no db ierakstus ar ceļiem uz mapītēm:

    folder_1
    folder_1/folder_1_1
    folder_1/folder_1_2
    ...

    Gribētos uztaisīt no šamiem smuku masīvu, apm. tādu:

    $items = array(
    'folder_1' => array('path' => $path,
    				'name'=> $name,
    				'tree' => array(
    								'folder_1_1' => array('path' => $path,
    													  'name' => $name, 
    													  'tree' => array()), 
    								'folder_1_2' =>	array('path' => $path,
    													  'name' => $name, 
    													  'tree' => array())
    								)
    			)
    );

    Piedevām, var būt situācija, kad tanī sarakstā ir folder_2/folder_2_1, bet nav folder_2. Esmu baigi iebremzējies, un galīgi nesaprotu, ka to smuki dabūt gatavu. Moš, var kāds palīdzēt ar idejām?

  6. Imho, piekrītu Delfins, ka esi nedaudz saputrojies klasēs. Uz ātro, šiet ir lieki mantot no DBObject - tai vajadzēetu būt pastāvīgai klasei...

    Tak, ja reizēm rodas vajadzība pec kaut kā līdzīga "multiple inheritance", var risinat divējādi:

    1) veidot mantošanas ķēdīti

    abstract class A {
    public function Afunction() {}
    }
    class B extends A {
    ...
    }
    class C extends B {
    ...
    }

    2) deleģēt funkcijas

    class A {
    public function Afunction() {}
    }
    class B {
    public function Bfunction() {}
    }
    class C {
    private $a = NULL;
    private $b = NULL;
    
    public function __construct() {
    	$this->a = new A();
    	$this->b = new B();
    }
    public function __call($func,$args) {
    	if(method_exists($this->a,$func) {
    		$this->a->$func($args);
    	}
    	elseif(method_exists($this->b,$func) {
    		$this->b->$func($args);
    	}
    	else {
    		throw new Exception('Undefined method "'.$func.'" called');
    	}
    }
    }

  7. 2 Kristabs

    Jā, droši vien apgūt Postgre prieka pēc nevajag. It sevišķi, ja zini Mysql. Tak viņām abam ir viena kopēja īpašība - viņas abas ir relācijas datu bāzes. Un abām normālai datu organizešanai ir prasība pēc 3. normālformas... ;) Tā kā nekāda dirš*na te nav - Robis nodemonstrēja elementāru kopējo relācijas datu bāžu principu nezināšanu ;) Un uzdevums nebūt nebija kas ļoti kruts - diezgan parasta situācija...

  8. A $_REQUEST vairs neeksistē? tak jēdzīgāk laikam tomēr šo apstrādāt :)

    Jo pēc tam es uzraskstīju print_r($_GET);

    Nu bet loģiski - piemērā tik $_POST ir apstrādāts. $_GET atsevišķi vajag pēc tā paša algoritma ;)

    Un tu ko, login datus caur get padod? Jocīgi bik ;)

  9. Dotajā gadījumā mani vairāk interesēja aprakstoša atbilde, tipa "atradu visus ātri no win update saita" vai "mocījos ilgi, un ne velna neatradu" :) Skaidrs, ka neviens nnevar pateikt - jā, ir visi tavam nezināmajam dzelzim... Tak kopējā tendence, ja tā var teikt...

  10. Stādīju te uz jaunas mašīnas php5.1.4 un apache2.0.52. Php liku kā moduli. Uz vecās tāda kombinācija strādāja bez problēmām, tak tagad pie apacha palaišanas izlamājas, ka php nevar atrast nevienu extensiju, kaut ceļš norādīts pareizi. Un dīvainākais tas, ka pēc visas lamāšanās, iet ar visām extensijām... Nācās atslēgt startup errorus, tak tomēr gribētos saprast, kas par g... Kāds ir saskāries ar ko līdzīgu?

     

    P.S. apacha error loga gaabals izskatās sita:

     

    [Fri Oct 06 16:23:25 2006][notice] Parent: Created child process 3924

    PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\php\\ext\\php_curl.dll' - The specified module could not be found.\r\n in Unknown on line 0

    PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\php\\ext\\php_fdf.dll' - The specified module could not be found.\r\n in Unknown on line 0

    PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\php\\ext\\php_interbase.dll' - The specified module could not be found.\r\n in Unknown on line 0

    PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\php\\ext\\php_ldap.dll' - The specified module could not be found.\r\n in Unknown on line 0

    PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\php\\ext\\php_mcrypt.dll' - The specified module could not be found.\r\n in Unknown on line 0

    PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\php\\ext\\php_mhash.dll' - The specified module could not be found.\r\n in Unknown on line 0

    PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\php\\ext\\php_mssql.dll' - The specified module could not be found.\r\n in Unknown on line 0

    PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\php\\ext\\php_openssl.dll' - The specified module could not be found.\r\n in Unknown on line 0

    PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\php\\ext\\php_imagick.dll' - The specified module could not be found.\r\n in Unknown on line 0

    [Fri Oct 06 16:23:33 2006] [notice] Child 3924: Child process is running

    [Fri Oct 06 16:23:33 2006] [notice] Child 3924: Acquired the start mutex.

    [Fri Oct 06 16:23:33 2006] [notice] Child 3924: Starting 250 worker threads.

×
×
  • Create New...