本文整理汇总了PHP中util::array_merge方法的典型用法代码示例。如果您正苦于以下问题:PHP util::array_merge方法的具体用法?PHP util::array_merge怎么用?PHP util::array_merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util
的用法示例。
在下文中一共展示了util::array_merge方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: massign
public function massign($data)
{
if (!is_array($data)) {
return false;
}
$this->data = util::array_merge($this->data, $data);
}
示例2: setParams
/**
* can set params batch by method
* @param array $data
* @param enum $type = get / post
* @return bool
*/
public static function setParams($data, $type = 'get')
{
self::_checkInit();
if (!is_array($data)) {
return false;
}
if ($type == 'get') {
$_GET = util::array_merge($_GET, $data);
self::$_getData = util::array_merge(self::$_getData, self::_formatDeep($data));
} else {
$_POST = util::array_merge($_POST, $data);
self::$_postData = util::array_merge(self::$_postData, self::_formatDeep($data));
}
}
示例3: count
public function count($key = '')
{
auto::isDebugMode() && ($_debugMicrotime = microtime(true));
$countKey = empty($key) ? '*' : $key;
$where = $this->_getWhere();
$sql = $where['sql'];
$sqlData = $where['data'];
$values = array();
if (is_array($sqlData)) {
$values = util::array_merge($values, $sqlData);
}
$sql = "SELECT COUNT({$countKey}) FROM " . $this->_table . $sql;
$this->_lastQuery = array($sql, $values);
$sth = $this->_getPdoByMethodName(__FUNCTION__)->prepare($sql);
$res = $sth->execute($values);
if ($res === false) {
$this->_raiseError('count query failed~', exception_mysqlpdo::type_query_error);
}
$count = $sth->fetchColumn();
$this->_clearStat();
auto::isDebugMode() && auto::dqueue(__METHOD__, 'cost ' . (microtime(true) - $_debugMicrotime) . 's of query: ' . var_export($this->_lastQuery, true));
return $count;
}
示例4: whereMatch
public function whereMatch($match = array(), $in = array(), $notIn = array(), $like = array(), $between = array())
{
/**
* where a=1 and b=2 and c in (123,34,3,5) and b not in (3,2,4) and x like '435%' and y between y1 and y2, group by a order by b desc limit 20
* *
* array('match'=>array(), 'in'=>array(), 'like'=>array() )
*
* @return string
*/
$sql = '1';
$whereData = array();
if ($match && is_array($match)) {
foreach ($match as $k => $v) {
$sql .= ' AND ' . $k . ' = ? ';
$whereData[] = $v;
}
}
if ($in && is_array($in)) {
foreach ($in as $k => $v) {
if (!is_array($v)) {
continue;
}
$insteads = array_fill(0, count($v), '?');
$sql .= ' AND ' . $k . ' IN( ' . implode(',', $insteads) . ') ';
$whereData = util::array_merge($whereData, $v);
}
}
if ($notIn && is_array($notIn)) {
foreach ($notIn as $k => $v) {
if (!is_array($v)) {
continue;
}
$insteads = array_fill(0, count($v), '?');
$sql .= ' AND ' . $k . ' NOT IN( ' . implode(',', $insteads) . ') ';
$whereData = util::array_merge($whereData, $v);
}
}
if ($like && is_array($like)) {
foreach ($like as $k => $v) {
$sql .= ' AND ' . $k . ' LIKE ? ';
$whereData[] = $v;
}
}
if ($between && is_array($between)) {
foreach ($between as $k => $v) {
$sql .= ' AND ( ' . $k . ' BETWEEN ? AND ? )';
$whereData[] = $v[0];
$whereData[] = $v[1];
}
}
$this->_sql['where'] = $sql;
$this->_sql['whereData'] = $whereData;
return $this;
}