Re: [PHP-DB] Writing to files (db related) ish

2002-09-26 Thread Miguel Carvalho

Hi,

> Hi All
>
> I know how to open, read & write to files using Php.
>
> But how can you write some content to a particular place in a file, Not
> the start or end but say the middle some where.
>
> Example:
>
> Basic html file
>
> 
> 
> 
> 
> 
>
> Write my stuff here!!!
>
> 
> 
>
> This eventually will relate to a db so I hope its not completely of
> topic.
>

  It doesn't seam to be database related...
  But any way

  Two solutions:
  1st solution( recommended ):
- read the entire file into a string( fread, )
- do a string relacement, ie: replace the string "" with
the  string "what you want".  2st solution:
- use fseek function to place the file "pointer" where you want
- write the string to the file


Miguel



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




Re: [PHP-DB] Oracle connection problem after call to unserialize()

2002-09-24 Thread Miguel Carvalho

> I made a class called OracleCon that is used to connect to an Oracle
> server and provide some certain queries to the database
> When i create an object of that class and serialize it to add it to a
> cookie, if i echo the $object->connection attribute i get a "Resource
> id #2"
>
> When after redirection due to succefull login, i need to use this
> object to run the queries i get an error like this:
>
> Warning: ociparse(): supplied argument is not a valid OCI8-Connection
> resource in c:\program files\apache
> group\apache\htdocs\php\OracleCon.inc on line 66
>

You cant't serialize a object that uses as a member a "resource"( let's
say an handler ).When PHP end the script, it will close all handler's used( database
connecitons, files, etc ).
You have to store the login information in a session var or in the database.

> If i echo the $object->connection attribute again i get a "0" If i
> echo the other attributes, they have the same values as they were set
> before serialization of the object

Handler's are not serializable var's.

Miguel





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




[PHP-DB] External file integryti check

2002-09-03 Thread Miguel Carvalho

Hi, id'like to know the opinion about to ensure external file integrity.

Scenario: A web application that uses binary files( images, PDF's ).
On the database ( postgresql 7.2.2 ) i store the filename of the files.

The files ( images only ) are taken from an internal machine when needed(
via ftp ) or automatically at idle periods.If the image comes throuth ftp( requested 
by a user ),
 the image is downloaded to a temporary directory, a record is inserted
 into the database and the file get's moved to the final directory if it
 passed some tests.If no image is requested by a user, a script will download( rcp ) 
at night
the files and then put those in the final directory.When a user request's a PDF, i 
create the PDF in realtime, using info.
stored in the DB plus the image( store on filesystem ).
My concern here is the folowing:
  let's imagine that an image file is overwriten with a new image( by
  mistake ). This is possible because users use some kind of ID to name
  the file. If this appens, the info stored in DB is out of sync in
  relation to the file stored in filesystem.
  To correct this issues i have three possibilities:

1 - Store the PDF's in the filesystem, and store the file date, time
andCRC32 of the entire file in the database. This solution has a
consequence... i will need lots of space in the server( each file is
aprox. 2MB ).  At night a script will validate the sync between the info 
stored in
  DB and the info on filesystem.
2 - Create the PDF when requested. When the PDF generated for the
first time, i will store: image creation date, time, crc32 and some
more dates, times and CRC32's of other information into the DB.  At night a 
script will validate the sync between the info stored in
  DB and the info on filesystem.
3 - Run a script that is change file permissions( file is created with
user owner of webserver) for those new records inserted to root.  A script 
will be run, because i cant change ownership of a file on
  the fly with PHP( PHP security ).
Those are my solution's, if any one has any comments or suggestion's
please  share it with us.Thank's
Miguel Carvalho



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




Re: [PHP-DB] PHP amd MYSQL

2002-06-05 Thread Miguel Carvalho

Hi,

> I am setting up a web page system which involves html pages, php pages
> and mysqldatabase.
>
> I have a number of questions and do not know where to find answers.
>
> If  I display the rows from a database table in a php generated html
> table is it possible to mark a row so that it can be deleted or
> modified by calling another php page?

