[PHP] Re: Metabse and ODBC Blobs, was [Re: Store Image in Access Database]
Hello, Mike Baranski wrote: Sorry about the previous one, that was a mistake. I have the following code to insert a blob into an access OLE object field: I am not sure if using SQL is the appropriate way to update such object field. Anyway, to make this work, such object must be of ODBC type ODBC_LONGVARBINARY . Metabase can create tables with BLOB fields properly declared. You may want to try the driver test script to see what it does and how it shows in access. Look in lob_test.schema to see how you can define a schema with LOB fields so Metabase manager class can create one for your needs. if(($prepared_query=MetabasePrepareQuery($database,UPDATE incident_blob SET data_blob=?, description='new'))) { $binary_lob=array( Type=inputfile, Database=$database, Error=, FileName=test.php ); if(($success=MetabaseCreateLOB($binary_lob,$blob))) { MetabaseQuerySetBLOB($database,$prepared_query,1,$blob,data_blob); if(!MetabaseExecuteQuery($database,$prepared_query)) $error=MetabaseError($database); MetabaseDestroyLOB($blob); } else { $error=$binary_lob[Error]; echo Error 1 (CreateLOB): $error\n; } MetabaseFreePreparedQuery($database,$prepared_query); } else { $error=MetabaseError($database); echo Error 2 (Prepare): $error\n; } I can connect and query the database otherwise, and it works fine. The problem is with the Blobs, that update statement is not getting run. There's only 1 row in the table, but the description and ole object do not get updated. If I switch the driver to use mysql as opposed to odbc, it works fine on an identical table (on linux, not windows). Any ideas? Did you verify that MetabaseExecuteQuery call above succeeds? If it does not succeed, what is the error message that is returned? Regards, Manuel Lemos Mike B. On Wednesday 26 December 2001 02:49 pm, Manuel Lemos wrote: Hello, Mike Baranski wrote: Hi, I'm trying to store a binary file in an access database, I'm using an ole type, and I think that it's getting inserted OK. My problem is that I don't know how to pull it out... How do you select the stuff that's in an ole object out of the database and display it, a jpg, for example. I can't even get the raw data. I've tried converting it to base 16 and inserting it, but I still can't pull it out. I know how to do this in mysql, so posting that won't help. I need to know how to do this with access. If you are using ODBC, you may want to try Metabase because it supports BLOB fields with any ODBC driver. Metabase is Open Source and is freely available here. http://phpclasses.UpperDesign.com/browse.html/package/20 Regards, Manuel Lemos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Metabse and ODBC Blobs, was [Re: Store Image in Access Database]
Hello, Mike Baranski wrote: Sorry about the previous one, that was a mistake. I have the following code to insert a blob into an access OLE object field: I am not sure if using SQL is the appropriate way to update such object field. Anyway, to make this work, such object must be of ODBC type ODBC_LONGVARBINARY . Metabase can create tables with BLOB fields properly declared. You may want to try the driver test script to see what it does and how it shows in access. Look in lob_test.schema to see how you can define a schema with LOB fields so Metabase manager class can create one for your needs. if(($prepared_query=MetabasePrepareQuery($database,UPDATE incident_blob SET data_blob=?, description='new'))) { $binary_lob=array( Type=inputfile, Database=$database, Error=, FileName=test.php ); if(($success=MetabaseCreateLOB($binary_lob,$blob))) { MetabaseQuerySetBLOB($database,$prepared_query,1,$blob,data_blob); if(!MetabaseExecuteQuery($database,$prepared_query)) $error=MetabaseError($database); MetabaseDestroyLOB($blob); } else { $error=$binary_lob[Error]; echo Error 1 (CreateLOB): $error\n; } MetabaseFreePreparedQuery($database,$prepared_query); } else { $error=MetabaseError($database); echo Error 2 (Prepare): $error\n; } I can connect and query the database otherwise, and it works fine. The problem is with the Blobs, that update statement is not getting run. There's only 1 row in the table, but the description and ole object do not get updated. If I switch the driver to use mysql as opposed to odbc, it works fine on an identical table (on linux, not windows). Any ideas? Did you verify that MetabaseExecuteQuery call above succeeds? If it does not succeed, what is the error message that is returned? Regards, Manuel Lemos Mike B. On Wednesday 26 December 2001 02:49 pm, Manuel Lemos wrote: Hello, Mike Baranski wrote: Hi, I'm trying to store a binary file in an access database, I'm using an ole type, and I think that it's getting inserted OK. My problem is that I don't know how to pull it out... How do you select the stuff that's in an ole object out of the database and display it, a jpg, for example. I can't even get the raw data. I've tried converting it to base 16 and inserting it, but I still can't pull it out. I know how to do this in mysql, so posting that won't help. I need to know how to do this with access. If you are using ODBC, you may want to try Metabase because it supports BLOB fields with any ODBC driver. Metabase is Open Source and is freely available here. http://phpclasses.UpperDesign.com/browse.html/package/20 Regards, Manuel Lemos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: Metabse and ODBC Blobs, was [Re: Store Image in Access Database]
OK, first, that's right out of the metabase manual, with names changed to protect the innocent. Second, the example won't work, it gives syntax errors with the MS driver on creating the test db and tables, but I fixed the DB part, but the tables still won't create themselves, it still gives errors. I've hacked it up a little bit, but it doesen't look like the test stuff will work for access. Has anyone successfully done this, and how? I cannot believe that I'm the only person who's ever stored binary data in Access, regardless of how bad of an idea it is... Hello, Mike Baranski wrote: Sorry about the previous one, that was a mistake. I have the following code to insert a blob into an access OLE object field: I am not sure if using SQL is the appropriate way to update such object field. Anyway, to make this work, such object must be of ODBC type ODBC_LONGVARBINARY . Metabase can create tables with BLOB fields properly declared. You may want to try the driver test script to see what it does and how it shows in access. Look in lob_test.schema to see how you can define a schema with LOB fields so Metabase manager class can create one for your needs. if(($prepared_query=MetabasePrepareQuery($database,UPDATE incident_blob SET data_blob=?, description='new'))) { $binary_lob=array( Type=inputfile, Database=$database, Error=, FileName=test.php ); if(($success=MetabaseCreateLOB($binary_lob,$blob))) { MetabaseQuerySetBLOB($database,$prepared_query,1,$blob,data_blob); if(!MetabaseExecuteQuery($database,$prepared_query)) $error=MetabaseError($database); MetabaseDestroyLOB($blob); } else { $error=$binary_lob[Error]; echo Error 1 (CreateLOB): $error\n; } MetabaseFreePreparedQuery($database,$prepared_query); } else { $error=MetabaseError($database); echo Error 2 (Prepare): $error\n; } I can connect and query the database otherwise, and it works fine. The problem is with the Blobs, that update statement is not getting run. There's only 1 row in the table, but the description and ole object do not get updated. If I switch the driver to use mysql as opposed to odbc, it works fine on an identical table (on linux, not windows). Any ideas? Did you verify that MetabaseExecuteQuery call above succeeds? If it does not succeed, what is the error message that is returned? Regards, Manuel Lemos Mike B. On Wednesday 26 December 2001 02:49 pm, Manuel Lemos wrote: Hello, Mike Baranski wrote: Hi, I'm trying to store a binary file in an access database, I'm using an ole type, and I think that it's getting inserted OK. My problem is that I don't know how to pull it out... How do you select the stuff that's in an ole object out of the database and display it, a jpg, for example. I can't even get the raw data. I've tried converting it to base 16 and inserting it, but I still can't pull it out. I know how to do this in mysql, so posting that won't help. I need to know how to do this with access. If you are using ODBC, you may want to try Metabase because it supports BLOB fields with any ODBC driver. Metabase is Open Source and is freely available here. http://phpclasses.UpperDesign.com/browse.html/package/20 Regards, Manuel Lemos -- * * Mike Baranski * * Security Managment Consulting * * 919-788-9200 Phone* * 919-510-0037 Fax * * [EMAIL PROTECTED] * * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: Metabse and ODBC Blobs, was [Re: Store Image in Access Database]
Hello, Mike Baranski wrote: OK, first, that's right out of the metabase manual, with names changed to protect the innocent. Second, the example won't work, it gives syntax errors with the MS driver on creating the test db and tables, but I fixed the DB part, but the tables still won't create themselves, it still gives errors. I suppose that is because Access SQL engine does not support standard SQL clauses like specifying default values for table fields. That is a known limitation of Access that Metabase supports by setting the database setup option UseDefaultValues to 0 . I've hacked it up a little bit, but it doesen't look like the test stuff will work for access. Has anyone successfully done this, and how? I cannot believe that I'm the only person who's ever stored binary data in Access, regardless of how bad of an idea it is... If you set UseDefaultValues option to 0 as mentioned above it will work fine. Usually I run the conformance tests for all types of supported databases before each Metabase release to make sure that nothing is broken. In fact, I use Access .mdb databases to test Metabase ODBC driver. I can assure you that LOBs work fine with Access using Metabase. Just mail me back if you still have difficulties. Regards, Manuel Lemos Hello, Mike Baranski wrote: Sorry about the previous one, that was a mistake. I have the following code to insert a blob into an access OLE object field: I am not sure if using SQL is the appropriate way to update such object field. Anyway, to make this work, such object must be of ODBC type ODBC_LONGVARBINARY . Metabase can create tables with BLOB fields properly declared. You may want to try the driver test script to see what it does and how it shows in access. Look in lob_test.schema to see how you can define a schema with LOB fields so Metabase manager class can create one for your needs. if(($prepared_query=MetabasePrepareQuery($database,UPDATE incident_blob SET data_blob=?, description='new'))) { $binary_lob=array( Type=inputfile, Database=$database, Error=, FileName=test.php ); if(($success=MetabaseCreateLOB($binary_lob,$blob))) { MetabaseQuerySetBLOB($database,$prepared_query,1,$blob,data_blob); if(!MetabaseExecuteQuery($database,$prepared_query)) $error=MetabaseError($database); MetabaseDestroyLOB($blob); } else { $error=$binary_lob[Error]; echo Error 1 (CreateLOB): $error\n; } MetabaseFreePreparedQuery($database,$prepared_query); } else { $error=MetabaseError($database); echo Error 2 (Prepare): $error\n; } I can connect and query the database otherwise, and it works fine. The problem is with the Blobs, that update statement is not getting run. There's only 1 row in the table, but the description and ole object do not get updated. If I switch the driver to use mysql as opposed to odbc, it works fine on an identical table (on linux, not windows). Any ideas? Did you verify that MetabaseExecuteQuery call above succeeds? If it does not succeed, what is the error message that is returned? Regards, Manuel Lemos Mike B. On Wednesday 26 December 2001 02:49 pm, Manuel Lemos wrote: Hello, Mike Baranski wrote: Hi, I'm trying to store a binary file in an access database, I'm using an ole type, and I think that it's getting inserted OK. My problem is that I don't know how to pull it out... How do you select the stuff that's in an ole object out of the database and display it, a jpg, for example. I can't even get the raw data. I've tried converting it to base 16 and inserting it, but I still can't pull it out. I know how to do this in mysql, so posting that won't help. I need to know how to do this with access. If you are using ODBC, you may want to try Metabase because it supports BLOB fields with any ODBC driver. Metabase is Open Source and is freely available here. http://phpclasses.UpperDesign.com/browse.html/package/20 Regards, Manuel Lemos -- * * Mike Baranski * * Security Managment Consulting * * 919-788-9200 Phone* * 919-510-0037 Fax * * [EMAIL PROTECTED] * * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]