[PHP] Divide into words

2002-12-16 Thread Uros Gruber
Hi!

For example i have some words:

Today is very beautiful day and sun is shining

What i want to get from this is array

words
 [Today] => 0
 [Is] => 6,30
 [Very] => 8
 [beautiful] => 12
 ..

Can somebody please help me with this. Those nubers are
position of special word in above sentence. If word repeates
i want to have both positions saved in same row like word is.

I tried something but i think it's to lame.


-- 
bye,
 Uros


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re[2]: [PHP] Divide into words

2002-12-16 Thread Uros Gruber
Hi!

I have dome almost the same

$input = 'Today is a very beautiful day and the sun is shining';

$output = array();
$words = explode(' ',$input);

$cur_pos = 0;
foreach($words as $word) {
if(!empty($output[$word])){
$output[$word] .= ','.$cur_pos;
} else {
$output[$word] = $cur_pos;
}
$cur_pos += strlen($word) + 1;
}
unset ($word);


but i thought if there is some better way. I also tried
Marco's example and adjust it a little bit to get the same
results. And here is some benchmark i have.

with this example i get  0.0024310350418091
and with Marco's i get 0.0034389495849609s

So using two array is faster anyway. Probably of explode
speed.

-- 
bye,
 Uros
Monday, December 16, 2002, 6:36:37 PM, you wrote:

>> For example i have some words:
>> 
>> Today is very beautiful day and sun is shining
>> 
>> What i want to get from this is array
>> 
>> words
>>  [Today] => 0
>>  [Is] => 6,30
>>  [Very] => 8
>>  [beautiful] => 12
>>  ..
>> 
>> Can somebody please help me with this. Those nubers are
>> position of special word in above sentence. If word repeates
>> i want to have both positions saved in same row like word is.
>> 
>> I tried something but i think it's to lame.

JWH> Well you could've at least shown us what you had so far instead of
JWH> letting us solve the problem for you:

JWH> $string = "Today is a very beautiful day and the sun is shining";

JWH> $words = explode(" ",$string);
JWH> $pos = 0;

JWH> foreach($words as $word)
JWH> {
JWH> if(isset($w[$word]))
JWH> { $w[$word] .= ",$pos"; }
JWH> else
JWH> { $w[$word] = $pos; }

JWH> $pos += strlen($word) + 1;
JWH> }

JWH> print_r($w);

JWH> ---John W. Holmes...

JWH> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
JWH> today. http://www.phparch.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] text parser

2002-12-20 Thread Uros Gruber
Hi!

I wan't to know if there is any goor text parser around here
written in php. I'm asking before i create my own.

I would like extract some text msgs to words and i would also
like take care of stop words, special characters etc... So to
know if some word is regular word, or if is number, html tag,
html entry.


-- 
tia,
 Uros


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] detaching

2003-07-08 Thread Uros Gruber
Hello!

first my code

#!/usr/local/bin/php -q



I read that posix_setsid return pid on succesfull detaching. But i get
-1. I read man for setsid and this -1 mean error.

What i want is that if i run this  script with automatic detaching.
But it does nothing than waiting this for to finish.

What am I doing wrong.
  

-- 
lp,
 Uros  mailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re[2]: [PHP] config tests

2003-08-10 Thread Uros Gruber
Hi,

You don't need to do that way. I also test speed if you select for
example 5 diferent values. You get 5 queries.

I just select everything in one place then I use

$config['config_color']

or you can write some function getConfig('config_color') to get
selected value from this array.

I use text to store this because there's no need to index this.

I also make some script to easy add and remove config values.

But I agree with you that 1st one is more flexible.

-- 
Best regards,
 Uros
 
Sunday, August 10, 2003, 10:32:13 AM, you wrote:

JWH> Uros Gruber wrote:

>> Hello!
>> 
>> I just made some speed tests getting configuration from DB.
>> 
>> For now I figured 2 ways doing this.
>> 
>> 1. One value in each row
>> 
>> id   |   name| val
>> --
>> 1| name1 | value1
>> 
>> 
>> 2. using serialize($config) and saving this in one row.
>>$config is predefined array of configuration.
>> 
>> 
>> I test this with 100 config values. First I read all 100 rows for 1st
>> example, then I read only one row and then unserialize this to get
>> array.
>> 
>> Here is result:
>> 
>> 1st example 0.0478450059891 86.74%
>> 2nd example 0.0073139667511 13.26%
>> 
>> There you can see speed of second example. I wan't to know what do you
>> think about this. And what's your solutions of reading config from DB.
>> I saw that many big project still use first example.
>> 

JWH> Question: How many people selected 'blue' for their config color?

JWH> 1. SELECT COUNT(*) FROM Table WHERE config_color = 'blue';

JWH> 2. ?? SELECT COUNT(*) FROM Table WHERE serialized_column LIKE 
JWH> '"config_color";s:4:"blue";'

JWH> Basically, method 1 is more flexible. With method 2, you'll need to 
JWH> store it in a TEXT column or hope your serialized value never goes over 
JWH> 255 characters.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re[2]: [PHP] Image Header

2003-08-11 Thread Uros Gruber
Hello,

Monday, August 11, 2003, 10:42:58 PM, you wrote:

CS> --- Uros Gruber <[EMAIL PROTECTED]> wrote:
>> I made some php script to get Header from http request. When I
>> request some image header looks like:
>> Content-Type: text/html

CS> Your instincts serve you well. You want the Content-Type header to be correct,
CS> as you are currently telling the Web client that you are sending HTML, and then
CS> (I assume) dumping a bunch of binary data.

>> Image showed correctly

CS> On what browser? IE has earned a poor reputation for its disregard for content
CS> type, so IE's bug may be conveniently counteracting your own by coincidence.
On both mozzila and IE.


>> here is code I have in img.php
>> 
>> $size = getimagesize ($file);
>> header("Content-type: {$size['mime']}");

CS> OK, I see that the documentation is somewhat confusing here (I may try to fix
CS> this). The key phrase in the manual preceding this example is:

CS> "Beginning with PHP 4.3, getimagesize() also returns an additional parameter,
CS> mime, that corresponds with the MIME type of the image."

CS> So, before we continue, can you tell us what version of PHP you are using? You
CS> might want to just do this:

Server: Apache/1.3.27 (Unix) PHP/4.3.1
I check that i get correct MIME, so header is OK. Also if i manualy
set to jpeg, nothing helps.

CS> header('Content-Type: image/jpeg');

I think I'm stuck here.

best regards

Uros


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] php+apache+accelerator

2003-08-14 Thread Uros Gruber
Hello!

I installer php and apache on many computers. I also try some of
accelerators (phpaccelerato and turckmmcache). And I found some
strange bahaviour about apache server. I didn't find any solution yet.

Here is the problem.

Apache server gets core dump whenever I have any php_admin... stuff in
virtual host. If I disable accelerator there's no such problem and
also if I enable it and remove all php_admin.. tags out of virtual
hosts it also works.

I get core dump only when i use apachectl graceful, restart or http -S
or apachectl configtest. If I use stop and start there's no problem at
all. There's nothing in logs, so I'm asking you guys If anyone had
such problem.

I use FreBSD from 4.7 to 5.1 apache 1.3 with mod_ssl and PHP version
from 4.3x and 4.2x. I tested with all this versions and there's no
diference. I test many things and now I'm without any.

I can't figure out who makes problem. Maybe any module of apache,
apache itself, php, accelerator, os.

Any suggestions how to start searching the ghost.

tia

Uros

P.S. can somebody resend this to maybe apache list, because I'm not
subscribed to it.
  

-- 
lp,
 Uros  mailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Image Header

2003-08-14 Thread Uros Gruber
Hi!

I don't know if this is ok, so can somebody give me some explanation.

I made some php script to get Header from http request. When I request
some image header looks like:

