yii-components

DropDownList yii 2.0 example

孤街浪徒 提交于 2020-01-23 06:08:57
问题 I am using yii 2.0 Framework. How i can make options from my database. I found this, but it's yii 1.1: <?php echo CHtml::dropDownList('listname', $select, array('M' => 'Male', 'F' => 'Female')); I want to pass it to form: <?php $form->dropDownList() ?> How i can fill my dropdownlist from my database table? 回答1: Use yii\helpers\Html it contains Html::dropDownList() . echo Html::dropDownList('listname', $select, ['M'=>'Male', 'F'=>'Female']); Check Yii Framework 2.0 API Controller public

DropDownList yii 2.0 example

≡放荡痞女 提交于 2020-01-23 06:06:58
问题 I am using yii 2.0 Framework. How i can make options from my database. I found this, but it's yii 1.1: <?php echo CHtml::dropDownList('listname', $select, array('M' => 'Male', 'F' => 'Female')); I want to pass it to form: <?php $form->dropDownList() ?> How i can fill my dropdownlist from my database table? 回答1: Use yii\helpers\Html it contains Html::dropDownList() . echo Html::dropDownList('listname', $select, ['M'=>'Male', 'F'=>'Female']); Check Yii Framework 2.0 API Controller public

Uploading file in Yii using ajax

最后都变了- 提交于 2020-01-14 12:47:11
问题 I am trying to implement file upload from a popover using ajax like facebook chat . I found that using ajax submit button, it is not able to upload files in Yii. So I tried to use like php method. Here is the php method I found, which is well working. <div id='preview'> </div> <form id="imageform" method="post" enctype="multipart/form-data" action='ajaximage.php'> Upload image: <div id='imageloadstatus' style='display:none'><img src="loader.gif" alt="Uploading...."/></div> <div id=

Print out a SQL single query (Yii 1.x)

半城伤御伤魂 提交于 2020-01-14 12:36:33
问题 I have a massive query that is generated using CDbCriteria as shown below:- $schema = Yii::app()->db->schema; $builder = $schema->commandBuilder; // how to echo out this query? $command = $builder->createFindCommand($schema->getTable('myuser'), $criteria); $results = $command->queryAll(); I know I can use the 'logging' feature of Yii to view the query, is it possible to just echo out this single query (as opposed to having Yii show me tons of other queries that are being run on the page). 回答1

Print out a SQL single query (Yii 1.x)

混江龙づ霸主 提交于 2020-01-14 12:36:11
问题 I have a massive query that is generated using CDbCriteria as shown below:- $schema = Yii::app()->db->schema; $builder = $schema->commandBuilder; // how to echo out this query? $command = $builder->createFindCommand($schema->getTable('myuser'), $criteria); $results = $command->queryAll(); I know I can use the 'logging' feature of Yii to view the query, is it possible to just echo out this single query (as opposed to having Yii show me tons of other queries that are being run on the page). 回答1

Yii CUserIdentity vs a User Model

北慕城南 提交于 2020-01-13 19:55:13
问题 I have at least one model in my Yii project that will need to reference a particular user ID. In my SQL for the model I have something like CONSTRAINT FOREIGN KEY (user_id) REFERENCES User(id) . I was going to go ahead and create a User model when I came across the docs for CUserIdentity. I have to admit I am confused. Is a CUserIdentity a user or a state associated with a particular user-case? I would like to use as much of the built-in Yii features as possible since they handle a lot of

Yii CUserIdentity vs a User Model

南楼画角 提交于 2020-01-13 19:53:22
问题 I have at least one model in my Yii project that will need to reference a particular user ID. In my SQL for the model I have something like CONSTRAINT FOREIGN KEY (user_id) REFERENCES User(id) . I was going to go ahead and create a User model when I came across the docs for CUserIdentity. I have to admit I am confused. Is a CUserIdentity a user or a state associated with a particular user-case? I would like to use as much of the built-in Yii features as possible since they handle a lot of

Yii::app()->getModule('user') is not returning the right value view/layout/main.php

戏子无情 提交于 2020-01-06 08:00:51
问题 Yii::app()->getModule('user') is not returning the right value in view/layouts/main.php I am using Yii-User YII-User Extension to manage the User related features. When I Yii::app()->getModule('user')->loginUrl, I get Trying to get property of non-object at array('url'=>Yii::app()->getModule('user')->loginUrl, 'label'=>Yii::app()->getModule('user')->t("Login"), 'visible'=>Yii::app()->user->isGuest), Pls tell me whats going wrong, is it a known issue or something like that. Here is the config

Ignoring Server Down Error Message when using Yii CMemCache

给你一囗甜甜゛ 提交于 2019-12-25 07:22:24
问题 I've enabling yii memcached, How do I ignoring this error when dedicated memcached server was down. MemcachePool::get(): Server 192.168.1.200 (tcp 11211, udp 0) failed with: No connection could be made because the target machine actively refused it. (10061) Thanks, 回答1: You could: extend CMemCache as your own caching component override the getters and setters to return false if no connection is present or connection isn't active, otherwise call the parent:: equivalent method (with any

Yii Framework: setPathOfAlias() returns null

穿精又带淫゛_ 提交于 2019-12-25 04:24:15
问题 I am trying to put MaxMind's GeoIp2 into my Yii application. Basically, I copied the files under "src" (see previous link) under protected -> vendors -> maxmind . The folder structure under my application is the following: protected |---- vendors |---- Zend |---- maxmind |---- Database |---- Reader.php |---- Model |---- ... |---- ... After that, I created the path aliases into my index.php file: Yii::setPathOfAlias('Zend', Yii::getPathOfAlias('application.vendors.Zend')); Yii::setPathOfAlias(