insert and retrieve PDF Mysql

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Juanchopapacho
Posts: 2
Joined: Sat Sep 05, 2015 4:08 am

insert and retrieve PDF Mysql

Post by Juanchopapacho » Sat Sep 05, 2015 4:21 am

Hello Community!

I'm doing a system where a PDF ... That PDF is recovered in LiveCode through an image and generates RevBrowser ... Everything that makes as follows:

on card:

Code: Select all

global myBrowser2

        on browserOpen2
                if myBrowser2 is empty then
                     put revBrowserOpenCef(the windowid of this stack,"") into myBrowser2
                end if
                revBrowserSet myBrowser2, "showborder","true"
                revBrowserSet myBrowser2, "visible","true"
                revBrowserSet myBrowser2, "rect",rect of image "bwin2"
        end browserOpen2

        on browserClose2
                revBrowserClose myBrowser2
                put empty into myBrowser2
        end browserClose2
on Button:

Code: Select all

global tFile
global myBrowser2

on mouseUp
     GLOBAL theResult,thepDF
     browserOpen2
     PrintCards2
     answer thePDF
      revBrowserSet myBrowser2, "url", thepDF
   revBrowserSet myBrowser2, "rect", "0,0,800,800"
end mouseUp
That what is done is to show the newly created PDF in a picture called "bwin2" through a browser ...

What I want to do now, it is to insert the PDF shown in a database and be able to recover.

I read about the BLOB, but really do not know how to be inserted by a PDF file from LiveCode.

Best regards! = D

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: insert and retrieve PDF Mysql

Post by MaxV » Thu Sep 10, 2015 3:23 pm

The SQLStatement may contain one or more placeholders, which are sequential numbers prepended by a colon. The revExecuteSQL command substitutes the corresponding item in the variablesList for each of these placeholders. For example, if you have two variables called "valueX" and "valueY", you can use a SQLStatement that includes placeholders as follows:

Code: Select all

revExecuteSQL myID, "insert into mytable values(:1,:2)", "valueX","valueY"
when using binaries, you have to insert the *b prefix in variable name; so if you variable containing a binary is "valueX", the correct code is:

Code: Select all

revExecuteSQL myID, "insert into mytable values(:1)", "*bvalueX"
Since the revExecuteSQL command strips the binary marker "*b" and passes it to the database as binary data, rather than text data.

Example with UPDATE:

Code: Select all

 put "UPDATE flags SET  logo=:1  WHERE ID="& tID &" ;" into tSQL 
 revExecuteSQL connID,tSQL,"*blogo"  # because "logo" variable contains an image
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply