本文整理汇总了PHP中ADORecordSet_array::InitArrayFields方法的典型用法代码示例。如果您正苦于以下问题:PHP ADORecordSet_array::InitArrayFields方法的具体用法?PHP ADORecordSet_array::InitArrayFields怎么用?PHP ADORecordSet_array::InitArrayFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ADORecordSet_array
的用法示例。
在下文中一共展示了ADORecordSet_array::InitArrayFields方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmlrpcval2rs
/**
* Given a well-formed xmlrpc struct object returns an AdoDB object
*
* @todo add some error checking on the input value
*/
function xmlrpcval2rs(&$xmlrpcval)
{
$fields_array = array();
$data_array = array();
// rebuild column information
$header = $xmlrpcval->structmem('header');
$numfields = $header->structmem('fieldcount');
$numfields = $numfields->scalarval();
$numrecords = $header->structmem('recordcount');
$numrecords = $numrecords->scalarval();
$sqlstring = $header->structmem('sql');
$sqlstring = $sqlstring->scalarval();
$fieldinfo = $header->structmem('fieldinfo');
for ($i = 0; $i < $numfields; $i++) {
$temp = $fieldinfo->arraymem($i);
$fld = new ADOFieldObject();
while (list($key, $value) = $temp->structeach()) {
if ($key == "name") {
$fld->name = $value->scalarval();
}
if ($key == "type") {
$fld->type = $value->scalarval();
}
if ($key == "max_length") {
$fld->max_length = $value->scalarval();
}
if ($key == "not_null") {
$fld->not_null = $value->scalarval();
}
if ($key == "has_default") {
$fld->has_default = $value->scalarval();
}
if ($key == "default_value") {
$fld->default_value = $value->scalarval();
}
}
// while
$fields_array[] = $fld;
}
// for
// fetch recordset information into php array
$body = $xmlrpcval->structmem('body');
for ($i = 0; $i < $numrecords; $i++) {
$data_array[$i] = array();
$xmlrpcrs_row = $body->arraymem($i);
for ($j = 0; $j < $numfields; $j++) {
$temp = $xmlrpcrs_row->arraymem($j);
$data_array[$i][$j] = $temp->scalarval();
}
// for j
}
// for i
// finally build in-memory recordset object and return it
$rs = new ADORecordSet_array();
$rs->InitArrayFields($data_array, $fields_array);
return $rs;
}
示例2: strpos
//.........这里部分代码省略.........
$rs->affectedrows = (int) $meta[3];
$rs->insertid = $meta[4];
return $rs;
}
# If detect timeout here return false, forcing a fresh query and new cache values
#
# Under high volume loads, we want only 1 thread/process to _write_file
# so that we don't have 50 processes queueing to write the same data.
#
# We implement a probabilistic blocking write:
#
# -2 sec before timeout, give processes 1/16 chance of writing to file with blocking io
# -1 sec after timeout give processes 1/4 chance of writing with blocking
# +0 sec after timeout, give processes 100% chance writing with blocking
if (sizeof($meta) > 1) {
if ($timeout > 0) {
$tdiff = $meta[1] + $timeout - time();
if ($tdiff <= 2) {
switch ($tdiff) {
case 2:
if ((rand() & 0xf) == 0) {
fclose($fp);
$err = "Timeout 2";
return false;
}
break;
case 1:
if ((rand() & 0x3) == 0) {
fclose($fp);
$err = "Timeout 1";
return false;
}
break;
default:
fclose($fp);
$err = "Timeout 0";
return false;
}
// switch
}
// if check flush cache
}
// (timeout>0)
$ttl = $meta[1];
}
$meta = false;
$meta = fgetcsv($fp, 16000, ",");
if (!$meta) {
fclose($fp);
$err = "Unexpected EOF 1";
return false;
}
}
// Get Column definitions
$flds = array();
foreach ($meta as $o) {
$o2 = explode(':', $o);
if (sizeof($o2) != 3) {
$arr[] = $meta;
$flds = false;
break;
}
$fld = new ADOFieldObject();
$fld->name = urldecode($o2[0]);
$fld->type = $o2[1];
$fld->max_length = $o2[2];
$flds[] = $fld;
}
} else {
fclose($fp);
$err = "Recordset had unexpected EOF 2";
return false;
}
// slurp in the data
$MAXSIZE = 128000;
$text = fread($fp, $MAXSIZE);
$cnt = 1;
while (strlen($text) == $MAXSIZE * $cnt) {
$text .= fread($fp, $MAXSIZE);
$cnt += 1;
}
fclose($fp);
//print "<hr>";
//print_r($text);
//if (strlen($text) == 0) $arr = array();
//else
$arr = unserialize($text);
//print_r($arr);
if (!is_array($arr)) {
$err = "Recordset had unexpected EOF (in serialized recordset)";
if (get_magic_quotes_runtime()) {
$err .= ". Magic Quotes Runtime should be disabled!";
}
return false;
}
$rs = new ADORecordSet_array();
$rs->timeCreated = $ttl;
$rs->InitArrayFields($arr, $flds);
return $rs;
}
示例3: array
function &_rs2rs(&$rs, $nrows = -1, $offset = -1)
{
$arr =& $rs->GetArrayLimit($nrows, $offset);
$flds = array();
for ($i = 0, $max = $rs->FieldCount(); $i < $max; $i++) {
$flds[] =& $rs->FetchField($i);
}
$rs->Close();
$rs2 = new ADORecordSet_array();
$rs2->InitArrayFields($arr, $flds);
return $rs2;
}
示例4: flock
//.........这里部分代码省略.........
fclose($fp);
return false;
}
fclose($fp);
if ($timeout > 0) {
$err = ' Timeout for insert/update/delete illegal';
return false;
}
$val = 1;
$rs = new ADORecordSet($val);
$rs->EOF = true;
$rs->_numOfFields = 0;
$rs->sql = urldecode($meta[2]);
$rs->affectedrows = (int) $meta[3];
$rs->insertid = $meta[4];
$rs->aa = '100';
return $rs;
}
# Under high volume loads, we want only 1 thread/process to _write_file
# so that we don't have 50 processes queueing to write the same data.
# Would require probabilistic blocking write
#
# -2 sec before timeout, give processes 1/16 chance of writing to file with blocking io
# -1 sec after timeout give processes 1/4 chance of writing with blocking
# +0 sec after timeout, give processes 100% chance writing with blocking
if (sizeof($meta) > 1) {
if ($timeout > 0) {
$tdiff = $meta[1] + $timeout - time();
if ($tdiff <= 2) {
switch ($tdiff) {
case 2:
if ((rand() & 15) == 0) {
fclose($fp);
$err = "Timeout 2";
return false;
}
break;
case 1:
if ((rand() & 3) == 0) {
fclose($fp);
$err = "Timeout 1";
return false;
}
break;
default:
fclose($fp);
$err = "Timeout 0";
return false;
}
// switch
}
// if check flush cache
}
// (timeout>0)
$ttl = $meta[1];
}
$meta = fgetcsv($fp, 8192, ",");
if (!$meta) {
fclose($fp);
$err = "Unexpected EOF 1";
return false;
}
}
// Get Column definitions
$flds = array();
foreach ($meta as $o) {
$o2 = explode(':', $o);
if (sizeof($o2) != 3) {
$arr[] = $meta;
$flds = false;
break;
}
$fld = new ADOFieldObject();
$fld->name = urldecode($o2[0]);
$fld->type = $o2[1];
$fld->max_length = $o2[2];
$flds[] = $fld;
}
} else {
fclose($fp);
$err = "Recordset had unexpected EOF 2";
//print "$url ";print_r($meta);
//die();
return false;
}
// slurp in the data
$text = fread($fp, MAX_BLOB_SIZE);
fclose($fp);
//$text = substr($text,0,44);
$arr = @unserialize($text);
//var_dump($arr);
if (!is_array($arr)) {
$err = "Recordset had unexpected EOF 3";
return false;
}
$rs = new ADORecordSet_array();
$rs->timeCreated = $ttl;
$rs->InitArrayFields($arr, $flds);
return $rs;
}
示例5: csv2rs
//.........这里部分代码省略.........
$err = "Timeout 3";
return false;
}
break;
case 2:
if ((rand() & 15) == 0) {
fclose($fp);
$err = "Timeout 2";
return false;
}
break;
case 1:
if ((rand() & 3) == 0) {
fclose($fp);
$err = "Timeout 1";
return false;
}
break;
default:
fclose($fp);
$err = "Timeout 0";
return false;
}
// switch
}
// if check flush cache
}
// (timeout>0)
$ttl = $meta[1];
}
//================================================
// new cache format - use serialize extensively...
if ($meta[0] === '====1') {
// slurp in the data
$MAXSIZE = 128000;
$text = fread($fp, $MAXSIZE);
if (strlen($text)) {
while ($txt = fread($fp, $MAXSIZE)) {
$text .= $txt;
}
}
fclose($fp);
$rs = unserialize($text);
if (is_object($rs)) {
$rs->timeCreated = $ttl;
} else {
$err = "Unable to unserialize recordset";
//echo htmlspecialchars($text),' !--END--!<p>';
}
return $rs;
}
$meta = false;
$meta = fgetcsv($fp, 32000, ",");
if (!$meta) {
fclose($fp);
$err = "Unexpected EOF 1";
return false;
}
}
// Get Column definitions
$flds = array();
foreach ($meta as $o) {
$o2 = explode(':', $o);
if (sizeof($o2) != 3) {
$arr[] = $meta;
$flds = false;
break;
}
$fld = new ADOFieldObject();
$fld->name = urldecode($o2[0]);
$fld->type = $o2[1];
$fld->max_length = $o2[2];
$flds[] = $fld;
}
} else {
fclose($fp);
$err = "Recordset had unexpected EOF 2";
return false;
}
// slurp in the data
$MAXSIZE = 128000;
$text = '';
while ($txt = fread($fp, $MAXSIZE)) {
$text .= $txt;
}
fclose($fp);
@($arr = unserialize($text));
//var_dump($arr);
if (!is_array($arr)) {
$err = "Recordset had unexpected EOF (in serialized recordset)";
if (get_magic_quotes_runtime()) {
$err .= ". Magic Quotes Runtime should be disabled!";
}
return false;
}
$rs = new ADORecordSet_array();
$rs->timeCreated = $ttl;
$rs->InitArrayFields($arr, $flds);
return $rs;
}