一次编写,随处运行
ciative array. The value for the Type key may be one of the following: data, inputfile or outputfile. The first two are used when you want to write a LOB into the database. If you have the LOB stored in a variable you should use data while inputfile should be used to read the LOB directly from a file. Finally, outputfile should be used when you want to retrieve a LOB from the database. Depending on if you are using data or inputfile you need to specify a value for the Filename key or the Data key as seen in the above example. Now, we will store the above LOB''s in the database. 如你能看到的,MDB::createLob() 被传递一个关系数组。Type 键的值可能是以下中的一个:data, inputfile 或者 outputfile。前两个用于你想要把 LOB 写入数据库的时候。如果你有一个储存在变量中的 LOB,你应当在 需要使用 inputfile 时从文件直接读取 LOB。最后,outpufile 应当在你想要从数据库中读取 LOB 时使用。取决于你是否使用数据或者 inputfile 你需要给 Filename 键或者 Data 键指定一个值,像上面的例子那样。现在,我们将把前面的 LOB 储存到数据库中去。 $p_query = $mdb->prepareQuery(''INSERT INTO files (id, b_data, c_data) VALUES (1, ?, ?)''); $mdb->setParamBlob($p_query, 1 , $blob, ''b_data''); $result = $mdb->executeQuery($p_query); In order to fetch the above file from the database we will need to first select the data from the database and create a LOB object using MDB::createLob(). This time we will set `Type'' to `outputfile''. $mdb->query(''SELECT b_data FROM files WHERE id = 1''); $binary_lob = array( Now we can read the LOB from the result set using MDB::readLob(). Passing a length of 0 to MDB::readLob() means that the entire LOB is read and stored in the file we specified above. Once we are done we can free the resources. Alternatively, you can set any length larger than zero and read the LOB using a while loop checking MDB::endofLob(). $mdb->readLob($blob, $data, 0); It is important to note that you may not mix this method of fetching with the bulk fetching methods like MDB::fetchAll() as this will cause problems in most PHP database extensions. At some point MDB may be able to retrieve LOB''s using the bulk fetching methods. As we have seen in this section MDB features its ow |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |