Yii

createUrl Yii - should we call it on controller view, or doesn't matter?

陌路散爱 提交于 2020-01-05 09:22:27
问题 Should createUrl be called on controller or in views ? It doesn't matter? Or it does matter ? Is there a rule we should follow ? Like methods that extend ccontroller should be used on controllers and so on .. ? 回答1: In View you can use this snippet. You can use this snippet everywhere. Yii::app()->createUrl(); But for me is better to define a url in controller's action, and use simply $some_url var in the view. class SomeController extends Controller { public function actionSomeAction() {

Yii: relate n:m on both sides of an AR

烈酒焚心 提交于 2020-01-05 07:56:11
问题 For a better user experience, I didn't want to just make a casual PM system, but actually group it into conversations. And as an added feature, being able to PM multiple people at once. Something that was requested multiple times. So I created this: /* User conversations ONE Conversation HAS MANY Conversation Members HAS MANY Users HAS MANY Private Messages ONE Private Message HAS ONE Conversation ONE User HAS MANY Conversation Member HAS ONE Conversation */ CREATE TABLE IF NOT EXISTS `tbl

How can I update Yii's CListView when a new record was added triggered by an AJAX call?

和自甴很熟 提交于 2020-01-05 07:38:29
问题 Yesterday I was introduced to the CListView and could manage to display all the information i want about my records, and in the format i want. I have a 'create' button (add a new contact), which opens a modal pop up window with the corresponding fields. When this window is closed, i return to the CListView, and here is my issue: i've been trying to update the CListView (without any luck, clearly). I believe it should be easy to update the clistview with this call: $.fn.yiiListView.update('

Controller can't find the view in Yii

拈花ヽ惹草 提交于 2020-01-05 07:33:31
问题 I want a view from another module to be rendered and I use path '//modulename/foldername/viewname' (without .php ), but when I run it I get "Controller can't find the view" error. What do I do wrong? It used to work before. My version of Yii is 1.1.15. EDIT: These is my urlManager: 'urlManager' => array( 'class' => 'yupe\components\urlManager\LangUrlManager', 'languageInPath' => true, 'langParam' => 'language', 'urlFormat' => 'path', 'showScriptName' => false, 'cacheID' => 'cache', 'rules' =>

Yii find query result - without table structure

我是研究僧i 提交于 2020-01-05 07:03:47
问题 I'm using the below query for to models $criteria = new CDbCriteria; $criteria->condition='brand_id=3'; $model=Models::model()->find($criteria); it gives result with Table structure and relational table structure like below Models Object ( [_md:CActiveRecord:private] => CActiveRecordMetaData Object ( [tableSchema] => CMysqlTableSchema Object ( [schemaName] => [name] => models [rawName] => `models` [primaryKey] => model_id [sequenceName] => [foreignKeys] => Array ( [brand_id] => Array ( [0] =>

Saving data in the database in yii2 during file upload action

女生的网名这么多〃 提交于 2020-01-05 05:08:12
问题 I have a upload controller where by am also performing saving other data to the database. The file uploading to the folder is okay but saving the other details in the table doesn't happen controller code $images = $_FILES['evidence']; $success = null; $paths= ['uploads']; // get file names $filenames = $images['name']; // loop and process files for($i=0; $i < count($filenames); $i++){ //$ext = explode('.', basename($filenames[$i])); $target = "uploads/cases/evidence".DIRECTORY_SEPARATOR . md5

yii begginer

人走茶凉 提交于 2020-01-05 04:51:32
不错的YII学习博客 http://blog.csdn.net/guanhui077/article/details/8708886(http://blog.csdn.net/guanhui077/article/details/8708886) http://blog.csdn.net/aszt123/article/category/1608495/2 http://www.imobilebbs.com/wordpress/archives/3865 http://blog.csdn.net/mengxiangbaidu/article/category/690447 YII Beginner http://www.yiiframework.com/wiki/250/yii-for-beginners/ http://www.yiiframework.com/doc/blog/1.1/zh_cn/start.testdrive http://www.yiiframework.com/doc/blog/1.1/zh_cn/start.overview YII 安装 link OOP学习 http://net.tutsplus.com/tutorials/php/object-oriented-php-for-beginners/ http://dl.dbank.com

实用Yii扩展

拈花ヽ惹草 提交于 2020-01-05 04:43:36
可以去官方搜索Yii扩展:Extensions | Yii PHP Framework http://www.yiiframework.com/extensions/?tag=tree Yii checkbox in dropdown http://stackoverflow.com/questions/11608318/yii-checkbox-in-dropdown yii_extension_CGridView相关第三方扩展汇总 http://blog.csdn.net/phpgcs/article/details/11928543 Extensions http://www.yiiframework.com/extensions/?tag=input&sort=update.desc jQuery File Upload Demo xupload ,带上传图片预览功能 http://www.yiiframework.com/extension/xupload#hh0 来源: https://www.cnblogs.com/imxiu/p/3491354.html

DELETE verb is not working in Yii Rest Api?

丶灬走出姿态 提交于 2020-01-05 04:40:39
问题 When try to delete a record using Yii Rest api HTTP DELETE mothod is not working my url routing is array('users/list', 'pattern'=>'users/<model:\w+>/<id:\d+>', 'verb'=>'DELETE'), when i request like http://localhost/api/users/delete?id=1 in method DELETE in rest client it says there is no method like delete so i created an action like the following public function actionDelete() { switch($_GET['action']) { case 'delete': // {{{ $id = $_GET['id']; $this->DeleteUser($id); break; // }}} default:

How to format date in listing page

白昼怎懂夜的黑 提交于 2020-01-05 04:14:07
问题 I am new to Yii framework and just started to work on an existing website. I have a listing page and my requirement was to add a new field 'review_date_time' and I could managed to display it in listing. Now my question is how to change the format of the date and how to show a white space if date is not there in table field.Right now it is displaying 0000-00-00 00:00:00 if no date is there. My code for listing $this->widget('zii.widgets.grid.CGridView', array( 'id' => 'series-grid',