Re: [PHP-DB] Transaction over persistent connection problem

2005-04-27 Thread Manuel Lemos
Hello,
on 04/27/2005 08:13 PM Jochem Maas said the following:
Ok. So the idea of splitting one transaction into two steps of a 
script is
wrong?

Yes, it is not possible to achive that. What happens is that first 
access to script is handled by one Web server process or thread and 
you cannot assure that the second access will be handled by the same 
Web process or server to finish the same transaction that was started.
some thoughts:
if he ran the the page/script on a seperate webserver (configured to
run one process), especially for this one task - to which only one
person [c|w]ould connect - then it would be technically doable no?
It would be the same problem because the other separate Web server 
script would start the transaction and then it would end.

The problem is not running many processes per script but rather that PHP 
scripts exit after they serve their response.

Furthermore, if the main Web server could run many scripts in parallel 
that would ask the separate server to start a transaction. Even if it 
was feasable to end the transaction in a second request, how would the 
separate know which transaction was started by which client?

The problem all boils down to the fact that HTTP is stateless.
Even if starting and ending transactions on different request was 
feasible, transactions should be managed by a different type of server, 
not really by common HTTP servers.


Furthermore, you should never leave a transaction open that you cannot 
guarantee that it will finished in a very short notice, otherwise it may 
say database server is in the US, and connecting server (that makes use 
of transactions)
is in Europe... how are you going to guarantee that the connecting 
server will never
suffer network or power loss midway thru a transaction? (I'd put money 
on the
fact that the same thing has crossed the minds of more than one database 
engine
developer.)
Disconnected or timed-out transactions should be aborted and implicit 
rollback happens. However that happens in an abnormal situations. 
Timeout and rollback only happens to assure that there are no 
outstanding transactions living for more than a short period (were 
talking about seconds here).

If you need to start a more complex operation that needs to wait for 
user response during an unknown period, you need to use other kind of 
non-blocking locking methods.


block the access to the whole database forever.
thats a broad statement. a transaction doesn't have to block access per 
definition,
It must be atomic, therefore no more than once concurrent access can 
change the same data.


and its not unfeasable to suggest that some database engines may account 
for the
possibility for 'hung' transaction in some kind of garbage collection 
routine...?
It is not really a garbage collection but rather aborting transactions 
(rollback) after a timeout or disconnection.

--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Transaction over persistent connection problem

2005-04-27 Thread Jochem Maas
Manuel Lemos wrote:
Hello,
on 04/27/2005 11:49 AM Oskar said the following:
Ok. So the idea of splitting one transaction into two steps of a 
script is
wrong?

Yes, it is not possible to achive that. What happens is that first 
access to script is handled by one Web server process or thread and you 
cannot assure that the second access will be handled by the same Web 
process or server to finish the same transaction that was started.
some thoughts:
if he ran the the page/script on a seperate webserver (configured to
run one process), especially for this one task - to which only one
person [c|w]ould connect - then it would be technically doable no?
Furthermore, you should never leave a transaction open that you cannot 
guarantee that it will finished in a very short notice, otherwise it may 
say database server is in the US, and connecting server (that makes use of 
transactions)
is in Europe... how are you going to guarantee that the connecting server will 
never
suffer network or power loss midway thru a transaction? (I'd put money on the
fact that the same thing has crossed the minds of more than one database engine
developer.)
block the access to the whole database forever.
thats a broad statement. a transaction doesn't have to block access per 
definition,
and its not unfeasable to suggest that some database engines may account for the
possibility for 'hung' transaction in some kind of garbage collection 
routine...?

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


RE: [PHP-DB] Transaction over persistent connection problem

2005-04-27 Thread Oskar

Thanks for your help, Manuel. Your advice saved me hours of searching the
web.

Regards, OKi98

> -Original Message-
> From: Manuel Lemos [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, April 27, 2005 7:20 PM
> To: php-db@lists.php.net
> Subject: Re: [PHP-DB] Transaction over persistent connection problem
>
>
> Yes, it is not possible to achive that. What happens is that first
> access to script is handled by one Web server process or thread and you
> cannot assure that the second access will be handled by the same Web
> process or server to finish the same transaction that was started.
>
> Furthermore, you should never leave a transaction open that you cannot
> guarantee that it will finished in a very short notice, otherwise it may
> block the access to the whole database forever.
>
>
> --
>
> Regards,
> Manuel Lemos
>
> PHP Classes - Free ready to use OOP components written in PHP
> http://www.phpclasses.org/
>
> PHP Reviews - Reviews of PHP books and other products
> http://www.phpclasses.org/reviews/
>
> Metastorage - Data object relational mapping layer generator
> http://www.meta-language.net/metastorage.html
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

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



Re: [PHP-DB] php4 can't find tnsnames.ora oracle9 but can connectif description

2005-04-27 Thread Christopher Jones
Without real information I can only wonder and guess.
Is TNS_ADMIN set to a directory or a file?  It should be a directory.
Try renaming sqlnet.ora temporarily or set the alias in tnsnames.ora
to something like "testdb.boo.com = (DESCRIPTION = ..."
Chris
neil smith wrote:
Hello chris,
I've modified the variables in the apache user environment (in my case 
root at the moment) but that didn't amke any difference to php not being 
able to find tnsnames.ora. So the work around I've used is to use 
ORACLE_SID="desciption(...etc. SID = )))"; ie the full description 
of the database alias within tnsnames.ora

However this is not good, so if you have any other idea please let me 
know. I'm flumuxed.

thanks,
neil
>From: Christopher Jones <[EMAIL PROTECTED]>
>To: neil smith <[EMAIL PROTECTED]>
>CC: php-db@lists.php.net, [EMAIL PROTECTED]
>Subject: Re: [PHP-DB] php4 can't find tnsnames.ora oracle9 but can 
connectif description hardcoded
>Date: Wed, 20 Apr 2005 09:25:12 +1000
>
>Make sure the environment variables are set in the shell that starts
>Apache.  See
>http://www.oracle.com/technology/tech/opensource/php/php_troubleshooting_faq.html#envvars 

>
>Try changing your OCILogon command to
>
>   $odbc = 
OCILogon("yourusername","yourpassword",$db);
>
>i.e. remove "/test" from the username parameter.
>
>Chris
>
>neil smith wrote:
>>Hello,
>>
>>I have test script that can connect to the oracle database. It
>>doesn't
>>require tnsnames.ora because I define the database alias in the
>>script
>>itself. It looks like this:
>>
>>
>>
>>echo 
"TWO_TASK=".getenv("TWO_TASK")."
"; >>echo "LD_LIBRARY_PATH=".getenv("LD_LIBRARY_PATH")."
"; >>echo "ORACLE_BASE=".getenv("ORACLE_BASE")."
"; >>echo "ORACLE_HOME=".getenv("ORACLE_HOME")."
"; >>echo "TNS_ADMIN=".getenv("TNS_ADMIN")."
"; >>echo "NLS_LANG=".getenv("NLS_LANG").".
"; >> >># this allows a successful connection >> >>$db = " (DESCRIPTION = >> (ADDRESS = (PROTOCOL = TCP) (HOST =testdb.boo.com)(PORT = 1521)) >> (CONNECT_DATA= (SID = testdb)) >> )"; >> >>// these don't work.. php can't seem to find tnsnames.ora >># $db = "testdb.boo.com"; >>//$db = "testdb.boo.com"; >># $db = "testdb"; >>//echo $testdb; >> >> >>$odbc = OCILogon("test/test","test",$db); >> >>if ($odbc == false){ >> $msg = OCIError($odbc)."
"; >>} else { >>echo "success!!!
"; >>} >> >> >> >>My problem is is that when I try to use the database alias in >>tnsnames.ora I >>get an ora-12154 error. I get this despite the facts that >>oracle_home, >>tns_admin and everything else is defined in the script and the >>tnsnames.ora >>contains exactly the same alias as I use in the hardcoded version >>(see the >>uncommented $db above). >>sqlnet.ora contains a value name_domain that apparently is appended >>to the >>alias in tnsnames.ora but accounting for this still doesn't let me >>connect >>to oracle . It's as if tnsnames.ora cannot be found. I've changed >>the >>permissions to 777 for the whole directory structure and I can >>successfully >>use tnsnames.ora with sqlplus or tnsping. >> >>Does anybody have any ideas what is going wrong? Is this a bug? >> >>thanks, >> >>neil >> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DB] Transaction over persistent connection problem