HTTP/1.1 200 OK
Date: Mon, 11 Aug 2003 17:24:14 GMT
Server: Apache/1.3.27 (Unix) PHP/4.3.1
Last-Modified: Fri, 25 Oct 2002 09:37:57 GMT
ETag: "1cd2ce-1253f-3db910f5"
Accept-Ranges: bytes
Content-Length: 75071
Connection: close
Content-Type: image/jpeg
===

Then I made some php script to showing images and when i request for
example img.php?name=somejpg.jpg header looks like this:


HTTP/1.1 200 OK
Date: Mon, 11 Aug 2003 17:24:14 GMT
Server: Apache/1.3.27 (Unix) PHP/4.3.1
X-Powered-By: PHP/4.3.1
Connection: close
Content-Type: text/html
===

Why?. Image showed correctly and here is code I have in img.php


=

$file = $_GET['name'];

if (ereg('(\.\.)^(\/+)',$file)) {
die();
}

$file = dirname(__FILE__).'/'.$file;
$size = getimagesize ($file);
$fp = fopen($file, "rb");

if ($size && $fp) {
  header("Content-type: {$size['mime']}");
  fpassthru($fp);
  exit;
} else {

}

So I set Content-type: but on request is html/text. And one more
question. Is it possible that IE or mozzila cache those kind of
images. For example that I ser Cache header option..

-- 
tia,
 Uros


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] config tests

2003-08-14 Thread Uros Gruber
Hello!

I just made some speed tests getting configuration from DB.

For now I figured 2 ways doing this.

1. One value in each row

id   |   name| val
--
1| name1 | value1


2. using serialize($config) and saving this in one row.
   $config is predefined array of configuration.


I test this with 100 config values. First I read all 100 rows for 1st
example, then I read only one row and then unserialize this to get
array.

Here is result:

1st example 0.0478450059891 86.74%
2nd example 0.0073139667511 13.26%

There you can see speed of second example. I wan't to know what do you
think about this. And what's your solutions of reading config from DB.
I saw that many big project still use first example.

-- 
Best regards,
 Uros


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] What to use for multilanguage

2002-09-30 Thread Uros Gruber

Hi!

I'm developing some CMS engine and right now i'm at designing
multilanguage feature.

I nee some advices what is the best way to solve this. What
is with memory because if i have some big language files etc.

What to use, pure php, db, gettext. What about speed.

Any ideas would be good.
  

-- 
tia,
 Uros  mailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] DB speed

2002-10-10 Thread Uros Gruber

Hi!

 I'm making some testing over DB.php  (PEAR)

 And i wan't to know if this is normal.

 I've made some script where I connect do SQL server
 and execute one simple (1row) query.

 I use pgsql and mysql. tables and indexes are same for both
 servers. So test table is identical

 Whe i execute those script i get some timing results

PGSQL
Total time: 0.0576
Execution time: 0.0185

MySQL
Total time: 0.0086
Execution time: 0.0028 

Time is in seconds.

My machine is PIII 333 MHz with 128MB RAM. I table is only 3
rows of data.

I want to know why is sucsh diference. Both servers runing
with socket connections and using connnect (non-persistant)

-- 
tia,
 Uros  mailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re[2]: [PHP] DB speed

2002-10-10 Thread Uros Gruber

Hi!

I make some more test for this.

When i enable pconect (persistant) the result amazed me.

PGSQL
Total time: 0.0070
Execution time: 0.0034
MySQL
Total time: 0.0072
Execution time: 0.0027

Now PGSQL is as fast as mysql or maybe a lile slower.
So is this normal that non-persistant is so much overhead for
pg. Is there any tools to check this. Or is some kind of a
bug in php. I use 4.2.3. And pg is 7.2.1. Can somebody make
some test. I can send script what i've run.


-- 
tia,
 Urosmailto:[EMAIL PROTECTED]


Friday, October 11, 2002, 5:09:31 AM, you wrote:

t> I think i read something a while ago, about mysql being faster, having
t> less features, but postgres being a little slower but able to handle
t> LARGE databases better than mysql. I could be wrong, so dont take my
t> word for it. At the end of the day they are both good db's.

t> On Thu, 2002-10-10 at 09:02, Simon Taylor wrote:
>> Well obviously - cos MySQL rocks!!, but seriously I also did some tests and
>> got variable results from different db's - even got an odbc connection to
>> access to run faster than mysql at one stage!! - something tells me there
>> are other factors contributing..
>> Cheers
>> Simon
>> 
>> -Original Message-
>> From: Uros Gruber [mailto:[EMAIL PROTECTED]] 
>> Sent: 10 October 2002 14:17
>> To: [EMAIL PROTECTED]
>> Subject: [PHP] DB speed
>> 
>> 
>> Hi!
>> 
>>  I'm making some testing over DB.php  (PEAR)
>> 
>>  And i wan't to know if this is normal.
>> 
>>  I've made some script where I connect do SQL server
>>  and execute one simple (1row) query.
>> 
>>  I use pgsql and mysql. tables and indexes are same for both  servers. So
>> test table is identical
>> 
>>  Whe i execute those script i get some timing results
>> 
>> PGSQL
>> Total time: 0.0576
>> Execution time: 0.0185
>> 
>> MySQL
>> Total time: 0.0086
>> Execution time: 0.0028 
>> 
>> Time is in seconds.
>> 
>> My machine is PIII 333 MHz with 128MB RAM. I table is only 3 rows of data.
>> 
>> I want to know why is sucsh diference. Both servers runing
>> with socket connections and using connnect (non-persistant)
>> 
>> -- 
>> tia,
>>  Uros  mailto:[EMAIL PROTECTED]
>> 
>> 
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
>> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] ob_output

2002-11-22 Thread Uros Gruber
Hi!

here is my test code

";


ob_end_flush();

sleep(2);
}

?>  

I can make this work on php and apache. I always get output
in one shot not line by line. If i try this code with php and
iis it works.

What am i doing wrong. Do i have to tell apache to send line
by line to browser not everything together.

-- 
lp,
 Uros


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re[2]: [PHP] ob_output

2002-11-22 Thread Uros Gruber
Hi!

I changed it to ob_flush() and the problem still exist.

Check the link and you'll se.
http://www.kud-igen.si/link.php


I have 3 apache servers and no one works as i want to. But
iis makes no problems.

-- 
bye,
 Uros


Friday, November 22, 2002, 8:32:56 PM, you wrote:

CW> On Fri, 22 Nov 2002, Uros Gruber wrote:

>> ob_end_flush();

CW> This turns off output buffering after flushing, the first time it gets
CW> called in the first iteration of your for() loop.

>> I can make this work on php and apache. I always get output
>> in one shot not line by line. If i try this code with php and
>> iis it works.

CW> Try using ob_flush() instead.  http://www.php.net/ob_flush
CW> "This function does not destroy the output buffer like ob_end_flush()
CW>  does."

CW> What's odd is that it works like you want it to in IIS 

CW> g.luck,
CW> ~Chris


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] help with some class problem

2002-06-19 Thread Uros Gruber

Hi!

i'm making some modular aplication. I have one base class for
example:

class Main {

  function loadmod($name,&$mod) {
$mod = new $name; // load module
  }
}

In module class i want to use some properties from main
module, but i don't know how to solve this. But i don't want
extend all module from main class,

i call modules like this.

first i initialize main class

$main = new Main;
$main->loadmod('testmodule',$m);

and when i wan't to call some function from it i call

$m->modulFunction(arg);

i also don't know if this is right way to do this, but my
point is that i want to have some main class on wich i buld
modules, this modules use some properties en methods from
main class like dbacces, configuration 


And also i don't want this to be slower everytime i add ne
module.

any ideas

-- 
bye,
 Uros  mailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Speed tests? RAM usage displays?

2002-06-20 Thread Uros Gruber

Hi!

