Yii

Yii Framework : Join table (or other SQL) in data provider?

谁说胖子不能爱 提交于 2020-01-25 18:41:50
问题 Background I have used Gii Crud Generator with my "Category" model, and I want to modify the admin form. I look inside "protected/views/Category/admin.php, I found the table is render by a widget('zii.widgets.grid.CGridView'), and it using a data Provider for it's data. I suppose I can find some where to input the SQL query in the data Provider, but I don't understand about how's it works. these is the code In the Model->relations(), but I don't know what to do next. public function relations

Yii Framework : Join table (or other SQL) in data provider?

折月煮酒 提交于 2020-01-25 18:41:12
问题 Background I have used Gii Crud Generator with my "Category" model, and I want to modify the admin form. I look inside "protected/views/Category/admin.php, I found the table is render by a widget('zii.widgets.grid.CGridView'), and it using a data Provider for it's data. I suppose I can find some where to input the SQL query in the data Provider, but I don't understand about how's it works. these is the code In the Model->relations(), but I don't know what to do next. public function relations

CDbCriteria condition from another CDbCriteria

你离开我真会死。 提交于 2020-01-25 06:44:10
问题 I don't if that I want to do is possible or not, I have two models i want to get data from one model using a condition from another. $criteria1=new CDbCriteria; $paramIds = $s['param_id']; $stress = model1::model()->find($criteria1); $mycondition= ($stress->stress_value); echo $mycondition ; // I get this value and I want to use it as // condition for the next cdbcreteria $criteria2=new CDbCriteria; // condition $criteria2->addcondition(array('pressure_value' > $mycondition)); // I can't

PHPUnit autoloading classes

本秂侑毒 提交于 2020-01-25 01:07:28
问题 Question in short How can I make the Autoloader find all classes required to run my PHP tests? Question in detail I want to autoload the classes that I am using in PHPUnit in Eclipse. My directory structure is as follows. Project (called yii-app) protected dirA classA.php dirB classB.php yii-1.1.14.f0fee9 Yii.php tests ClassATest.php ClassBTest.php bootstrap.php Autoloader.php I use the bootstrap.php and Autoloader.php that I found here, see below for details. The Class classA does not make

Where should I place my app's yiic file to execute console commands?

时光总嘲笑我的痴心妄想 提交于 2020-01-25 00:15:53
问题 When you generate Yii 1.x auto-generated application, app's private yiic is placed in protected folder. However, when I use it to execute yiic help shell , I see following message: It is recommended that you execute this command under the directory that contains the entry script file of the Web application. And then: * entry-script | config-file: optional, the path to the entry script file or the configuration file for the Web application. If not given, it is assumed to be the 'index.php'

Yii CDbConnection failed to open the DB connection: could not find driver with google cloud sql

痴心易碎 提交于 2020-01-24 22:05:33
问题 I'm having an issue with Yii and a mysql database running on Google Cloud sql. Quick overview: We have moved this from an existing server where it all worked with no issues at all and have now set up a Google Compute Engine server with php and all the relivant drivers mysql_pdo being one of them. We also have a Google Cloud SQL database storing all of our existing database information. What I have tried I have written a simple php script which uses PDO('mysql:<IPADDRESS>;dbname=<MYDBNAME>,

Yii CDbConnection failed to open the DB connection: could not find driver with google cloud sql

送分小仙女□ 提交于 2020-01-24 22:05:05
问题 I'm having an issue with Yii and a mysql database running on Google Cloud sql. Quick overview: We have moved this from an existing server where it all worked with no issues at all and have now set up a Google Compute Engine server with php and all the relivant drivers mysql_pdo being one of them. We also have a Google Cloud SQL database storing all of our existing database information. What I have tried I have written a simple php script which uses PDO('mysql:<IPADDRESS>;dbname=<MYDBNAME>,

Yii Query Builder multiple where clauses

对着背影说爱祢 提交于 2020-01-24 20:17:06
问题 I noticed in my stack that my query wasn't being executed correctly as I had multiple where clauses in my querybuilder. So I looked at this post Multiple call where in Yii Query builder Applied what i'd read, but still the query doesn't combine the where statements. What am I doing wrong? $command = Yii::app()->db->createCommand() .... ->where(array('in', 'u.id', $licenses), array('and', 'i.date_added > DATE_SUB(u.date_expired, INTERVAL 30 DAY)')); //->where(array('and', 'i.date_added > DATE

Yii CGridView hyperlink open in new tab

假如想象 提交于 2020-01-24 17:07:05
问题 I have made one column of my yii CGridview as a hyperlink. But on clicking it, it opens link address within the same tab. How can I open the link address in a new tab ? array( 'header'=>'Name', 'name' => 'name', 'value' => 'CHtml::link($data->name, $data->site_url)', 'type' => 'raw', ), 回答1: Set the target attribute as _blank for the link ( <a> ) that will be generated: <a href="some_url" target="_blank">Foo</a> With CHtml::link : 'value' => 'CHtml::link($data->name, $data->site_url, array(

how to change csrf field id from YII_CSRF_TOKEN to any other

别等时光非礼了梦想. 提交于 2020-01-24 10:30:55
问题 i am using Get method for form post but i am not interested if person could see if i am using yii framework. So instead of using YII_CSRF_TOKEN i need to make my own defined id name e.g. like only TOKEN. I don't want to reveal what framework i am using , any kind of tip or help ??? 回答1: in your application config add the below code 'request'=>array( 'csrfTokenName'=>'YOUR_TOKEN_NAME_HERE', ), 来源: https://stackoverflow.com/questions/11809448/how-to-change-csrf-field-id-from-yii-csrf-token-to