本文整理汇总了PHP中Am_Query::crossJoin方法的典型用法代码示例。如果您正苦于以下问题:PHP Am_Query::crossJoin方法的具体用法?PHP Am_Query::crossJoin怎么用?PHP Am_Query::crossJoin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Am_Query
的用法示例。
在下文中一共展示了Am_Query::crossJoin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getResourcesForMembers
/**
* select resource accessible for customers using
* records (user_id, resource_id, resource_type, login, email)
* @return Am_Query
*/
function getResourcesForMembers($types = null)
{
if ($types && !is_array($types)) {
$types = (array) $types;
}
$qfree = new Am_Query($this, 'rfree');
$qfree->crossJoin('?_user', 'u')->clearFields()->addField('u.user_id')->addField('rfree.resource_id')->addField('rfree.resource_type')->addField('u.login')->addField('u.email')->addWhere("rfree.fn = 'free'");
$q = $this->_getBaseQuery();
$q->clearFields();
$q->addField('DISTINCT c.user_id')->addField('r.resource_id')->addField('r.resource_type')->addField('u.login')->addField('u.email')->leftJoin('?_user', 'u', 'u.user_id=c.user_id')->addOrder('user_id')->addWhere("r.fn <> 'free'")->addUnion($qfree);
if ($types) {
$q->addWhere('r.resource_type IN (?a)', $types);
}
return $q;
}
示例2: getResourcesForMembers
/**
* select resource accessible for customers using
* records (user_id, resource_id, resource_type, login, email)
* @return Am_Query
*/
function getResourcesForMembers($types = null, $condition = "1=1")
{
if ($types && !is_array($types)) {
$types = (array) $types;
}
$qfree = new Am_Query($this, 'rfree');
$qfree->crossJoin('?_user', 'u')->clearFields()->addField('u.user_id')->addField('rfree.resource_id')->addField('rfree.resource_type')->addField('u.login')->addField('u.email')->addField("rfree.fn", 'fn')->addField("rfree.id", 'fn_id')->groupBy('user_id, resource_id, resource_type', 'u')->addWhere("rfree.fn IN ('free', 'free_without_login')")->addWhere("(\n (rfree.start_days IS NULL AND rfree.stop_days IS NULL) \n OR\n (CEIL((UNIX_TIMESTAMP() - UNIX_TIMESTAMP(u.added))/86400) BETWEEN IFNULL(rfree.start_days,0) AND IFNULL(rfree.stop_days, 90000)) \n OR\n (CEIL((UNIX_TIMESTAMP() - UNIX_TIMESTAMP(u.added))/86400) >= IFNULL(rfree.start_days,0) AND rfree.stop_days = -1) \n )");
if ($types) {
$qfree->addWhere('rfree.resource_type IN (?a) AND ' . $condition, $types);
}
$q = $this->_getBaseQuery();
$q->clearFields();
$q->clearOrder();
$q->addField('DISTINCT c.user_id')->addField('r.resource_id')->addField('r.resource_type')->addField('u.login')->addField('u.email')->addField("r.fn", 'fn')->addField("r.id", 'fn_id')->leftJoin('?_user', 'u', 'u.user_id=c.user_id')->addOrder('user_id')->addOrderRaw("(SELECT _sort_order\n FROM ( SELECT sort_order as _sort_order, \n resource_type as _resource_type, \n resource_id as _resource_id\n FROM ?_resource_access_sort ras) AS _ras\n WHERE _resource_id=resource_id AND _resource_type=resource_type LIMIT 1),\n resource_id, resource_type")->groupBy('user_id, resource_id, resource_type', 'c')->addWhere("r.fn NOT IN ('free', 'free_without_login')")->addUnion($qfree);
if ($types) {
$q->addWhere('r.resource_type IN (?a) AND ' . $condition, $types);
}
return $q;
}