Yii

Foreach through a large table using Yii ActiveRecord - “out of memory” errors

纵饮孤独 提交于 2020-01-05 04:00:51
问题 I have a website on Yii Framework and I want to search a table for matching words. I keep getting "out of memory" (it is a large table). I try this code but it keeps loading the page $dataProvider = new CActiveDataProvider('Data'); $iterator = new CDataProviderIterator($dataProvider); foreach($iterator as $data) { echo $data->name."\n"; } So I try this code but it keeps limiting the result to 10: $dataProvider = new CActiveDataProvider('Data'); $iterator = new CDataProviderIterator(

PHP MySQL Yii - database reading not writing

跟風遠走 提交于 2020-01-05 03:28:41
问题 I have a working Yii app on my local lamp stack. Now when I put the app on a lamp server the app reads the db and runs, but the app isn't successfully writing to the db. I'm getting no errors logs. Any thoughts? Here's how I'm updating the db: public function actionIndex() { if ($_GET["yep"] == "") { pd_error("You are not logged in!"); } list($uid, $domain) = preg_split("/@/",$_GET["yep"],2); $model=$this->loadModel($uid); $this->redirect($model->URL."?".$model->Unique_ID); } public function

Yii Remember me functionality?

痴心易碎 提交于 2020-01-05 02:52:11
问题 Hi i am new in yii and below is my UserIdentiy function Please let me know how can i add the remember me functionality public function authenticate() { $users = array(); if ($this->usertype == "registration") { $users = Login::model()->findByAttributes(array('email' => $this->username)); $users = $users->attributes; } if (empty($users)) $this->errorCode = self::ERROR_USERNAME_INVALID; elseif (!empty($users['password']) && $users['password'] !== md5($this->password)) $this->errorCode = self:

How to create friendly links in Yii project using Yiinitializr

纵然是瞬间 提交于 2020-01-05 02:30:14
问题 I try to use Yiinitializr site structure for my Yii project. The structure looks like this: root --backend ----standart yii folders ----... ----www ------index.php (admin.mysite.com) --common ----common folders for backend and frontend ----... --backend ----standart yii folders ----... ----www ------index.php (mysite.com) Blank Yiinitializr strucure see on github The question is how to make working URLs like this: admin.mysite.com/invites - in backend and mysite.com/users - in frontend

Insert records into two table at once

﹥>﹥吖頭↗ 提交于 2020-01-05 01:51:10
问题 In my web page, there is a CSV import section. Users may import several thousands of records. I need to insert the csv details into the 2 tables. The first table contains the basic information. And the second one contains the other additional information. So that i need to save the first table's Inserted ID into the second table. For the above requirement, i wrote the 2 mysql statement. But it took more time to import. Here, is it possible to insert records into 2 table using single query?

Using STAT relation in CActiveDataProvider criteria

帅比萌擦擦* 提交于 2020-01-04 23:27:01
问题 This is my controller action public function actionIndex() { //Supervisor non possono vedere brani OPEN //Gerard (manager) non puo' vedere OPEN/REJECTED/PROPOSED/CLOSED //Editor non puo' vedere APERTO/PROPOSTO/REJECTED se non suo $with = array( 'propostoCount', 'pubblicatoCount', 'pendingCount', 'apertoCount', 'rifiutatoCount', 'chiusiCount', ); $condition = 'propostoCount=1 AND pubblicatoCount=1 AND pendingCount=1 AND rifiutatoCount=1 AND chiusiCount>0'; $dataProvider=new CActiveDataProvider

Using STAT relation in CActiveDataProvider criteria

末鹿安然 提交于 2020-01-04 23:24:22
问题 This is my controller action public function actionIndex() { //Supervisor non possono vedere brani OPEN //Gerard (manager) non puo' vedere OPEN/REJECTED/PROPOSED/CLOSED //Editor non puo' vedere APERTO/PROPOSTO/REJECTED se non suo $with = array( 'propostoCount', 'pubblicatoCount', 'pendingCount', 'apertoCount', 'rifiutatoCount', 'chiusiCount', ); $condition = 'propostoCount=1 AND pubblicatoCount=1 AND pendingCount=1 AND rifiutatoCount=1 AND chiusiCount>0'; $dataProvider=new CActiveDataProvider

Adding a css class to specific items of Yii active checkBoxList

对着背影说爱祢 提交于 2020-01-04 10:09:26
问题 Working with Yii and active checkboxlist. I know the params. I need to add a flag css class to the items. This is my code: $form->checkBoxList($model, 'items', $selected, array( 'class'=>'default_class' )); This code just adds a default_class to every item. But I need a different class for specific items. 回答1: @XIII, I had updated my answer $form->checkBoxList($model, 'items', $selected, array( 'options' => array( 'value1'=>array('disabled'=>true, 'label'=>'value 1'), 'value2'=>array('label'=

How can I access a model's data inside a new view file?

大城市里の小女人 提交于 2020-01-04 05:23:06
问题 I want to access all the data of a model in one of its views, which I made and called searching.php . I wrote an action in the business controller which is like this: public function actionSearching() { // using the default layout 'protected/views/layouts/main.php' $this->layout='//layouts/main'; $this->render('searching'); } In the view of business/searching I want to access all the data of a model (Business). This includes business_name, business_description etc. But when I run this code I

Yii validation rule - unique

巧了我就是萌 提交于 2020-01-04 03:57:22
问题 in Yii framework, can I use unique validation rule to check uniqueness of an field within some condition (I know there is criteria, but this condition is a bit tricky)? Ie, i want to check num_days unique by property_id. table: NUM PROP_ID 3 4 3 5 validation should pass in case i try insert 3, 6, but fail in case of 3, 4 回答1: Check out UniqueAttributesValidator, and also this answer. In the links you'll see that they have used $this->attributename for the params array of the criteria option