Created
February 17, 2015 03:58
-
-
Save rowland/d59ee296f8be4b581fed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
function blob_extract($blob_id) { | |
if (!$blob_id) | |
return ""; | |
list ($length,$numseg,$maxseg,$stream,$isnull) = ibase_blob_info($blob_id); | |
$handle = ibase_blob_open($blob_id); | |
$x = "dummy"; | |
$data = ""; | |
while($x != "") { | |
$x = ibase_blob_get($handle,1024); | |
$data .= $x; | |
} | |
ibase_blob_close($handle); | |
return $data; | |
} | |
define('MAX_SEGMENT_SIZE',65535); | |
function blob_create($data) { | |
if(strlen($data) == 0) | |
return false; | |
$handle = ibase_blob_create(); | |
$len = strlen($data); | |
for ($pos = 0; $pos < $len; $pos += MAX_SEGMENT_SIZE) { | |
$buflen = ($pos + MAX_SEGMENT_SIZE > $len) ? ($len - $pos) : MAX_SEGMENT_SIZE; | |
$buf = substr($data,$pos,$buflen); | |
ibase_blob_add($handle,$buf); | |
} | |
return ibase_blob_close($handle); | |
} | |
function ibase_fetch_array($cursor) { | |
if ($obj = @ibase_fetch_object($cursor)) { | |
$result = (array)$obj; | |
} else { | |
$result = $obj; | |
} | |
return $result; | |
} | |
function ibase_fetch_array2($cursor) { | |
if ($obj = @ibase_fetch_object($cursor,IBASE_TEXT)) { | |
$result = (array)$obj; | |
} else { | |
$result = $obj; | |
} | |
return $result; | |
} | |
function ibase_fetch_all($cursor) { | |
$result = array(); | |
while ($row = ibase_fetch_array($cursor)) { | |
array_push($result,$row); | |
} | |
return $result; | |
} | |
function ibase_field_names($cursor) { | |
$result = array(); | |
$num_fields = ibase_num_fields($cursor); | |
for ($i = 0; $i < $num_fields; $i++) { | |
$field_info = ibase_field_info($cursor,$i); | |
$result[] = $field_info['name']; | |
} | |
return $result; | |
} | |
function ibase_connect_alias($alias) { | |
return ibase_connect( | |
$alias['database'], | |
$alias['username'], | |
$alias['password'], | |
$alias['charset'], | |
$alias['buffers'], | |
$alias['dialect'], | |
$alias['role']); | |
} | |
function ibase_pconnect_alias($alias) { | |
return ibase_pconnect( | |
$alias['database'], | |
$alias['username'], | |
$alias['password'], | |
$alias['charset'], | |
$alias['buffers'], | |
$alias['dialect'], | |
$alias['role']); | |
} | |
%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment