Yii2 Working with Relational Data at ActiveDataProvider
Yii2 Working with Relational Data at ActiveDataProvider
namespace common\models; use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Recording; /**
* RecordingSearch represents the model behind the search form about `common\models\Recording`.
*/
class RecordingSearch extends Recording
{
public $integerReg = '/^\s*[+-]?\d+\s*$/'; /**
* @inheritdoc
*/
public function rules()
{
return [
[['book_id'], 'integerAndString'],
];
} public function integerAndString($attribute, $params)
{
if (!preg_match($this->integerReg, $this->$attribute) && !is_string($this->$attribute)) {
$this->addError($attribute, Yii::t('yii', '{attribute} must be an integer or a string.', ['attribute'=>$this->getAttributeLabel($attribute)]));
}
} /**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
// ...... if (empty($this->book_id) || preg_match($this->integerReg, $this->book_id)) {
$query->andFilterWhere(['book_id' => $this->book_id]);
} else {
$query->joinWith('book')->andFilterWhere(['like', Book::tableName().'.name', $this->book_id]);
} // ......
}
}
Yii2 Working with Relational Data at ActiveDataProvider的更多相关文章
- Deal with relational data using libFM with blocks
原文:https://thierrysilbermann.wordpress.com/2015/09/17/deal-with-relational-data-using-libfm-with-blo ...
- 《Using Databases with Python》Week3 Data Models and Relational SQL 课堂笔记
Coursera课程<Using Databases with Python> 密歇根大学 Week3 Data Models and Relational SQL 15.4 Design ...
- Yii2中mongodb使用ActiveRecord的数据操作
概况 Yii2 一个高效安全的高性能PHP框架.mongodb 一个高性能分布式文档存储NOSQL数据库. 关于mongodb与mysql的优缺点,应该都了解过. mysql传统关系数据库,安全稳定 ...
- ExtJS4笔记 Data
The data package is what loads and saves all of the data in your application and consists of 41 clas ...
- MySQL vs. MongoDB: Choosing a Data Management Solution
原文地址:http://www.javacodegeeks.com/2015/07/mysql-vs-mongodb.html 1. Introduction It would be fair to ...
- 100 open source Big Data architecture papers for data professionals
zhuan :https://www.linkedin.com/pulse/100-open-source-big-data-architecture-papers-anil-madan Big Da ...
- Coursera, Big Data 2, Modeling and Management Systems (week 1/2/3)
Introduction to data management 整个coures 2 是讲data management and storage 的,主要内容就是分布式文件系统,HDFS, Redis ...
- [Windows Azure] Data Management and Business Analytics
http://www.windowsazure.com/en-us/develop/net/fundamentals/cloud-storage/ Managing and analyzing dat ...
- Putting Apache Kafka To Use: A Practical Guide to Building a Stream Data Platform-part 1
转自: http://www.confluent.io/blog/stream-data-platform-1/ These days you hear a lot about "strea ...
随机推荐
- 解决IIS出现的问题
- 将一个mapList转换为beanList
public static <T> List<T> copyMapToBean( List<Map<String, Object>> resultM ...
- Pillow不支持color emoji font!
我想在MAC下面用pillow把一些文本转换成PNG图片,在转普通文字的时候都没问题,但在遇到emoji字符的时候就搞不定了,代码如下: import loggingimport PIL.Image ...
- Educational Codeforces Round 52E(构造,快速幂)
#include <bits/stdc++.h>using namespace std;const int mod=998244353;long long b[200007];long l ...
- FFT求卷积(多项式乘法)
FFT求卷积(多项式乘法) 卷积 如果有两个无限序列a和b,那么它们卷积的结果是:\(y_n=\sum_{i=-\infty}^\infty a_ib_{n-i}\).如果a和b是有限序列,a最低的项 ...
- 解读人:范徉,Methylome and Metabolome Analyses Reveal Adaptive Mechanisms in Geobacter sulfurreducens Grown on Different Terminal Electron Acceptors(甲基化组学和代谢组学分析发现Geobacter sulfurreducens生长在不同电子终受体中的适应机制)
发表时间: (2019年4月) IF:3.950 单位: Fujian Provincial Key Laboratory of Soil Environmental Health and Regul ...
- vue使用webpack压缩后体积过大要怎么优化
vue使用webPack压缩后存储过大,怎么优化 在生产环境去除developtool选项 在webpack.config.js中设置的developtool选项,仅适用于开发环境,这样会造成打包成的 ...
- nexus私服的搭建和使用
- day20模块作业
1.模块化作业 1.回顾文件递归遍历. 默写一遍. 入口在: 当文件是个文件夹的时候 出口在: 文件是一个文件 2.计算时间差(用户输入起始时间和结束时间. 计算时间差(小时), 例如, 用户输入20 ...
- 基于CentOS系统下的Oracle的安装
背景 最近的数据库的实验课,要求利用虚拟机安装CentOS系统,并在此系统上安装Oracle_11g软件实现监听,在windows系统上安装SQL Developer软件作为客户端 ,从而可以在SQL ...