Yii

how to show new added columns in database in yii framework?

前提是你 提交于 2019-12-24 05:43:13
问题 i added two new columns in my db table, and then i defined these new columns in the table model itself, and then, when i called $model->getAttributes() the two new columns didn't appear in the array output of $model->getAttributes() method call there's no schema caching set in my configs, any idea how to solve this?, and how am I gonna get the value of the input forms of the new added columns from the front-end if i have a problem in showing off the two newly added columns ? e.g new columns

Alter table or reset auto-increment using CDbMigration

非 Y 不嫁゛ 提交于 2019-12-24 05:21:50
问题 How can I alter table or reset the auto-increment of a field in Yii 1.x, using CDbMigration? I found alterColumn method, as good as createTable, dropTable, renameTable and truncateTable methods, but either I'm blind or there isn't anything for altering table or resetting the auto-increment of particular column or field. 回答1: You can use execute() as Yii defines it: Executes a SQL statement. This method executes the specified SQL statement using dbConnection. So, $this->execute("ALTER TABLE

Alter table or reset auto-increment using CDbMigration

柔情痞子 提交于 2019-12-24 05:21:27
问题 How can I alter table or reset the auto-increment of a field in Yii 1.x, using CDbMigration? I found alterColumn method, as good as createTable, dropTable, renameTable and truncateTable methods, but either I'm blind or there isn't anything for altering table or resetting the auto-increment of particular column or field. 回答1: You can use execute() as Yii defines it: Executes a SQL statement. This method executes the specified SQL statement using dbConnection. So, $this->execute("ALTER TABLE

CGridview custom field sortable

此生再无相见时 提交于 2019-12-24 03:51:40
问题 I had created with custom field in yii Cgridview but how to make that sortable. The custom field value is from a function in the model. I want to make this field sortable? Can someone help me? 回答1: In the search function of your model, where customField is the name of your field: // ...other criteria... $criteria->compare('customField',$this->customField); $sort = new CSort(); $sort->attributes = array( 'customField'=>array( 'asc'=>'customField ASC', 'desc'=>'customField DESC', ), '*', //

using yii with memcache, error when one of two server fails

强颜欢笑 提交于 2019-12-24 03:08:07
问题 i have a problem with yii and storing data in memcache. For my application i use system.caching.CMemCache and the following config: 'servers' => array( 'server1' => array('host' => 'localhost', 'port' => 11211, 'weight' => 50), 'server2' => array('host' => '192.168.0.2', 'port' => 11211, 'weight' => 50) ), if memcache on both systems is running, everything is ok and the values get spread up on the servers. but if one server fails (or if i stop the memcache manually) the application throw

Multiple GET-variables in yii path url

↘锁芯ラ 提交于 2019-12-24 03:05:47
问题 I have a problem with my Yii urlManager. I'm using the path format and want to pass multiple get variables. The url looks like that: /Yii/app/de/user/admin/id/5/test/hello my .htaccess: Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteBase /Yii/app/ RewriteRule ^(.*)$ index.php?/$1 [QSA,L] I tried with the urlManager, but it doesn't work with following rules: 'rules' => array( '<language:\w+>/<controller:\w+>/<id:\d+>'=>'<controller>/view', '<language:\w+>/

Yii - Make a string usable in a URL or filename

情到浓时终转凉″ 提交于 2019-12-24 02:56:05
问题 Does the Yii framework contain a function that can make a string usable in a URL or filename ? For example: Health+%26+Safety+franchises = health-safety-franchises So something similar to: https://docs.djangoproject.com/en/dev/ref/templates/builtins/#slugify 回答1: slugify in Django Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens. Also strips leading and trailing whitespace. Following are the functions in PHP to carry out same

yii2 下的redis常用命令集合

浪子不回头ぞ 提交于 2019-12-24 02:47:25
<?php \Yii:: $app ->redis->set( 'user' , 'aaa' ); \Yii:: $app ->redis->set( 'user2' , 'bbb' ); \Yii:: $app ->redis->set( 'user3' , 'ccc' ); \Yii:: $app ->redis->set( 'user4' , 'ddd' ); \Yii:: $app ->\Yii-> $app ->redis->expire( 'sms:send:' . $mobile ,60); // 设置过期时间 \Yii:: $app ->redis->setex( '13800000000' , 30, 'value' ); //设置一个带有效期(秒)的数据 \Yii:: $app ->redis->get( 'user' ); //此时可以输出aaa \Yii:: $app ->redis->flushall(); //删除redis中的所有数据 $source = Yii:: $app ->redis->del( 'var1' ); //删除某个键值 /*-一个键值数据存入redis-*/ \Yii:: $app ->redis->hmset( '13800000000' , 'name' , 'sky' , 'age' , 18); /*-设置一个带有效期(秒

Yii generate a model file using php code instead of gii tool

牧云@^-^@ 提交于 2019-12-24 02:44:08
问题 I'm having real problems with the following topic: I'm creating a social network using Yii framework and for each user I'm generating a bunch of DB tables that start with the user id, so a DB table looks like: 13_my_firends. The point is that by doing this, I cannot generate a certain model using the gii tool, and I really need some models for this tables to make some relations to avoid inner joins, so I guess the problem is like this: -> How can I create a model file using php or Yii code

Yii generate a model file using php code instead of gii tool

梦想的初衷 提交于 2019-12-24 02:44:03
问题 I'm having real problems with the following topic: I'm creating a social network using Yii framework and for each user I'm generating a bunch of DB tables that start with the user id, so a DB table looks like: 13_my_firends. The point is that by doing this, I cannot generate a certain model using the gii tool, and I really need some models for this tables to make some relations to avoid inner joins, so I guess the problem is like this: -> How can I create a model file using php or Yii code