I dont know if mysql supports select for update, but the locking will not
work. The reasons are:
   As soon the PHP page ends, PHP will realease all non persistent
   database connections.You can work around this, using a persistent connection( this 
type of
connection doesnt close even after the php script ends ), but this kind of
connection can bring you troubles. You will get troubles if you run insert
or update commands, because all script instances will share the same
database connection. If for some reason, a script( or the db server )
locks the table for some reason, all scripts that use the persistent connection
  will wait for the unlock of the table.Worse, if you rollback a transaction, every 
transactions that use the
persistent connection will be roolbacked.

Is there any reason to lock the rows?

>If so is this documented
> anywhere?

>
> Is there any good source of information on setting up 'forms'to work
> like Oracle forms where database records can be inserted, updated or
> deleted?

I dont know. Sorry.

Regards
Miguel



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




Re: [PHP-DB] PHP and OCI NLS behaviour

2002-04-18 Thread Miguel Carvalho

> The speed decrease is dependant on your setup. How fast your machines
> are and how good your network is. I ran a few quick tests on our
> servers and there seemed to be little effect on performance. The loss
> of
> performance was unmeasurable.
>

I see that it's a minor issue.


> I'm not sure on the character set setting. You can see your current NLS
> settings for your session, instance and database by querying
> NLS_SESSION_PARAMETERS, NLS_INSTANCE_PARAMETERS and
> NLS_DATABASE_PARAMETERS. Maybe that well help you.

I have done a select from those table/view...and all are as i need.

A have tried changing the session parameters with alter session, but the
result is the same.

Isn't this an issue related to OCI8 or PHP.
As i said at some days ago, this only appens on my Linux( suse 7.x) machine
that is using PHP. On the windows machines, all is fine.

Does any can send me an exemple of the definition of NLS_LANG environment
variable?


Thank's for the repply

Regards
Miguel Carvalho



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




Re: [PHP-DB] PHP and OCI NLS behaviour

2002-04-17 Thread Miguel Carvalho

>
> Or if that is not available for you to edit you could always try just
> executing a statement to alter the session once a database connection
> is established. This method is a little slower.

How slower? Very very slower? Can you give me an aproximation in seconds?

>As you will have to
> execute the alter session statements every time you make the
> connection.

Ok.

>
> The SQL is something like:
> alter session set NLS_LANGUAGE = 'AMERICAN' NLS_TERRITORY = 'AMERICA'

Can i specify the characterset on the alter session?
Sorry for the question...but the Oracle docs that i have read, just say
what is the sintaxe.

Regards
Miguel Carvalho



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




[PHP-DB] PHP and OCI NLS behaviour

2002-04-16 Thread Miguel Carvalho

Hi,

First of all i have searched for this trouble on the news(
groups.google.com); on Oracle docson  phpbuilder site; in php general, php
db mailing list's .

The problem:

Background info:
PHP version: 4.1.2
OS: Linux Suse 7
OCI version: 8
Database version: 7.x
Database OS: HP/UX


I need to do a select for a field that is varchar2.
The field contains strings that have some char's like ( á in html á,
ã in html ã).

The problem is that instead of these nice char's a get a ?.

This seams to me a PHP/OCI probleam, because if a use SQL Plus 8 ( on a
Windows machine )or other cliente, i get every thing ok.

What a have tried til now:

Changing the NLS_LANG env var( with PutEnv in Apache )...no luck.

The result for: select * from NLS_SESSION_PARAMETRS is the same on the
Windows client and on PHP( i thought that OCI layer was using some defaults
of it's own ).

The database was created with the right NLS_PARAMETER's ( if it were not, i
couldnt get these char's in SQLPLUS ).

One more thingi very new to Oraclebut i have worked with other DBMS
like MSSQL Server, MySQL, Postgres.

Does any one has seen this before?
Is this a known probleam?
Does any one have any tip to solve this probleam?

Thank's
Miguel Carvalho



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