function _fetch() { $rs = $this->_queryID; if (!$rs or $rs->EOF) { $this->fields = false; return false; } $this->fields = array(); if (!$this->_tarr) { $tarr = array(); $flds = array(); for ($i = 0, $max = $this->_numOfFields; $i < $max; $i++) { $f = $rs->Fields($i); $flds[] = $f; $tarr[] = $f->Type; } // bind types and flds only once $this->_tarr = $tarr; $this->_flds = $flds; } $t = reset($this->_tarr); $f = reset($this->_flds); if ($this->hideErrors) { $olde = error_reporting(E_ERROR | E_CORE_ERROR); } // sometimes $f->value be null for ($i = 0, $max = $this->_numOfFields; $i < $max; $i++) { //echo "<p>",$t,' ';var_dump($f->value); echo '</p>'; switch ($t) { case 135: // timestamp if (!strlen((string) $f->value)) { $this->fields[] = false; } else { if (!is_numeric($f->value)) { $val = variant_date_to_timestamp($f->value); } else { $val = $f->value; } $this->fields[] = adodb_date('Y-m-d H:i:s', $val); } break; case 133: // A date value (yyyymmdd) if ($val = $f->value) { $this->fields[] = substr($val, 0, 4) . '-' . substr($val, 4, 2) . '-' . substr($val, 6, 2); } else { $this->fields[] = false; } break; case 7: // adDate if (!strlen((string) $f->value)) { $this->fields[] = false; } else { if (!is_numeric($f->value)) { $val = variant_date_to_timestamp($f->value); } else { $val = $f->value; } if ($val % 86400 == 0) { $this->fields[] = adodb_date('Y-m-d', $val); } else { $this->fields[] = adodb_date('Y-m-d H:i:s', $val); } } break; case 1: // null $this->fields[] = false; break; case 6: // currency is not supported properly; ADOConnection::outp('<b>' . $f->Name . ': currency type not supported by PHP</b>'); $this->fields[] = (double) $f->value; break; default: $this->fields[] = $f->value; break; } //print " $f->value $t, "; $f = next($this->_flds); $t = next($this->_tarr); } // for if ($this->hideErrors) { error_reporting($olde); } @$rs->MoveNext(); // @ needed for some versions of PHP! if ($this->fetchMode & ADODB_FETCH_ASSOC) { $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE); } return true; }
function _fetch() { $rs = $this->_queryID; if (!$rs or $rs->EOF) { $this->fields = false; return false; } $this->fields = array(); if (!$this->_tarr) { $tarr = array(); $flds = array(); for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) { $f = $rs->Fields($i); $flds[] = $f; $tarr[] = $f->Type; } // bind types and flds only once $this->_tarr = $tarr; $this->_flds = $flds; } $t = reset($this->_tarr); $f = reset($this->_flds); if ($this->hideErrors) $olde = error_reporting(E_ERROR|E_CORE_ERROR);// sometimes $f->value be null for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) { //echo "<p>",$t,' ';var_dump($f->value); echo '</p>'; switch($t) { case 135: // timestamp if (!strlen((string)$f->value)) $this->fields[] = false; else { if (!is_numeric($f->value)) # $val = variant_date_to_timestamp($f->value); // VT_DATE stores dates as (float) fractional days since 1899/12/30 00:00:00 $val= (float) variant_cast($f->value,VT_R8)*3600*24-2209161600; else $val = $f->value; $this->fields[] = adodb_date('Y-m-d H:i:s',$val); } break; case 133:// A date value (yyyymmdd) if ($val = $f->value) { $this->fields[] = substr($val,0,4).'-'.substr($val,4,2).'-'.substr($val,6,2); } else $this->fields[] = false; break; case 7: // adDate if (!strlen((string)$f->value)) $this->fields[] = false; else { if (!is_numeric($f->value)) $val = variant_date_to_timestamp($f->value); else $val = $f->value; if (($val % 86400) == 0) $this->fields[] = adodb_date('Y-m-d',$val); else $this->fields[] = adodb_date('Y-m-d H:i:s',$val); } break; case 1: // null $this->fields[] = false; break; case 20: case 21: // bigint (64 bit) $this->fields[] = (float) $f->value; // if 64 bit PHP, could use (int) break; case 6: // currency is not supported properly; ADOConnection::outp( '<b>'.$f->Name.': currency type not supported by PHP</b>'); $this->fields[] = (float) $f->value; break; case 11: //BIT; $val = ""; if(is_bool($f->value)) { if($f->value==true) $val = 1; else $val = 0; } if(is_null($f->value)) $val = null; $this->fields[] = $val; break; default: $this->fields[] = $f->value; break; } //print " $f->value $t, "; $f = next($this->_flds); $t = next($this->_tarr); } // for if ($this->hideErrors) error_reporting($olde); @$rs->MoveNext(); // @ needed for some versions of PHP! if ($this->fetchMode & ADODB_FETCH_ASSOC) { $this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); } return true; }
/** * Helper. Recursively goes through the properties * of a VARIANT object $o of class $classname. * $islist should be TRUE if $o is a collection/list * and provides `Count` and Item() * * @return array of properties */ function populate($o, $classname, $islist = false) { if (!is_array($this->api)) { return false; } $count = $islist ? $o->Count : 1; $populateme = array(); for ($i = 0; $i < $count; $i++) { $item = $islist ? $o->Item($i) : $o; $populateme[$i] = array(); foreach ($this->api[$classname] as $prop => $value) { // skip restricted properties in the basic (free) HTTPWatch edition if ($classname === 'Entry') { if ($item->isRestrictedURL && $this->paidproperties[$prop]) { continue; } } else { if ($this->hasRestrictions() && $this->paidproperties[$prop]) { continue; } } if (is_array($value)) { $populateme[$i][$prop] = $this->populate($item->{$prop}, $value[0], true); } else { if (is_string($value)) { $populateme[$i][$prop] = $this->populate($item->{$prop}, $value, false); } else { if ($value === 1) { $val = $item->{$prop}; if (gettype($val) === "object") { $type = variant_get_type($val); if ($type === 8209) { $val = $this->getStream($val); } if ($type === VT_DATE) { $val = variant_date_to_timestamp($val); } } $populateme[$i][$prop] = $val; } } } } } return $islist ? $populateme : $populateme[0]; }
function _fetch() { $rs = $this->_queryID; if (!$rs or $rs->EOF) { $this->fields = false; return false; } $this->fields = array(); if (!$this->_tarr) { $tarr = array(); $flds = array(); $i = 0; for ($max = $this->_numOfFields; $i < $max; ++$i) { $f = $rs->Fields($i); $flds[] = $f; $tarr[] = $f->Type; } $this->_tarr = $tarr; $this->_flds = $flds; } $t = reset($this->_tarr); $f = reset($this->_flds); if ($this->hideErrors) { $olde = error_reporting(E_ERROR | E_CORE_ERROR); } $i = 0; for ($max = $this->_numOfFields; $i < $max; ++$i) { switch ($t) { case 135: if (!strlen((string) $f->value)) { $this->fields[] = false; break; } else { if (!is_numeric($f->value)) { $val = variant_date_to_timestamp($f->value); } else { $val = $f->value; } $this->fields[] = adodb_date('Y-m-d H:i:s', $val); break; } break; case 133: if ($val = $f->value) { $this->fields[] = substr($val, 0, 4) . '-' . substr($val, 4, 2) . '-' . substr($val, 6, 2); break; } else { $this->fields[] = false; break; } break; case 7: if (!strlen((string) $f->value)) { $this->fields[] = false; break; } else { if (!is_numeric($f->value)) { $val = variant_date_to_timestamp($f->value); } else { $val = $f->value; } if ($val % 86400 == 0) { $this->fields[] = adodb_date('Y-m-d', $val); break; } else { $this->fields[] = adodb_date('Y-m-d H:i:s', $val); break; } break; } break; case 1: $this->fields[] = false; break; case 6: adoconnection::outp('<b>' . $f->Name . ': currency type not supported by PHP</b>'); $this->fields[] = (double) $f->value; break; default: $this->fields[] = $f->value; break; } $f = next($this->_flds); $t = next($this->_tarr); } if ($this->hideErrors) { error_reporting($olde); } @$rs->MoveNext(); if ($this->fetchMode & ADODB_FETCH_ASSOC) { $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE); } return true; }
protected function GetDateTimeFieldValueByName(&$value) { if (isset($value)) { if (is_object($value) && get_class($value) == 'variant' && version_compare(PHP_VERSION, '5.1', '<')) { //$offset = (60 * 60 * 24) + strtotime('1970-01-02 00:00:00'); return new SMDateTime(variant_date_to_timestamp($value)); } else { return SMDateTime::Parse(strval($value), '%Y-%m-%d %H:%M:%S'); } } else { return null; } }