Thursday, June 20, 2002, 10:56:40 PM, you wrote:

PS> Is there any way to determine script's memory usage?

When you configure and compile you have some option
--with-memory-limit  something like that and then add

\"%{mod_php_memory_usage}n\"

in you http.conf of Apache where you define how log files
look like.


PS> What about execution time in ms (with breakpoints)?
PS> And is there way to measure MySQL query speed in ms?

u can use microtime function

function getMicrotime()
{
list($usec, $sec) = explode(" ",microtime()); 
return ((float)$usec + (float)$sec); 
}

in your head of your script than call:

$start = getMicrotime();

and then in the end of script

$stop = getMicrotime();
$diff = $stop - $start;
echo "Execution time was: ".$diff;

You can also use Benchmark module from PEAR there is also
support for markers.

-- 
lp,
 Urosmailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Very slow pg access

2002-06-21 Thread Uros Gruber

Hi!

i made some benchmarks because my script is somehow very
slow. In this script i execute 3 queries to PostgreSQL server
and one connect string. I connect to socket.

I check this queries in pg with explain analyze and i have
result 1.18ms so i add a little and let say that for those 3
queries need 2ms. (1 simple select, 1 delete, 1 insert)


When i check from PHP i use microtime() to check times.

Here is results

0.0443  for connect
0.0343  1 querydelete
0.0034  2 queryselect
0.0049  3 queryTHIS ONE is INSERT OR UPDATE

0.087 TOTAL

so complete time is about 0.090 s this is 90ms against 2ms. I
thik that this is not normal. or is PHP so slow or there is
something wrong with libraries

I use PHP 4.1.2 and pg 7.2.1

Any thoughts.

-- 
tia,
 Uros  mailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re[2]: [PHP] Very slow pg access

2002-06-22 Thread Uros Gruber

Hi!

Sunday, June 23, 2002, 1:21:07 AM, you wrote:


F> I find it impossible that PHP should be "slow". PHP's Pg functions are - 
F> and shouldn't be - nothing more or else than a frontend to the Pg API.

F> The problem is most likely that you are not comparing the same values. I 
F> think the analyze values are calculated "internal" values that has little 
F> to do with real life through an API.

F> Postgres is very fast - but a connect and 3 queries in 0.002 ms? Hmmm!
i didn't say 0.002 ms i say 0.002 s this is 2ms, but from php
that time was 90ms

I also use one patch for realtimer in pg, it say max 10ms.
without connect, but i don't thik that for connection is user
like 80ms,

I thik that here must be something wrong, or with some lib,
I realy don't know, so i'm asking on that list for help to
solve this.

Btw computer is PII300MHz with 128MB RAM, but in this table
is for now from 0 to 15 entries.


-- 
lp,
 Urosmailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Whos online at the moment in PHP

2002-06-23 Thread Uros Gruber

Hi,

I've ma some atuh system to do such thing beside other
special functions, u have to store some session ids in some
db and then refresh timestamp for those session wich is still
active other delete after 30min or some other time.

-- 
bye,
 Urosmailto:[EMAIL PROTECTED]


Sunday, June 23, 2002, 3:53:46 PM, you wrote:


P> Is it possible to code in PHP a small indicator on a site saying how many 
P> people are viewing that page at the moment?
P> Sorry if its a silly question, but i am a newbie at PHP. If it is, could 
P> you point me in the good direction? i mean, some function or something.
P> Thanks.

P> Pag


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Timeout and fsockopen

2003-09-16 Thread uros . gruber
Hello!

I'm trying to find if some host is up or not.

For example

$fp = @fsockopen ('www.damirjosar.com', 80, $errno, $errstr, 1);

because this url is expired it takes about 10 seconds to get response from
DNS, but with fsockopne it take 62 seconds. but i set timeout to 1.

I also try checkdnsrr and gethostbyname and all functions takes about 60
seconds. Why?. Can this be set to lover value.

I was looking in source code, but I'm not good at C, so I can't figure out
what the problem is.
  
I'm doing some link checker and when i get to host like this everything
stops and waits


-- 
Best regards,
 uros

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Fwd: MMCache segmentation faults

2003-11-17 Thread Uros Gruber
Subject: MMCache segmentation faults

===8<==Original message text===
Hello!

I send this to [EMAIL PROTECTED]  but It was returned. So I'll ask here if somebody 
have any idea.

I upgrade my php and mmcache (php 4.3.4 and mmcache 2.4.6) and
I have a lot of

[Mon Nov 17 13:49:17 2003] [notice] child pid 32974 exit signal Segmentation fault (11)
[Mon Nov 17 13:49:18 2003] [notice] child pid 32767 exit signal Segmentation fault (11)
[Mon Nov 17 13:49:19 2003] [notice] child pid 33282 exit signal Segmentation fault (11)
[Mon Nov 17 13:49:20 2003] [notice] child pid 33289 exit signal Segmentation fault (11)
[Mon Nov 17 13:49:22 2003] [notice] child pid 33291 exit signal Segmentation fault (11)
[Mon Nov 17 13:49:24 2003] [notice] child pid 33346 exit signal Segmentation fault (11)

messages in my apache error log.

server is FreeBSD 5.1 Release.

my php.ini

zend_extension="/usr/local/lib/php/20020429/mmcache.so"
mmcache.shm_size="16"
mmcache.cache_dir="/tmp/mmcache"
mmcache.enable="1"
mmcache.optimizer="1"
mmcache.check_mtime="1"
mmcache.debug="0"
mmcache.filter=""
mmcache.shm_max="0"
mmcache.shm_ttl="0"
mmcache.shm_prune_period="0"
mmcache.shm_only="0"
mmcache.compress="1"
mmcache.keys="shm_and_disk"
mmcache.sessions="shm_and_disk"
mmcache.content="shm_and_disk"

I delete cache folder when I upgrade. If i remove mmcache from php.ini
there's no problems. But strange is that pages load normaly.
  

-- 
Best regards,
 Uros  mailto:[EMAIL PROTECTED]


===8<===End of original message text===



-- 
lp,
 Uroš

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] directory browsing

2002-05-01 Thread Uros Gruber

Hi!

I wan't to make directory browsing like yahoo or google over
categories.

For example look on
http://www.google.com/dirhp

I have made myself 2 diferent ways. One is quicker but more
complex and oher is slower but easy to read and understand.

In my table i have this colums

id_cat, name, id_parent, level

What i want to know is if anybody have done this and how. I
want to know if i'm doing right way or is there another way.

1.) In my first way i fisrt select data from db with
condition where id_parent='some_category'.

Then i recursively run thru array of id_cat's which i have
from previsious query. And get data for sub categories.

This method is simple to program but it's slow on many
categories.

2.) second way i use colum level to help get second query.
First query is the same as on 1st example. In second query i
select all categories which is one level lower than this i'm
id. But then i have to program to delete all neceseary data
from this array.

This method was quicker but more complex.

I hope this is understandable. I wan't to know how to code
this. Is there maybe another way (better way) to solve this.
Is maybe somewhere class for this.
  

-- 
tia,
 Uros


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Localization support

2002-02-24 Thread Uros Gruber

Hi!

I hope this is right address to get some help about this.

I tried many ways to get working locales, but nothing works.

My OS is FreeBSD 4.5 and php i use is 4.1.1.

I want to get slovenian locale working
If I set LC_ALL in my environment and if i type date for example in
shell everything is OK, i see date printet in my language.

but when i type this i PHP

setlocale(LC_ALL, 'sl_SI.ISO_8859-2');
echo "";
print_r(localeconv());

i get output like this

Array
(
[decimal_point] => .
[thousands_sep] => 
[int_curr_symbol] => 
[currency_symbol] => 
[mon_decimal_point] => 
[mon_thousands_sep] => 
[positive_sign] => 
[negative_sign] => 
[int_frac_digits] => 127
[frac_digits] => 127
[p_cs_precedes] => 127
[p_sep_by_space] => 127
[n_cs_precedes] => 127
[n_sep_by_space] => 127
[p_sign_posn] => 127
[n_sign_posn] => 127
[grouping] => Array
(
)

[mon_grouping] => Array
(

but it has to be like this


Array
(
[decimal_point] => ,
[thousands_sep] => .
[int_curr_symbol] => SIT
[currency_symbol] => SIT
[mon_decimal_point] => ,
[mon_thousands_sep] => .
[positive_sign] => 
[negative_sign] => -
[int_frac_digits] => 2
[frac_digits] => 2
[p_cs_precedes] => 0
[p_sep_by_space] => 1
[n_cs_precedes] => 0
[n_sep_by_space] => 1
[p_sign_posn] => 1
[n_sign_posn] => 1
[grouping] => Array
(
[0] => 3
)

[mon_grouping] => Array
(
[0] => 3
)

I tried exact code on window2000 and i get second output, so on
windows works this but on unix does not.

There is also strange thig about nameing locales. Somewhere i have to
use only sl or slv, somwhere sl_SI or maybe like here
sl_SI.ISO_8859-2. Shouldn't be this somehow standard. So if i move my
code on other machine nothing would work or what.

Plese if someboday can help me or have some good doc.

-- 
lp,
 Uros  mailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] SQL and PHP (socket vs TCP)

2002-02-26 Thread Uros Gruber

Hi!

Yesterday i noticed some strange thing with connection PHP to
postgreSQL. I have some script to tell me how long does it take to
generate some page.

And i noticed that this time is longer if i connect to socket. Isn't
this a little strange. I know that connection to socket must be
quicker that on IP.

Is there something that i don't know.
  

-- 
TIA,
 Uros


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] BUG in recursion

2002-03-30 Thread Uros Gruber

Hi!

This is a code

function Test()
{
static $count = 0;

$count++;
echo $count;
if ($count < 10) {
Test ();
}
echo "j";
}
test();

Output is

12345678910jj

Why is there 10 j at the and. If this would work it can be
only one. If $count is grater than 10 it does not call itself
but end. Is this maybe a bug or what.
  

-- 
lp,
 Uros  mailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re[2]: [PHP] BUG in recursion

2002-03-30 Thread Uros Gruber

Hi!

This I simply don't understand why this code executes that
way. So there is only inportant to put return after recursive
call and it works like i wan't. I sometimes write small C
programs and I don't remeber that code like this have to work
that way Hm.



-- 
bye,
 Urosmailto:[EMAIL PROTECTED]


Sunday, March 31, 2002, 1:10:30 AM, you wrote:

LTW> On Sat, 2002-03-30 at 15:59, Uros Gruber wrote:
>> Hi!
>> 
>> This is a code
>> 
>> function Test()
>> {
>> static $count = 0;
>> 
>> $count++;
>> echo $count;
>> if ($count < 10) {
>> Test ();
>> }
>> echo "j";
>> }
>> test();
>> 
>> Output is
>> 
>> 12345678910jj
>> 
>> Why is there 10 j at the and. If this would work it can be
>> only one. If $count is grater than 10 it does not call itself
>> but end. Is this maybe a bug or what.

LTW> No, there should be 10 of them, since every time Test() returns,
LTW> the function carries on executing. If you only want one 'j'
LTW> printed then put a return statement after the call to Test():

LTW> function Test()
LTW> {
LTW> static $count = 0;

LTW> $count++;
LTW> echo $count;
LTW> if ($count < 10) {
LTW> Test();
LTW> return;
LTW> }
LTW> echo "j";
LTW> }
LTW> Test();


LTW> Cheers!

LTW> Torben


LTW> -- 
LTW>  Torben Wilson <[EMAIL PROTECTED]>
LTW>  http://www.thebuttlesschaps.com
LTW>  http://www.hybrid17.com
LTW>  http://www.inflatableeye.com
LTW>  +1.604.709.0506


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re[4]: [PHP] BUG in recursion

2002-03-30 Thread Uros Gruber

Hi,

Ok, no I understand why. So this explains why every function
must have return. But how can i program for example one
recursion or where to put return so that test would not be
waiting for return but at the end of this recursion i would
like to do something with that $count for example.

Hmm i wrote this very strange i hope you understand.

I tell it simpler.

I would like something is executed x many times (for such
long if sentence is true) and thene do sometnihg else and
continue with program, not looping here.

-- 
tia,
 Urosmailto:[EMAIL PROTECTED]


Sunday, March 31, 2002, 1:34:20 AM, you wrote:

LTW> On Sat, 2002-03-30 at 16:16, Uros Gruber wrote:
>> Hi!
>> 
>> This I simply don't understand why this code executes that
>> way. So there is only inportant to put return after recursive
>> call and it works like i wan't. I sometimes write small C
>> programs and I don't remeber that code like this have to work
>> that way Hm.

LTW> Well, that's how it's supposed to work. Look at it like this:

LTW> 1: function test() {
LTW> 2:static $count = 0;
LTW> 3:$count++;
LTW> 4:echo $count;
LTW> 5:if ($count < 10) {
LTW> 6:test();
LTW> 7:}
LTW> 8:echo 'j';
LTW> 9: }


LTW> So the first thing that happens is you call test(). It executes
LTW> its lines in order, including function calls. When it hits the
LTW> call to test() on line 6, it calls test(), waits for it to 
LTW> return, and then continues on to line 8, echoing 'j'. 

LTW> This happens every time through, so when you get up to $i == 10, you
LTW> have 10 test()s stacked up, each of them waiting on line 6 for the
LTW> function call to test() to return. As each test() call returns,
LTW> execution continues on to line 8, echos j, then returns.

LTW> I'm in a hurry so I don't have too much time to make this much 
LTW> clearer (and my brain is not so good today anyway). If this still
LTW> doesn't make sense then Google gives a zillion hits for 'introduction
LTW> to recursion'.


LTW> Hope this helps,

LTW> Torben

>> -- 
>> bye,
>>  Urosmailto:[EMAIL PROTECTED]
>> 
>> 
>> Sunday, March 31, 2002, 1:10:30 AM, you wrote:
>> 
>> LTW> On Sat, 2002-03-30 at 15:59, Uros Gruber wrote:
>> >> Hi!
>> >> 
>> >> This is a code
>> >> 
>> >> function Test()
>> >> {
>> >> static $count = 0;
>> >> 
>> >> $count++;
>> >> echo $count;
>> >> if ($count < 10) {
>> >> Test ();
>> >> }
>> >> echo "j";
>> >> }
>> >> test();
>> >> 
>> >> Output is
>> >> 
>> >> 12345678910jj
>> >> 
>> >> Why is there 10 j at the and. If this would work it can be
>> >> only one. If $count is grater than 10 it does not call itself
>> >> but end. Is this maybe a bug or what.
>> 
>> LTW> No, there should be 10 of them, since every time Test() returns,
>> LTW> the function carries on executing. If you only want one 'j'
>> LTW> printed then put a return statement after the call to Test():
>> 
>> LTW> function Test()
>> LTW> {
>> LTW> static $count = 0;
>> 
>> LTW> $count++;
>> LTW> echo $count;
>> LTW> if ($count < 10) {
>> LTW> Test();
>> LTW> return;
>> LTW> }
>> LTW> echo "j";
>> LTW> }
>> LTW> Test();
>> 
>> 
>> LTW> Cheers!
>> 
>> LTW> Torben
>> 
>> 
>> LTW> -- 
>> LTW>  Torben Wilson <[EMAIL PROTECTED]>
>> LTW>  http://www.thebuttlesschaps.com
>> LTW>  http://www.hybrid17.com
>> LTW>  http://www.inflatableeye.com
>> LTW>  +1.604.709.0506
>> 
>> 
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php