Yii

How do I insert a mysql spatial point with a yii model?

梦想的初衷 提交于 2019-12-21 20:44:30
问题 I have a model type that was generated from a mysql table that has address data and also a spatial POINT field named "coordinates". When a model is created or updated I want to geocode the address and store the latitude and longitude coordinates in the POINT field. My understanding is the way to do this is to geocode the address in the model's beforeSave method. I have done this and have the coordinates in an associative array. Now my question is how can I insert this data into my coordinates

How do i add scripts and stylesheets inside yii module

不羁岁月 提交于 2019-12-21 20:36:09
问题 i am new to yii. I just created a module in yii the file structure is as follows -yii -protected -modules -admin -controller -model -view -layout -main.php -css -style.css -images -logo.jpg i was able to set the layout to like this 'modules'=>array( // uncomment the following to enable the Gii tool 'admin'=>array( 'layoutPath' => 'protected/modules/admin/views/layouts', ; ) and now the layout is rendered from the admin module the problem is that i cant load the stylesheets using <link rel=

How to display action button as dropdown in Yii2 gridview?

笑着哭i 提交于 2019-12-21 20:33:44
问题 I would like to display action button as dropdown in Yii 2 gridview. How can I achieve that without using any extension? I have added the source code bellow- <?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'id', 'name', ['class' => 'yii\grid\ActionColumn', 'template'=>'{view}{update}{delete}', 'buttons' => [ 'view' => function ($url, $model) { return Html::a('<span class="glyphicon glyphicon-eye-open">

How to get all table and column names from database in Yii Framework

我是研究僧i 提交于 2019-12-21 19:29:12
问题 I am working on a module where I want to do dynamic dependent dropdown table and column name functionality. Ex. Fetch all table names and display it in dropdown fields and after selection of particular table I want to display its all column name again in dropdown field. The issues are: 1) How to fetch all table name from db? 2) and how to fetch all column name from table? I tried few articles and forums like http://www.yiiframework.com/forum/index.php/topic/5920-how-can-i-get-the-actual-full

Installing Yii 2 demo application

和自甴很熟 提交于 2019-12-21 15:20:51
问题 i am trying to install yii 2 and to run the basic or advanced application. i have tried the steps given here Setting up preview of Yii2 to do this. the steps i followed, 1 - Installed the composer 2 - Use composer to install the app alongwith dependencies(Yii): php path/to/composer.phar create-project --stability=dev yiisoft/yii2-app-basic my_yii2_trial 3 - Access app from http://localhost/my_yii2_trial/web The problem is, i am getting this syntax error. Parse error: syntax error, unexpected

How to convert to use the Yii CDataProvider on view?

Deadly 提交于 2019-12-21 12:43:49
问题 I am trying to learn Yii, and have looked at Yii documentation, but still do not really get it. I still have no idea how to use the CDataProvider on the Controller and View to display all the blog posts available on the view. Can anyone please advise or give an example based on the following: The actionIndex in my PostController: public function actionIndex() { $posts = Post::model()->findAll(); $this->render('index', array('posts' => $posts)); )); The View, Index.php: <div> <?php foreach (

Yii2 pretty URL: automatically convert everything with slashes (including all parameters)

寵の児 提交于 2019-12-21 12:14:08
问题 I'm working with Yii2 and I would like to use urlManager with routing to convert all non-letter and non-number characters into slashes. I have looked at a lot of question what have already been asked (#1, #2, #3, #4) but none solved it since they either show a little similar but not what I want or not working for me at all. I have simple urlManager rules: //... 'urlManager' => [ 'class' => 'yii\web\UrlManager', 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => array( '

Change order of registered script files in yii

别来无恙 提交于 2019-12-21 12:13:03
问题 I'm making a widget for a Yii application. The main layout view registers all the common script files such as jQuery and jQueryUI. In my widget I want to use a jQueryUI plugin that relies on jQueryUI already being loaded. I know I can specify where on the page the script is included, but it seems a bit hit and miss to simply include it at the "end" - what if I have other script that I need to load after that plugin? How do I ensure they're loaded in the right order - anyone got any ideas? 回答1

Yii addInCondition with floats: How to ? and why addInCondition('column', array(1.1, 1.3)) don't work?

有些话、适合烂在心里 提交于 2019-12-21 08:59:37
问题 How to addInCondition with floats? I tried a lot. This works ok: $criteria=new CDbCriteria(); $criteria->addInCondition('order_id',array(36907)); $tasks=OrderTask::model()->findAll($criteria); In my case it returns 4 models: But if I try $criteria=new CDbCriteria(); $criteria->addInCondition('order_id',array(36907)); $criteria->addInCondition('step',array(3.20)); $tasks=OrderTask::model()->findAll($criteria); Or $criteria=new CDbCriteria(); $criteria->addInCondition('step',array("3.20"));

Yii Framework 2.0 Rules Date Validator

半城伤御伤魂 提交于 2019-12-21 07:15:07
问题 I am using Yii Framework 2.0. I have a form with a text input field which is meant for a date. I have read the Yii Framework 2.0 about the Class yii\validators\Validator and known all the validator keys which can be used inside of the rules() method in a model class. When I use the date key as below, it does not validate anything. It means that I still can put some text in that input field and can post the form. When I changed it into boolean or email , I could see that it validates very well