本文整理汇总了PHP中Record::convert方法的典型用法代码示例。如果您正苦于以下问题:PHP Record::convert方法的具体用法?PHP Record::convert怎么用?PHP Record::convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record::convert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionWhatsNew
public function actionWhatsNew()
{
if (!Yii::app()->user->isGuest) {
$user = User::model()->findByPk(Yii::app()->user->getId());
$lastLogin = $user->lastLogin;
$contacts = Contacts::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
$actions = Actions::model()->findAll("lastUpdated > {$lastLogin} AND (assignedTo='" . Yii::app()->user->getName() . "' OR assignedTo='Anyone') ORDER BY lastUpdated DESC LIMIT 50");
$sales = Sales::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
$accounts = Accounts::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
$arr = array_merge($contacts, $actions, $sales, $accounts);
$records = Record::convert($arr);
$dataProvider = new CArrayDataProvider($records, array('id' => 'id', 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'sort' => array('attributes' => array('lastUpdated', 'name'))));
$this->render('whatsNew', array('records' => $records, 'dataProvider' => $dataProvider));
} else {
$this->redirect('login');
}
}
示例2: actionSearch
//.........这里部分代码省略.........
if(is_numeric($term)){
$temp=$term;
$first=substr($temp,0,3);
$second=substr($temp,3,3);
$third=substr($temp,6,4);
$contactsCriteria->compare('phone', "($first) $second-$third", true, 'OR');
$contactsCriteria->compare('phone', "$first-$second-$third", true, 'OR');
$contactsCriteria->compare('phone', "$first $second $third", true, 'OR');
$contactsCriteria->compare('phone2', "($first) $second-$third", true, 'OR');
$contactsCriteria->compare('phone2', "$first-$second-$third", true, 'OR');
$contactsCriteria->compare('phone2', "$first $second $third", true, 'OR');
}
$contacts=Contacts::model()->findAll($contactsCriteria);
$actionsCriteria=new CDbCriteria();
$actionsCriteria->compare('actionDescription',$term,true,'OR');
$actions=Actions::model()->findAll($actionsCriteria);
$accountsCriteria=new CDbCriteria();
$accountsCriteria->compare("name",$term,true,"OR");
$accountsCriteria->compare("description",$term,true,"OR");
$accountsCriteria->compare('tickerSymbol',$term,true,'OR');
$accounts=Accounts::model()->findAll($accountsCriteria);
$quotesCriteria=new CDbCriteria();
$quotesCriteria->compare("name",$term,TRUE,"OR");
$quotes=Quote::model()->findAll($quotesCriteria);
$disallow=array(
'contacts',
'actions',
'accounts',
'quotes',
);*/
$modules = Modules::model()->findAllByAttributes(array('searchable' => 1));
$comparisons = array();
foreach ($modules as $module) {
$module->name == 'products' ? $type = ucfirst('Product') : ($type = ucfirst($module->name));
$module->name == 'quotes' ? $type = ucfirst('Quote') : ($type = $type);
$criteria = new CDbCriteria();
$fields = Fields::model()->findAllByAttributes(array('modelName' => $type, 'searchable' => 1));
$temp = array();
foreach ($fields as $field) {
$temp[] = $field->id;
$criteria->compare($field->fieldName, $term, true, "OR");
}
$arr = CActiveRecord::model($type)->findAll($criteria);
$comparisons[$type] = $temp;
$other[$type] = $arr;
}
$high = array();
$medium = array();
$low = array();
$records = array();
$regEx = "/{$term}/i";
foreach ($other as $key => $recordType) {
$fieldList = $comparisons[$key];
foreach ($recordType as $otherRecord) {
foreach ($fieldList as $field) {
$fieldRecord = Fields::model()->findByPk($field);
$fieldName = $fieldRecord->fieldName;
if (preg_match($regEx, $otherRecord->{$fieldName}) > 0) {
switch ($fieldRecord->relevance) {
case "High":
if (!in_array($otherRecord, $high) && !in_array($otherRecord, $medium) && !in_array($otherRecord, $low)) {
$high[] = $otherRecord;
}
break;
case "Medium":
if (!in_array($otherRecord, $high) && !in_array($otherRecord, $medium) && !in_array($otherRecord, $low)) {
$medium[] = $otherRecord;
}
break;
case "Low":
if (!in_array($otherRecord, $high) && !in_array($otherRecord, $medium) && !in_array($otherRecord, $low)) {
$low[] = $otherRecord;
}
break;
default:
$low[] = $otherRecord;
}
}
}
}
}
$records = array_merge($high, $medium);
$records = array_merge($records, $low);
$records = Record::convert($records, false);
$dataProvider = new CArrayDataProvider($records, array('id' => 'id', 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage())));
$this->render('search', array('records' => $records, 'dataProvider' => $dataProvider, 'term' => $term));
} else {
$results = new CActiveDataProvider('Tags', array('criteria' => array('condition' => 'tag="' . $term . '"')));
$this->render('searchTags', array('tags' => $results));
}
}
示例3: actionSearch
//.........这里部分代码省略.........
$userRecords = array();
$regEx = "/" . preg_quote($term, '/') . "/i";
foreach ($other as $key => $recordType) {
$fieldList = $comparisons[$key];
foreach ($recordType as $otherRecord) {
if ($key == 'Actions') {
if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) {
$userHigh[] = $otherRecord;
} else {
$high[] = $otherRecord;
}
} else {
foreach ($fieldList as $field) {
$fieldRecord = Fields::model()->findByPk($field);
$fieldName = $fieldRecord->fieldName;
if (preg_match($regEx, $otherRecord->{$fieldName}) > 0) {
switch ($fieldRecord->relevance) {
case "High":
if (!in_array($otherRecord, $high, true) && !in_array($otherRecord, $medium, true) && !in_array($otherRecord, $low, true) && !in_array($otherRecord, $userHigh, true) && !in_array($otherRecord, $userMedium, true) && !in_array($otherRecord, $userLow, true)) {
if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) {
$userHigh[] = $otherRecord;
} else {
$high[] = $otherRecord;
}
}
break;
case "Medium":
if (!in_array($otherRecord, $high, true) && !in_array($otherRecord, $medium, true) && !in_array($otherRecord, $low, true) && !in_array($otherRecord, $userHigh, true) && !in_array($otherRecord, $userMedium, true) && !in_array($otherRecord, $userLow, true)) {
if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) {
$userMedium[] = $otherRecord;
} else {
$medium[] = $otherRecord;
}
}
break;
case "Low":
if (!in_array($otherRecord, $high, true) && !in_array($otherRecord, $medium, true) && !in_array($otherRecord, $low, true) && !in_array($otherRecord, $userHigh, true) && !in_array($otherRecord, $userMedium, true) && !in_array($otherRecord, $userLow, true)) {
if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) {
$userLow[] = $otherRecord;
} else {
$low[] = $otherRecord;
}
}
break;
default:
if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) {
$userLow[] = $otherRecord;
} else {
$low[] = $otherRecord;
}
}
} elseif ($fieldRecord->type == 'phone') {
$tempPhone = preg_replace('/\\D/', '', $term);
if (strlen($tempPhone) == 10) {
$phoneLookup = PhoneNumber::model()->findByAttributes(array('modelType' => $fieldRecord->modelName, 'number' => $tempPhone, 'fieldName' => $fieldName));
if (!in_array($otherRecord, $high, true) && !in_array($otherRecord, $medium, true) && !in_array($otherRecord, $low, true) && !in_array($otherRecord, $userHigh, true) && !in_array($otherRecord, $userMedium, true) && !in_array($otherRecord, $userLow, true)) {
if (isset($phoneLookup) && $otherRecord->id == $phoneLookup->modelId) {
if ($otherRecord->hasAttribute('assignedTo') && $otherRecord->assignedTo == Yii::app()->user->getName()) {
$userHigh[] = $otherRecord;
} else {
$high[] = $otherRecord;
}
}
}
}
}
}
}
}
}
$records = array_merge($high, $medium);
$records = array_merge($records, $low);
$userRecords = array_merge($userHigh, $userMedium);
$userRecords = array_merge($userRecords, $userLow);
$records = array_merge($userRecords, $records);
$records = Record::convert($records, false);
if (count($records) == 1) {
// Only one match, so go straight to it.
//
// The record's corresponding model class must have
// X2LinkableBehavior for this to be possible.
if (!empty($records[0]['#recordUrl'])) {
$this->redirect($records[0]['#recordUrl']);
}
}
$dataProvider = new CArrayDataProvider($records, array('id' => 'id', 'pagination' => array('pageSize' => Profile::getResultsPerPage())));
$this->render('search', array('records' => $records, 'dataProvider' => $dataProvider, 'term' => $term));
} else {
Yii::app()->user->setState('vcr-list', $term);
$_COOKIE['vcr-list'] = $term;
$tagQuery = "\n SELECT * \n FROM x2_tags\n WHERE tag=:tag\n group BY tag, type, itemId";
$params = array(':tag' => $term);
// group by type and itemId to prevent display of duplicate tags
$sql = Yii::app()->db->createCommand($tagQuery);
$totalItemCount = Yii::app()->db->createCommand("\n SELECT count(*)\n FROM ({$tagQuery}) as t1;\n ")->queryScalar($params);
$results = new CSqlDataProvider($sql, array('totalItemCount' => $totalItemCount, 'sort' => array('defaultOrder' => 'timestamp DESC'), 'pagination' => array('pageSize' => Profile::getResultsPerPage()), 'params' => $params));
$this->render('searchTags', array('tags' => $results, 'term' => $term));
}
}
}
示例4: actionWhatsNew
public function actionWhatsNew(){
if(!Yii::app()->user->isGuest){
$user=UserChild::model()->findByPk(Yii::app()->user->getId());
$lastLogin=$user->lastLogin;
$contacts=ContactChild::model()->findAll("lastUpdated > $lastLogin");
$actions=ActionChild::model()->findAll("lastUpdated > $lastLogin AND (assignedTo='".Yii::app()->user->getName()."' OR assignedTo='Anyone')");
$sales=SaleChild::model()->findAll("lastUpdated > $lastLogin");
$accounts=AccountChild::model()->findAll("lastUpdated > $lastLogin");
$arr=array_merge($contacts,$actions,$sales,$accounts);
//$arr=array_merge($arr,$sales);
//$arr=array_merge($arr,$accounts);
$records=Record::convert($arr);
$dataProvider=new CArrayDataProvider($records,array(
'id'=>'id',
'pagination'=>array(
'pageSize'=>10,
),
));
$this->render('whatsNew',array(
'records'=>$records,
'dataProvider'=>$dataProvider,
));
}
else{
$this->redirect('login');
}
}
示例5: actionSearch
public function actionSearch(){
$term=$_GET['term'];
$contacts=ContactChild::model()->findAllBySql('SELECT * FROM x2_contacts WHERE CONCAT(firstName," ",lastName) LIKE "%'.$term.'%" OR backgroundInfo LIKE "%'.$term.'%"
OR email LIKE "%'.$term.'%" OR firstName LIKE "%'.$term.'%" OR lastName LIKE "%'.$term.'%" OR phone LIKE "%'.$term.'%" OR address LIKE "%'.$term.'%"');
$actions=ActionChild::model()->findAllBySql('SELECT * FROM x2_actions WHERE actionDescription LIKE "%'.$term.'%" LIMIT 10000');
$sales=SaleChild::model()->findAllBySql('SELECT * FROM x2_sales WHERE name LIKE "%'.$term.'%" OR description LIKE "%'.$term.'%"');
$accounts=AccountChild::model()->findAllBySql('SELECT * FROM x2_accounts WHERE name LIKE "%'.$term.'%" OR description LIKE "%'.$term.'%"
OR tickerSymbol LIKE "%'.$term.'%"');
$projects=ProjectChild::model()->findAll();
$cases=CaseChild::model()->findAll();
$marketing=MarketingChild::model()->findAll();
$names=array();
$descriptions=array();
$notes=array();
$records=array();
$regEx="/$term/i";
foreach($contacts as $contact){
if(preg_match($regEx,$contact->firstName." ".$contact->lastName)>0){
$names[]=$contact;
}elseif(preg_match($regEx,$contact->firstName)>0 || preg_match($regEx,$contact->lastName)>0){
$notes[]=$contact;
}elseif(preg_match($regEx,$contact->backgroundInfo)>0){
$descriptions[]=$contact;
}elseif(preg_match($regEx,$contact->email)>0){
$names[]=$contact;
}elseif(preg_match($regEx,$contact->phone)>0){
$names[]=$contact;
}elseif(preg_match($regEx,$contact->address)>0){
$names[]=$contact;
}
}
foreach($actions as $action){
if(preg_match($regEx,$action->actionDescription)>0){
$names[]=$action;
}
}
foreach($sales as $sale){
if(preg_match($regEx,$sale->name)>0){
$names[]=$sale;
}elseif(preg_match($regEx,$sale->description)>0){
$descriptions[]=$sale;
}
}
foreach($accounts as $account){
if(preg_match($regEx,$account->name)>0){
$names[]=$account;
}elseif(preg_match($regEx,$account->tickerSymbol)>0){
$names[]=$account;
}elseif(preg_match($regEx,$account->description)>0){
$descriptions[]=$account;
}elseif(preg_match($regEx,$account->website)>0){
$names[]=$account;
}
}
foreach($projects as $project){
if(preg_match($regEx,$project->name)>0){
$names[]=$project;
}elseif(preg_match($regEx,$project->description)>0){
$descriptions[]=$project;
}
}
foreach($cases as $case){
if(preg_match($regEx,$case->name)>0){
$names[]=$case;
}elseif(preg_match($regEx,$case->description)>0){
$descriptions[]=$case;
}
}
foreach($marketing as $item){
if(preg_match($regEx,$item->name)>0){
$names[]=$item;
}elseif(preg_match($regEx,$item->description)>0){
$descriptions[]=$item;
}
}
$records=array_merge($names,$descriptions);
$records=array_merge($records,$notes);
asort($records);
$records=Record::convert($records);
$dataProvider=new CArrayDataProvider($records,array(
'id'=>'id',
'pagination'=>array(
//.........这里部分代码省略.........