tailieunhanh - PHP Developer's Dictionary- P13
PHP Developer's Dictionary- P13:PHP is an open source, server-side, HTML-embedded scripting language used to create dynamically generated Web pages. With an easy-to-use syntax and a large, extensible library of modules, PHP brings together the best of Perl, C++, and other languages. | PHP Developer s Dictionary city char 50 state char 2 zip char 10 phone char 25 fax char 25 email char 50 resume oid primary key cid This script creates a contacts table with the usual information and another item called resume that is of type oid. To enter data in this table including the resume field the insert query looks like this INSERT INTO contacts VALUES NEXTVAL c Test Name Test Address Test City TS 11111 me@ lo_import resumes This query takes a file named from the resumes directory and imports it into the database as a large object. Similarly a select query to pull the resume out of the database looks like this SELECT cid name address city state zip phone fax email lo_export resume resumes FROM contacts WHERE cid 101 This exports the resume from the database places it in the resumes directory and names the file . The following example illustrates how to use the PHP large object functionality to insert a large object into the database html head title Large Objects title head body Connect to the Postgres Database conn pg_Connect localhost 5432 test if conn echo An database connection error occurred. n exit Begin the Transaction result pg_exec conn begin if result echo An error occurred beginning the transaction. n exit Lock the table oid pg_locreate conn echo The Large Object is created with Object ID oid br handle pg_loopen conn oid w echo The Large Object is opened in Write mode with Handle handle br IT-SC book 60 PHP Developer s Dictionary pg_lowrite handle resumes pg_loclose handle pg_exec conn INSERT INTO contacts VALUES NEXTVAL c Test Name Test Address Test City TS 11111 me@ oid pg_exec conn commit pg_exec conn end Free the result pg_FreeResult result Close the connection pg_Close conn body html The output of this script should look something like this The Large Object is created with Object ID 24097 The Large Object is opened in Write mode
đang nạp các trang xem trước