Yii

Android unable to connect my web-service in app

﹥>﹥吖頭↗ 提交于 2020-01-07 06:44:30
问题 There must be a lot of questions regarding to mine. But i couldn't find a good solution for it, so that's why i am posting a question. I have created a REST web-service using yii framework. Below is my code for the api class UsersController extends ActiveController { public $modelClass = 'app\models\Users'; public function actions() { $actions = parent::actions(); unset($actions['index']); return $actions; } public function actionIndex() { $users = Users::find()->all(); \Yii::$app->response-

How to display Yii's CLinkPager first and last buttons

巧了我就是萌 提交于 2020-01-07 06:15:13
问题 My page number is like: Page:1 2 3 4 5 last But I want to change it like: << first | < previous | 1 | ... | 5 | next > | last >> How to change this? My code is: <?php $this->widget('CLinkPager', array( 'currentPage' => $pages->getCurrentPage(), 'itemCount' => $item_count, 'pageSize' => $page_size, //'linkHash'=>'ls', 'maxButtonCount' => 5, 'firstPageLabel' => '', 'prevPageLabel' => '', 'nextPageLabel' => '', 'lastPageLabel' => 'last', 'header' => '<p>Page:</p>', /*'pager'=>array( 'class'=>

Adding CbuttonColumn to Csv Header Column array (Used in CgridView) - Yii Framework

你。 提交于 2020-01-07 05:46:21
问题 I am trying to add Delete button to CgridView , I am displaying CgridView columns from CSV file headers . I am storing Csv columns names in array, Now i want to add one more button column to delete the record. Here is my code, <?php $file = fopen('D:/xampp/htdocs/ccvv7/images/importcsv/load.csv', 'r'); $data = array(); while (($line = fgetcsv($file)) !== FALSE) { $data[] = $line; } fclose($file); $columns = array(); foreach ($data[0] as $key => $value) { $columns[] = array( 'name' => $key,

Why i getting an error “Call to a member function formName() on a non-object”

安稳与你 提交于 2020-01-07 03:15:13
问题 i try to save multilanguaged content My About model ... public function rules() { return [ [['status', 'date_update', 'date_create'], 'integer'], [['date_update', 'date_create'], 'required'], ]; } ... public function getContent($lang_id = null) { $lang_id = ($lang_id === null) ? Lang::getCurrent()->id : $lang_id; return $this->hasOne(AboutLang::className(), ['post_id' => 'id'])->where('lang_id = :lang_id', [':lang_id' => $lang_id]); } My AboutLang model public function rules() { return [ [[

Why i getting an error “Call to a member function formName() on a non-object”

試著忘記壹切 提交于 2020-01-07 03:14:06
问题 i try to save multilanguaged content My About model ... public function rules() { return [ [['status', 'date_update', 'date_create'], 'integer'], [['date_update', 'date_create'], 'required'], ]; } ... public function getContent($lang_id = null) { $lang_id = ($lang_id === null) ? Lang::getCurrent()->id : $lang_id; return $this->hasOne(AboutLang::className(), ['post_id' => 'id'])->where('lang_id = :lang_id', [':lang_id' => $lang_id]); } My AboutLang model public function rules() { return [ [[

Yii: Unable to delete the things from the admin panel

一世执手 提交于 2020-01-07 03:00:32
问题 I am a yiibie and I am having a problem that any event that I am trying to delete is not getting deleted and it gives me an error which is Error 500: <h1>CDbException</h1> <p>CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`response_system`.`user_join_event`, CONSTRAINT `fk_user_join_event_event1` FOREIGN KEY (`event_id`) REFERENCES `event` (`id`) ON DELETE NO ACTION ON

How to config and install Phundament 3 with MySQL?

旧巷老猫 提交于 2020-01-07 02:31:20
问题 Downloaded and place phundament3 in local machine, ya its working but not when trying to config /install it with Mysql database followed like installation doc , where I can find its Mysql dump? if installation do all for me then how to do in local? can any one explain steps, using Ubuntu 11.04 回答1: If you accidentally mixed up your installation, eg. you've installed Phundament with a SQLite database (which is the default), but you want to install it with MySQL, take the following steps:

yii framework, how to implement union sql

主宰稳场 提交于 2020-01-07 02:27:21
问题 i am trying to do something like this on yii actionAdmin() select * from car where carbrand = 'bmw' limit 1 union select * from car where carbrand = 'mercedez' i cannot find anything to do with union on CDbCriteria Is there any other way? 回答1: U can try to merge criteria with another one http://www.yiiframework.com/doc/api/1.1/CDbCriteria#mergeWith-detail or u can use DAO and CDbCommand http://www.yiiframework.com/doc/api/1.1/CDbCommand#union-detail. 来源: https://stackoverflow.com/questions

Use Yii findAll to return a model w/ all properties

為{幸葍}努か 提交于 2020-01-07 02:24:40
问题 I am still new to Yii and wondering how to return JSON from the $models = MyModel::model()->findAll(); . Say for example MyModel has a relation for MyChildModels in a ONE:MANY fashion. Straight from the Rest example on the Yii site I have: foreach ($models as $model) { $rows[] = $model->attributes; } $this->_sendResponse(200, CJSON::encode($rows), 'application/json'); I get all of the model's attributes but NOT the joined relation attributes. Similarly, I can change the $rows line to be:

how to generating a dropdown list in yii2

耗尽温柔 提交于 2020-01-06 23:46:17
问题 I tried to make a dropdown list in yii2 using this link : How to make a drop down list in yii2? my code is : <?php use yii\helpers\ArrayHelper; use app\models\Product; ?> <?= $listdata=ArrayHelper::map(Product::find()->all(),'id','name'); ?> <?= $form->field($model, 'parent_id')-> dropDownList($listdata); ?> but I have a problem in line of using ArrayHelper the problem is: PHP Notice – yii\base\ErrorException Array to string conversion .......! I tested the below code : $listData=ArrayHelper: