本文整理汇总了PHP中Object::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::fetch方法的具体用法?PHP Object::fetch怎么用?PHP Object::fetch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Object
的用法示例。
在下文中一共展示了Object::fetch方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Given the list of params in the params array, fetch the object
* and store the values in the values array
*
* @param Object $block typically a Phone|Email|IM object
* @param string $blockName name of the above object
* @param array $params input parameters to find object
* @param array $values output values of the object
* @param array $ids the array that holds all the db ids
* @param int $blockCount number of blocks to fetch
*
* @return array of $block objects.
* @access public
* @static
*/
function &getValues(&$block, $blockName, &$params, &$values, &$ids, $blockCount = 0)
{
$block->copyValues($params);
$flatten = false;
if (empty($blockCount)) {
$blockCount = 1;
$flatten = true;
} else {
$values[$blockName] = array();
$ids[$blockName] = array();
}
$blocks = array();
// we first get the primary location due to the order by clause
$block->orderBy('is_primary desc');
$block->find();
for ($i = 0; $i < $blockCount; $i++) {
if ($block->fetch()) {
if ($flatten) {
CRM_Core_DAO::storeValues($block, $values);
$ids[$blockName] = $block->id;
} else {
$values[$blockName][$i + 1] = array();
CRM_Core_DAO::storeValues($block, $values[$blockName][$i + 1]);
$ids[$blockName][$i + 1] = $block->id;
}
$blocks[$i + 1] = clone $block;
}
}
return $blocks;
}
示例2: render
/**
* Fast string templating.
* Uses a Twig-like syntax.
*
* @example
* echo Text::render('Your IP is : {{ server.REMOTE_HOST }}',array('server' => $_SERVER));
*
* @author Stefano Azzolini <stefano.azzolini@caffeinalab.com>
* @access public
* @static
* @param mixed $t The text template
* @param mixed $v (default: null) The array of values exposed in template.
* @return string
*/
public static function render($t, $v = null)
{
if (Options::get('core.text.replace_empties', true)) {
$replacer = function ($c) use($v) {
return Object::fetch(trim($c[1]), $v);
};
} else {
$replacer = function ($c) use($v) {
return Object::fetch(trim($c[1]), $v) ?: $c[0];
};
}
return preg_replace_callback("(\\{\\{([^}]+)\\}\\})S", $replacer, $t);
}
示例3: while
/**
* This will retrieve the results and place them into a nice array to use.
*
* @param Object $stmt : Results of prior query
**/
function get_result($stmt)
{
$meta = $stmt->result_metadata();
while ($field = $meta->fetch_field()) {
$parameters[] =& $row[$field->name];
}
call_User_func_array(array($stmt, 'bind_result'), $parameters);
while ($stmt->fetch()) {
foreach ($row as $key => $val) {
$x[$key] = $val;
}
$results[] = $x;
}
if (isset($results)) {
return $results;
}
}
示例4: retrieveBlock
/**
* Given the list of params in the params array, fetch the object
* and store the values in the values array
*
* @param Object $block typically a Phone|Email|IM|OpenID object
* @param string $blockName name of the above object
* @param array $values output values of the object
*
* @return array of $block objects.
* @access public
* @static
*/
static function retrieveBlock(&$block, $blockName)
{
// we first get the primary location due to the order by clause
$block->orderBy('is_primary desc, id');
$block->find();
$count = 1;
$blocks = array();
while ($block->fetch()) {
CRM_Core_DAO::storeValues($block, $blocks[$count]);
//unset is_primary after first block. Due to some bug in earlier version
//there might be more than one primary blocks, hence unset is_primary other than first
if ($count > 1) {
unset($blocks[$count]['is_primary']);
}
$count++;
}
return $blocks;
}
示例5: _fetch
/**
* 抓取页面
* @access protected
* @param string $url 目标页面url
* @param string $mode 采集模式,支持snoopy,curl,和file
* @return string
*/
protected function _fetch($url, $mode = 'snoopy')
{
switch ($mode) {
case 'snoopy':
if (!$this->snoopy) {
$this->snoopy = new Snoopy();
$this->snoopy->agent = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36';
}
//设置代理
if ($this->proxy) {
$this->snoopy->proxy_host = $this->proxy['host'];
$this->snoopy->proxy_port = $this->proxy['port'];
} else {
$this->snoopy->proxy_host = $this->snoopy->proxy_port = "";
}
if ($this->snoopy->fetch($url)) {
return array('http_code' => $this->snoopy->status, 'content' => $this->snoopy->results);
} else {
$this->error = "抓取页面失败!";
return false;
}
break;
case 'curl':
if (!$this->curl) {
$this->curl = curl_init();
// 设置浏览器信息
curl_setopt($this->curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36");
// 设置header
curl_setopt($this->curl, CURLOPT_HEADER, 0);
curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, 1);
// 设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上。
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);
}
//设置代理
if ($this->proxy) {
curl_setopt($this->curl, CURLOPT_PROXY, $this->proxy['ip'] . ':' . $this->proxy['port']);
} else {
curl_setopt($this->curl, CURLOPT_PROXY, '');
}
// 设置需要抓取的URL
curl_setopt($this->curl, CURLOPT_URL, $url);
// 运行cURL,请求网页
$content = curl_exec($this->curl);
if ($content) {
$http_code = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
return array('http_code' => $http_code, 'content' => $content);
} else {
$this->error = "抓取页面失败!";
return false;
}
break;
default:
$content = file_get_contents($url);
if ($content) {
return array('http_code' => 200, 'content' => $content);
} else {
$this->error = "抓取页面失败!";
return false;
}
break;
}
}
示例6: __construct
/**
* Construct an object of the DBMS_Result class for a generic DBMS Result system
* Permits to know what functions have to be implemented and can be used
* @param Object $handle DBMS Result like MySQLi_Result or else
*/
public function __construct($handle)
{
$infos = $handle->result_metadata();
assert('$infos != NULL');
$fields = $infos->fetch_fields();
$values = array();
$s = '';
for ($i = 0; $i < count($fields); $i++) {
if (!empty($s)) {
$s .= ', ';
}
$s .= '$values["' . $fields[$i]->name . '"]';
}
eval('$handle->bind_result(' . $s . ');');
for ($i = 0; $i < $handle->affected_rows; $i++) {
$handle->fetch();
$obj = new stdClass();
// Create new empty object
foreach ($values as $key => $value) {
$obj->{$key} = $value;
}
$this->results[] = $obj;
}
}
示例7: render
/**
* Fast string templating.
* Uses a Twig-like syntax.
*
* @example
* echo String::render('Your IP is : {{ server.REMOTE_HOST }}',array('server' => $_SERVER));
*
* @author Stefano Azzolini <stefano.azzolini@caffeinalab.com>
* @access public
* @static
* @param mixed $t The text template
* @param mixed $v (default: null) The array of values exposed in template.
* @return string
*/
public static function render($t, $v = null)
{
for ($r = $ox = $x = false; false !== ($x = $y = strpos($t, '{{', $x)); $r .= substr($t, $ox, $x - $ox), $c = substr($t, $x += 2, $l = ($y = strpos($t, '}}', $x)) - $x), $ox = $x += $l + 2, $r .= Object::fetch($c, $v)) {
}
return $r === false ? $t : $r . substr($t, $ox);
}
示例8: loadJsonObject
/**
* Return a sigle row query like JSON
* @return string
*/
public function loadJsonObject()
{
$jsonObject = json_encode($this->stmt->fetch(PDO::FETCH_ASSOC));
return $jsonObject;
}