Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

author
message
[Level:2]andrevanzuydam

Post subject: BLOBS / CLOBS & PHP Request NEW Function

registered: 04/25/2012

IP: *.215.158.63

views: 8

My main headache is that I don't want to write an SQL statement each time I need to access blob data, I want to just go with the information provided in the column data.  Now this is not a problem in "static" systems but I need to dynamically extract that information.

A function to return the data of a BLOB or CLOB would be appreciated if possible:

//$fieldvalue = 'file:/opt/CUBRID/databases/FILEOMINT/lob/ces_058/tbltest.00001335346225392229_6061';

$blobcontents = cubrid_get_lob_content ($resource, $fieldvalue);

I know the file path could easily be ripped from the column data and one could use file_get_contents but there are permission implications

Looking forward to some comments, or other ways to deal with the above situation.

Quote
[Level:8]CUBRID

# Post subject:Re: BLOBS / CLOBS & PHP Request NEW Function

profile

registered: 03/29/2010

IP: *.91.139.84

Hello Andre,

Have you tried cubrid_lob_get() function? Also take a look at Working with CUBRID BLOB/CLOB Data Types.

Quote
[Level:2]andrevanzuydam

# Post subject:Re: BLOBS / CLOBS & PHP Request NEW Function

profile

registered: 04/25/2012

IP: *.215.158.63

I am using cubrid_lob_get and I have my solution working, I could use internal SQL functions like clob_to_char in the SQL but I do not always want to pull binary data in my record set.  Also if there was a way to pass the lob into a variable instead of outputting to browser would also be good.  If necessary I can explain why there is a need for me to have this.

Quote
[Level:8]CUBRID

# Post subject:Re: BLOBS / CLOBS & PHP Request NEW Function

profile

registered: 03/29/2010

IP: *.91.139.84

Yes, would you please explain why do you need to store a LOB data into a variable? You should be careful with this as you may end up with "no enough memory" issues since you won't exactly know what the actual size of the LOB data is, which may be, in fact, larger that the memory_limit of your PHP environment.

Quote
[Level:8]CUBRID

# Post subject:Re: BLOBS / CLOBS & PHP Request NEW Function

profile

registered: 03/29/2010

IP: *.91.139.84

The reason why we do not recommend to mess with the files directly is that if a user has a permission, he may accidentally or intentionally delete the file while DB still references it in the table column. This creates inconsistency in your data, which is not good.

What I don't understand is that you say "I do not always want to pull binary data in my record set", then you say "I want to display the information on the screen for output." So do you want to display CLOB or you do not want to display? I cannot understand why you are making this so complicated.

If your user selects the columns manually by clicking on them, once he clicks your main action button, what you could do is retrieve the schema of these two tables by table name. Then from obtained schema determine which column has a BLOB/CLOB data type. For each LOB column, use CLOB_TO_CHAR() and you will get the data directly in your result set. If you do not want to have this LOB data in your result set, call cubrid_log_get() for these LOB columns. Even if they return resource identifiers, the CUBRID driver is developed in a way to make this process as efficient as possible. So, you do not worry about this.

And I don't encourage you to give permission to your file system to your Web server. As I said, some other process may take that advantage and mess up with your LOB files.

Quote
[Level:2]andrevanzuydam

# Post subject:Re: BLOBS / CLOBS & PHP Request NEW Function

profile

registered: 04/25/2012

IP: *.215.158.63

I have no problem with CLOB_TO_CHAR method, I then have to determine the table name from the SQL and get the information.  It is a long process to a very simple solution below :

I would be satisfied if I did not have to pass an SQL statement to cubrid_lob_get to retrieve the data, why can I not pass the field value that was returned in the result set as a reference to the BLOB ? This would immediately negate all the problems mentioned above.  I would also be quite happy to live with no direct feed to a variable in PHP.

Thanks for your input, if you feel my request is not valid / feasible for implementation then we leave it as it is, I do have a workable solution, although perhaps not in the way I felt could  have been.

Quote
[Level:2]andrevanzuydam

# Post subject:Re: BLOBS / CLOBS & PHP Request NEW Function

profile

registered: 04/25/2012

IP: *.215.158.63

Wonderful, I am happy if I can get both issues handled, it will help me a lot.

Quote
[Level:8]CUBRID

# Post subject:Re: BLOBS / CLOBS & PHP Request NEW Function

profile

registered: 03/29/2010

IP: *.91.139.84

Created a feature request which reflects your second question. Also updated your first feature request.

Quote




You are either using a very old browser or a browser that is not supported.
In order to browse cubrid.org you need to have one of the following browsers:



Internet Explorer: Mozilla Firefox: Google Chrome: