コード例 #1
0
ファイル: Sql.php プロジェクト: raz0rsdge/horde
 /**
  * Read file data from the SQL VFS backend.
  *
  * @param string $table    The VFS table name.
  * @param string $field    TODO
  * @param array $criteria  TODO
  *
  * @return mixed  TODO
  * @throws Horde_Vfs_Exception
  */
 protected function _readBlob($table, $field, $criteria)
 {
     if (!count($criteria)) {
         throw new Horde_Vfs_Exception('You must specify the fetch criteria');
     }
     $where = '';
     foreach ($criteria as $key => $value) {
         if (!empty($where)) {
             $where .= ' AND ';
         }
         $where .= $key . ' = ' . $this->_db->quote($value);
     }
     $sql = sprintf('SELECT %s FROM %s WHERE %s', $field, $table, $where);
     try {
         $result = $this->_db->selectValue($sql);
         $columns = $this->_db->columns($table);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Vfs_Exception($e);
     }
     if ($result === false) {
         throw new Horde_Vfs_Exception('Unable to load SQL data.');
     }
     return $columns[$field]->binaryToString($result);
 }