本文整理汇总了PHP中app\models\Authors类的典型用法代码示例。如果您正苦于以下问题:PHP Authors类的具体用法?PHP Authors怎么用?PHP Authors使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Authors类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getAuthorsForDropDownList
/**
* @return array(['id' => 'fullname])
*/
public static function getAuthorsForDropDownList()
{
$authorsModels = Authors::find()->all();
$authors = ArrayHelper::toArray($authorsModels, ['app\\models\\Authors' => ['id', 'fullname' => function ($model) {
return "{$model->firstname} {$model->lastname}";
}]]);
return ArrayHelper::map($authors, 'id', 'fullname');
}
开发者ID:Dr1N,项目名称:BooksOrganizer,代码行数:11,代码来源:Authors.php
示例2: getAuthorsName
public static function getAuthorsName($id = null)
{
$results = ['' => 'Не указан'];
foreach (Authors::find()->all() as $data) {
$results[$data->id] = $data->lastname . ' ' . $data->firstname;
}
return !empty($id) ? $results[$id] : $results;
}
开发者ID:Diakonrus,项目名称:test_zadanie,代码行数:8,代码来源:Authors.php
示例3: getAuthors
public static function getAuthors()
{
$result = ['' => ''];
$x = Authors::find()->all();
foreach ($x as $author) {
$result[$author->id] = "{$author->firstname} {$author->lastname}";
}
return $result;
}
开发者ID:Pontorez,项目名称:kgr,代码行数:9,代码来源:Authors.php
示例4: map
public static function map()
{
$authors = Authors::find()->all();
$map = array();
array_walk($authors, function ($val) use(&$map) {
$map[$val->id] = $val->firstname . ' ' . $val->lastname;
});
return $map;
}
开发者ID:gluck1986,项目名称:yii2test,代码行数:9,代码来源:Authors.php
示例5: getList
public static function getList()
{
$list = [];
$authors = Authors::find()->all();
foreach ($authors as $author) {
$list[$author->id] = $author->firstname . ' ' . $author->lastname;
}
return $list;
}
开发者ID:verve000,项目名称:verve000,代码行数:9,代码来源:Authors.php
示例6: actionUpdate
/**
* Updates an existing Books model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', ['model' => $model, 'authors' => $this->getAuthorsArray(Authors::find()->all())]);
}
}
开发者ID:alaz1987,项目名称:books,代码行数:15,代码来源:BooksController.php
示例7: getAuthors
public function getAuthors()
{
$authors = Authors::find()->orderBy('firstname')->all();
$lastname = ArrayHelper::map($authors, 'id', 'lastname');
$firstname = ArrayHelper::map($authors, 'id', 'firstname');
foreach ($lastname as $key => $value) {
$fullName[$key] = $firstname[$key] . ' ' . $lastname[$key];
}
return $fullName;
}
开发者ID:vitaloldos,项目名称:books,代码行数:10,代码来源:AuthorsSearch.php
示例8: getAuthorList
public static function getAuthorList()
{
$list = array();
$authors = Authors::find()->all();
//Все авторы
foreach ($authors as $value) {
$list[$value->id] = $value->firstname . " " . $value->lastname;
}
return $list;
}
开发者ID:74Genesis,项目名称:BooksCatalog-yii2,代码行数:10,代码来源:Books.php
示例9: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Authors::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id]);
$query->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname]);
return $dataProvider;
}
开发者ID:kh0rn,项目名称:test_app_yii2,代码行数:18,代码来源:AuthorsSeach.php
示例10: getNameAuthor
public static function getNameAuthor($id = NULL)
{
if ($id == NULL) {
return NULL;
}
$author = Authors::find()->where(['id' => $id])->asArray()->one();
if (!empty($author)) {
return $author['firstname'] . ' ' . $author['lastname'];
} else {
return NULL;
}
}
开发者ID:Wulfagor,项目名称:Testing-Task,代码行数:12,代码来源:Authors.php
示例11: actionUpdate
/**
* Updates an existing Books model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$model_b_a_rel = BookAuthorRel::findOne(['b_id' => $id]);
$authorsArr = Authors::authorArr();
if ($model->load(Yii::$app->request->post()) && $model_b_a_rel->load(Yii::$app->request->post())) {
$model->save();
$model_b_a_rel->saveMultiple(1);
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', ['model' => $model, 'model_b_a_rel' => $model_b_a_rel, 'authorsArr' => $authorsArr]);
}
}
开发者ID:snedi,项目名称:book-management,代码行数:19,代码来源:BooksController.php
示例12: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Authors::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'date_create' => $this->date_create, 'date_update' => $this->date_update]);
$query->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
开发者ID:snedi,项目名称:imot,代码行数:21,代码来源:AuthorsSearch.php
示例13: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Authors::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$dataProvider->setSort(['attributes' => ['id', 'fullName' => ['asc' => ['first_name' => SORT_ASC, 'last_name' => SORT_ASC], 'desc' => ['first_name' => SORT_DESC, 'last_name' => SORT_DESC], 'label' => 'Full Name', 'default' => SORT_ASC]]]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id]);
$query->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andWhere('first_name LIKE "%' . $this->fullName . '%" ' . 'OR last_name LIKE "%' . $this->fullName . '%"');
return $dataProvider;
}
开发者ID:fedman,项目名称:books,代码行数:22,代码来源:AuthorsSearch.php
示例14: search
public function search($params)
{
$query = Authors::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$dataProvider->setSort(['attributes' => ['id', 'fullName' => ['asc' => ['firstname' => SORT_ASC, 'lastname' => SORT_ASC], 'desc' => ['firstname' => SORT_DESC, 'lastname' => SORT_DESC], 'default' => SORT_ASC], 'firstname', 'lastname']]);
$this->load($params);
if (!$this->validate()) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id]);
$query->andFilterWhere(['like', 'firstname', $this->firstname]);
$query->andFilterWhere(['like', 'lastname', $this->lastname]);
$query->andWhere('firstname LIKE "%' . $this->fullName . '%" ' . 'OR lastname LIKE "%' . $this->fullName . '%"');
return $dataProvider;
}
开发者ID:verve000,项目名称:verve000,代码行数:15,代码来源:AuthorsSearch.php
示例15: actionUpdate
/**
* Updates an existing Books model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$authors = Authors::getAuthorsForDropDownList();
$model = $this->findModel($id);
//Request from form
if (Yii::$app->request->isPost) {
$model->load(Yii::$app->request->post());
$model->cover = UploadedFile::getInstance($model, 'cover');
if ($model->save()) {
$absoluteUrl = Yii::$app->session->has('absoluteUrl') ? Yii::$app->session->get('absoluteUrl') : Yii::$app->urlManager->createUrl("books");
return $this->redirect($absoluteUrl);
}
}
//Render update form
return $this->render('update', ['model' => $model, 'authors' => $authors]);
}
开发者ID:Dr1N,项目名称:BooksOrganizer,代码行数:22,代码来源:BooksController.php
示例16: actionEdit
public function actionEdit($id = null)
{
if (empty($id)) {
$model = new Books();
} else {
$model = Books::find()->where(['id' => $id])->one();
}
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$model->date_create = date('Y-m-d H:i:s');
$model->save();
return $this->redirect('index.php?r=site%2Fbooks');
}
$authors = Authors::find()->all();
$selected_authors = array();
foreach ($authors as $author) {
$selected_authors[$author->id] = $author['firstname'] . " " . $author['lastname'];
}
return $this->render('edit', ['model' => $model, 'authors' => $selected_authors, 'book_id' => $id]);
}
开发者ID:mustymenko,项目名称:yii-test,代码行数:19,代码来源:BooksController.php
示例17: actionBooks
public function actionBooks()
{
$session = Yii::$app->session;
$search = new SearchForm();
if ($search->load(Yii::$app->request->post()) && $search->validate()) {
$session['search'] = Yii::$app->request->post();
} elseif (!empty($session['search']['SearchForm'])) {
$search->load($session['search']);
}
if (empty($session['search']['SearchForm'])) {
$books = Books::find()->all();
} else {
$books = Books::findWithFilters($session['search']['SearchForm']);
}
$authors = Authors::find()->all();
$selected_authors = array();
foreach ($authors as $author) {
$selected_authors[$author->id] = $author['firstname'] . " " . $author['lastname'];
}
return $this->render('books', ['model' => $search, 'authors' => $selected_authors, 'books' => $books]);
}
开发者ID:mustymenko,项目名称:yii-test,代码行数:21,代码来源:SiteController.php
示例18: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Books::find()->joinWith(['authors' => function (Query $query) {
$query->from(Authors::tableName() . ' authors');
}]);
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider(['query' => $query]);
$dataProvider->sort->attributes['authors.fullname'] = ['asc' => ['authors.firstname' => SORT_ASC, 'authors.lastname' => SORT_ASC], 'desc' => ['authors.firstname' => SORT_DESC, 'authors.lastname' => SORT_DESC]];
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere(['id' => $this->id, 'date_create' => $this->date_create, 'date_update' => $this->date_update, 'date' => $this->date, 'author_id' => $this->author_id]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'preview', $this->preview])->andFilterWhere(['and', ['like', 'authors.firstname', $this->getAttribute('authors.fullname')], ['like', 'authors.lastname', $this->getAttribute('authors.fullname')]]);
if (!is_null($this->from_date) && !is_null($this->to_date)) {
$query->andFilterWhere(['between', 'date', date('Y-m-d', strtotime($this->from_date)), date('Y-m-d', strtotime($this->to_date))]);
}
return $dataProvider;
}
开发者ID:YuukiMur,项目名称:Books_first,代码行数:29,代码来源:BooksSearch.php
示例19: getAuthors
/**
* get Authors array for select box and other
* @return array
*/
public function getAuthors()
{
return ArrayHelper::map(Authors::find()->addSelect([Authors::tableName() . ".*", "CONCAT(firstname, ' ', lastname) AS author_fullname"])->all(), 'id', 'author_fullname');
}
开发者ID:krausweb,项目名称:yiibooks,代码行数:8,代码来源:Books.php
示例20: getAuthor
/**
* @return \yii\db\ActiveQuery
*/
public function getAuthor()
{
return $this->hasOne(Authors::className(), ['id' => 'author_id']);
}
开发者ID:Husniddin,项目名称:books,代码行数:7,代码来源:Books.php
注:本文中的app\models\Authors类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论