2005-04-27 Thread Manuel Lemos
Hello,
on 04/27/2005 11:49 AM Oskar said the following:
Ok. So the idea of splitting one transaction into two steps of a script is
wrong?
Yes, it is not possible to achive that. What happens is that first 
access to script is handled by one Web server process or thread and you 
cannot assure that the second access will be handled by the same Web 
process or server to finish the same transaction that was started.

Furthermore, you should never leave a transaction open that you cannot 
guarantee that it will finished in a very short notice, otherwise it may 
block the access to the whole database forever.

--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: FW: [PHP-DB] mime-type related to extension?. .

2005-04-27 Thread Matthew Weier O'Phinney
* Martin Norland <[EMAIL PROTECTED]>:
> meal list_php wrote:
> > Hi I sent this on 21st of april and got no answer...
> > there is no way to check the "real" mime type of a file?
> > even a file without extension?
> > thanks,
>
> You can call out to an external program called "file" (which is pretty 
> much guaranteed to be there, on a Linux system) which uses some magic to 
> determine the file type.  It should be able to tell you if the file is 
> jpeg regardless, without any messy work from you.  It will return a 
> string like so:
>   $ file false.doc
>   false.doc: JPEG image data, JFIF standard 1.02
> I'd run a few tests with some images from different sources, but it 
> should be returning a very standard string - "JPEG image data" should at 
> least be common.  IIRC Sony also has a 'motion jpeg' which might cause 
> you problems, depending on what you're doing - if you can get a hold of 
> one of those to test (if it's a concern) you might want to.

An additional tool that may be used when simply checking for image types
is to use getimagesize() -- though you should be using php >= 4.3.11 to
do this safely (see http://security.gentoo.org/glsa/glsa-200504-15.xml
for more information). One element returned by getimagesize() is the
image MIME type.

-- 
Matthew Weier O'Phinney   | WEBSITES:
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org

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



RE: [PHP-DB] Transaction over persistent connection problem

2005-04-27 Thread Oskar
Ok. So the idea of splitting one transaction into two steps of a script is
wrong?

I wanted to use it in a script that is importing big amount of datas (about
200k rows).

First step:
mysql_pconnect()
start transaction
insert rows and test errors
no errors => commit, mysql_close()
some errors => echo("Some errors occured. Do you want to keep 
non-error
entries in database? Yes/No");
Second step:
mysql_pconnect()
Yes => commit
No  => rollback
mysql_close()



> -Original Message-
> From: Manuel Lemos [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, April 27, 2005 4:21 PM
> To: php-db@lists.php.net
> Subject: Re: [PHP-DB] Transaction over persistent connection problem
>
>
> The solution of Metabase (portable database abstraction package) is to
> implicitly register a shutdown function that clean any pending
> transactions:
>
> http://www.phpclasses.org/metabase
>
>
> --
>
> Regards,
> Manuel Lemos
>
> PHP Classes - Free ready to use OOP components written in PHP
> http://www.phpclasses.org/
>
> PHP Reviews - Reviews of PHP books and other products
> http://www.phpclasses.org/reviews/
>
> Metastorage - Data object relational mapping layer generator
> http://www.meta-language.net/metastorage.html
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

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



Re: [PHP-DB] Transaction over persistent connection problem

2005-04-27 Thread Manuel Lemos
Hello,
on 04/27/2005 09:58 AM Oskar said the following:
You see - tables are locked and the only way to fix it is restarting MySQL.
Could you tell me what am I doing wrong, please?
I suspect that your scripts may be exiting once in a while with 
unfinished transactions due to bugs or errors that make it end 
prematurely. With persistent connections you need to rollback unfinished 
transations by the end of the script.

The solution of Metabase (portable database abstraction package) is to 
implicitly register a shutdown function that clean any pending transactions:

http://www.phpclasses.org/metabase
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Memory. .

2005-04-27 Thread Martin Norland
[FOTOList.com] Suporte wrote:
Hi,
When I get something from database, using this function: pg_query 
(postgresql) or mysql_query and after put this result in somes 
variables, Am I using double memory to same data or this new variable 
point to variable with db result?
The postgresql or mysql process is storing the resultset in memory, php 
is passed the address of the resultset.  When you actually pull the 
individual rows out of the resultset into PHP and assign them a 
variable, you are storing a second copy of that.  If you pull out all 
the rows and store them in an array in PHP, you then have two copies of 
your entire data.  If you need to pull your whole set of results out 
into an array, you can immediately use pg_free_result() or 
mysql_free_result() afterwards to free up the copy using memory in the 
database.

cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


[PHP-DB] Using Memory

2005-04-27 Thread [FOTOList.com] Suporte
Hi,
When I get something from database, using this function: pg_query 
(postgresql) or mysql_query and after put this result in somes 
variables, Am I using double memory to same data or this new variable 
point to variable with db result?

Gustavo Paixão
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Memory

2005-04-27 Thread [FOTOList.com] Suporte
Hi,
When I get something from database, using this function: pg_query 
(postgresql) or mysql_query and after put this result in somes 
variables, Am I using double memory to same data or this new variable 
point to variable with db result?

Gustavo Paixão
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: FW: [PHP-DB] mime-type related to extension?. .

2005-04-27 Thread Martin Norland
meal list_php wrote:
Hi I sent this on 21st of april and got no answer...
there is no way to check the "real" mime type of a file?
even a file without extension?
thanks,
You can call out to an external program called "file" (which is pretty 
much guaranteed to be there, on a Linux system) which uses some magic to 
determine the file type.  It should be able to tell you if the file is 
jpeg regardless, without any messy work from you.  It will return a 
string like so:
	$ file false.doc
	false.doc: JPEG image data, JFIF standard 1.02
I'd run a few tests with some images from different sources, but it 
should be returning a very standard string - "JPEG image data" should at 
least be common.  IIRC Sony also has a 'motion jpeg' which might cause 
you problems, depending on what you're doing - if you can get a hold of 
one of those to test (if it's a concern) you might want to.

cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


[PHP-DB] Transaction over persistent connection problem

2005-04-27 Thread Oskar
Hello,

I would like to create transaction that is commited/rolled back in the next
step of the script.

Example:



  Apply changes?
  
Yes
No
  





I don't know why but sometimes the script works sometimes not and then MySQL
processlist is:

TRANSACTIONS

Trx id counter 0 1647875
Purge done for trx's n:o < 0 1647364 undo n:o < 0 0
History list length 5
Total number of lock structs in row lock hash table 1
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0 0, not started, OS thread id 620
MySQL thread id 6, query id 23 localhost 127.0.0.1 root
SHOW INNODB STATUS
---TRANSACTION 0 1647874, not started, OS thread id 2852
MySQL thread id 5, query id 12 localhost 127.0.0.1 ODBC
---TRANSACTION 0 1647873, not started, OS thread id 1152
MySQL thread id 3, query id 8 localhost 127.0.0.1 ODBC
---TRANSACTION 0 1647872, ACTIVE 926 sec, OS thread id 440
2 lock struct(s), heap size 320, undo log entries 1
MySQL thread id 1, query id 3 localhost 127.0.0.1 ODBC

You see - tables are locked and the only way to fix it is restarting MySQL.

Could you tell me what am I doing wrong, please?

OKi98

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



Re: [PHP-DB] mime-type related to extension?

2005-04-27 Thread Mark Cain
The beginning of the jpeg file in hex looks like this:

FF D8 FF

perhaps you could test for that occurrence.  Be aware that the occurrence of
FF D8 FF must be in each jpg file -- it does not mean that the occurrence of
FF D8 FF is found only in a jpg file.

http://filext.com/detaillist.php?extdetail=JPG

you could also try http://www.jpeg.org/index.html


Mark Cain


- Original Message -
From: "mel list_php" <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, April 27, 2005 4:03 AM
Subject: FW: [PHP-DB] mime-type related to extension?


> Hi I sent this on 21st of april and got no answer...
> there is no way to check the "real" mime type of a file?
> even a file without extension?
> thanks,
> melanie
>
>
> >From: "mel list_php" <[EMAIL PROTECTED]>
> >To: php-db@lists.php.net
> >Subject: [PHP-DB] mime-type related to extension?
> >Date: Thu, 21 Apr 2005 13:45:45 +
> >
> >Hi guys!
> >
> >I have a basic form to upload files, my problem is about the mime type.
> >I use $type= $_FILES[$file_uploaded]['type']; to check the mime-type of
the
> >fila as I want to allow only .jpeg.
> >I have then a test like:
> >if  ($type=="image/pjpeg" || $type=="image/jpeg")
> >{
> >...
> >}
> >
> >Upload working fine if I send "red.jpg".
> >However if I rename the file in "red", php recognizes it as
> >application/octet-stream and not jpeg.
> >I'm working under linux and for me the extension is not required for a
> >file, I thought the mime-type was encoded in the file itself and was
> >independent of the extension.
> >Any clue on that?
> >Any other php function I should look at?
> >The cookbook and pear both use $_FILES[ ] ['type'] so I have no idea
here.
> >
> >Thanks,
> >Melanie
> >
> >_
> >It's fast, it's easy and it's free. Get MSN Messenger today!
> >http://www.msn.co.uk/messenger
> >
> >--
> >PHP Database Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> _
> Want to block unwanted pop-ups? Download the free MSN Toolbar now!
> http://toolbar.msn.co.uk/
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



FW: [PHP-DB] mime-type related to extension?

2005-04-27 Thread mel list_php
Hi I sent this on 21st of april and got no answer...
there is no way to check the "real" mime type of a file?
even a file without extension?
thanks,
melanie

From: "mel list_php" <[EMAIL PROTECTED]>
To: php-db@lists.php.net
Subject: [PHP-DB] mime-type related to extension?
Date: Thu, 21 Apr 2005 13:45:45 +
Hi guys!
I have a basic form to upload files, my problem is about the mime type.
I use $type= $_FILES[$file_uploaded]['type']; to check the mime-type of the 
fila as I want to allow only .jpeg.
I have then a test like:
if  ($type=="image/pjpeg" || $type=="image/jpeg")
{
...
}

Upload working fine if I send "red.jpg".
However if I rename the file in "red", php recognizes it as 
application/octet-stream and not jpeg.
I'm working under linux and for me the extension is not required for a 
file, I thought the mime-type was encoded in the file itself and was 
independent of the extension.
Any clue on that?
Any other php function I should look at?
The cookbook and pear both use $_FILES[ ] ['type'] so I have no idea here.

Thanks,
Melanie
_
It's fast, it's easy and it's free. Get MSN Messenger today! 
http://www.msn.co.uk/messenger

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
_
Want to block unwanted pop-ups? Download the free MSN Toolbar now!  
http://toolbar.msn.co.uk/

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