Search Results

Search found 119 results on 5 pages for 'yii'.

Page 3/5 | < Previous Page | 1 2 3 4 5  | Next Page >

  • Problem in Saving Multi Level Models in YII

    - by Waqar
    My Table structure for user and his adress detail is as follows CREATE TABLE tbl_users ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, loginname varchar(128) NOT NULL, enabled enum("True","False"), approved enum("True","False"), password varchar(128) NOT NULL, email varchar(128) NOT NULL, role_id int(20) NOT NULL DEFAULT '2', name varchar(70) NOT NULL, co_type enum("S/O","D/O","W/O") DEFAULT "S/O", co_name varchar(70), gender enum("MALE","FEMALE","OTHER") DEFAULT "MALE", dob date DEFAULT NULL, maritalstatus enum("SINGLE","MARRIED","DIVORCED","WIDOWER") DEFAULT "MARRIED", occupation varchar(100) DEFAULT NULL, occupationtype_id int(20) DEFAULT NULL, occupationindustry_id int(20) DEFAULT NULL, contact_id bigint(20) unsigned DEFAULT NULL, signupreason varchar(500), PRIMARY KEY (id), UNIQUE KEY loginname (loginname), UNIQUE KEY email (email), FOREIGN KEY (role_id) REFERENCES tbl_roles (id), FOREIGN KEY (occupationtype_id) REFERENCES tbl_occupationtypes (id), FOREIGN KEY (occupationindustry_id) REFERENCES tbl_occupationindustries (id), FOREIGN KEY (contact_id) REFERENCES tbl_contacts (id) ) ENGINE=InnoDB; CREATE TABLE tbl_contacts ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, contact_type enum("cres","pres","coff"), address varchar(300) DEFAULT NULL, landmark varchar(100) DEFAULT NULL, district_id int(11) DEFAULT NULL, city_id int(20) DEFAULT NULL, state_id int(20) DEFAULT NULL, pin_id bigint(20) unsigned DEFAULT NULL, area_id bigint(20) unsigned DEFAULT NULL, po_id bigint(20) unsigned DEFAULT NULL, phone1 varchar(20) DEFAULT NULL, phone2 varchar(20) DEFAULT NULL, mobile1 varchar(20) DEFAULT NULL, mobile2 varchar(20) DEFAULT NULL, PRIMARY KEY (id), FOREIGN KEY (district_id) REFERENCES tbl_districts (id), FOREIGN KEY (city_id) REFERENCES tbl_cities (id), FOREIGN KEY (state_id) REFERENCES tbl_states (id) ) ENGINE=InnoDB; CREATE TABLE tbl_states ( id int(20) NOT NULL AUTO_INCREMENT, name varchar(70) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB; CREATE TABLE tbl_districts ( id int(20) NOT NULL AUTO_INCREMENT, name varchar(70) DEFAULT NULL, state_id int(20) DEFAULT NULL, PRIMARY KEY (id), FOREIGN KEY (state_id) REFERENCES tbl_states (id) ) ENGINE=InnoDB; CREATE TABLE tbl_cities ( id int(20) NOT NULL AUTO_INCREMENT, name varchar(70) DEFAULT NULL, district_id int(20) DEFAULT NULL, state_id int(20) DEFAULT NULL, PRIMARY KEY (id), FOREIGN KEY (district_id) REFERENCES tbl_districts (id), FOREIGN KEY (state_id) REFERENCES tbl_states (id) ) ENGINE=InnoDB; The relationship is as follows User has multiple contacts i.e Permanent Address, Current Address, Office Address. Each Contact has state and City. User-Contact-state like this How to save models of this structure in one go. Please provide a reply ASAP

    Read the article

  • Yii CGridView and dropdown filter

    - by Dmitriy Gunchenko
    I created dropdown filter, it's display, but don't worked right. As I anderstand trouble in search() method view: $this->widget('zii.widgets.grid.CGridView', array( 'dataProvider'=>$model->search(), 'filter' => $model, 'columns'=>array( array( 'name' => 'client_id', 'filter' => CHtml::listData(Client::model()->findAll(), 'client_id', 'name'), 'value'=>'$data->client->name' ), 'task' ) )); I have to tables, and they relations are shown down model: public function relations() { // NOTE: you may need to adjust the relation name and the related // class name for the relations automatically generated below. return array( 'client' => array(self::BELONGS_TO, 'Client', 'client_id'), ); } public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria=new CDbCriteria; $criteria->with = array('client'); $criteria->compare('task_id',$this->task_id); $criteria->compare('client_id',$this->client_id); $criteria->compare('name',$this->client->name); $criteria->compare('task',$this->task,true); $criteria->compare('start_date',$this->start_date,true); $criteria->compare('end_date',$this->end_date,true); $criteria->compare('complete',$this->complete); return new CActiveDataProvider($this, array( 'criteria'=>$criteria, )); }

    Read the article

  • Filter Date using Date Picker in Yii

    - by era
    I have generated my crud screens using gii.. I have a search form, where i have put a date picker, where i give the user to select the date he wants. But the problem is that i have the date stored in seconds in the database. and i know that i can convert the date using strtotime. But then how do i filter using the search method in my model? this is my date picker <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array( 'name'=>'ordering_date', 'id'=>'ordering_date', // additional javascript options for the date picker plugin 'options'=>array( 'showAnim'=>'fold', ), 'htmlOptions'=>array( 'style'=>'height:20px;' ), )); ?> and this is my search method in my model. I want to compare the ordering_date public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched. //echo $this->ordering_date; $criteria=new CDbCriteria; $criteria->compare('order_id',$this->order_id); $criteria->compare('customer_id',$this->customer_id); $criteria->compare('delivery_address_id',$this->delivery_address_id); $criteria->compare('billing_address_id',$this->billing_address_id); $criteria->compare('ordering_date',$this->ordering_date); $criteria->compare('ordering_done',$this->ordering_done,true); $criteria->compare('ordering_confirmed',$this->ordering_confirmed); $criteria->compare('payment_method',$this->payment_method); $criteria->compare('shipping_method',$this->shipping_method); $criteria->compare('comment',$this->comment,true); $criteria->compare('status',$this->status,true); $criteria->compare('total_price',$this->total_price); return new CActiveDataProvider($this, array( 'criteria'=>$criteria, )); }

    Read the article

  • Yii Many_Many Relationship and Form

    - by Thorpe Obazee
    // Post model return array( 'categories' => array(self::HAS_MANY, 'Category', 'posts_categories(post_id, category_id)') ); I already have the setup of tables posts id, title, content categories id, name posts_categories post_id, category_i The problem I have is that I am getting an error when creating this form: <?php $form=$this->beginWidget('CActiveForm', array( 'id'=>'post-form', 'enableAjaxValidation'=>false, )); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <div class="row"> <?php echo $form->labelEx($model,'title'); ?> <?php echo $form->textField($model,'title',array('size'=>60,'maxlength'=>255)); ?> <?php echo $form->error($model,'title'); ?> </div> <div class="row"> <?php echo $form->labelEx($model,'uri'); ?> <?php echo $form->textField($model,'uri',array('size'=>60,'maxlength'=>255)); ?> <?php echo $form->error($model,'uri'); ?> </div> <div class="row"> <?php echo $form->labelEx($model,'content'); ?> <?php echo $form->textArea($model,'content',array('rows'=>6, 'cols'=>50)); ?> <?php echo $form->error($model,'content'); ?> </div> <div class="row"> <?php // echo $form->labelEx($model,'content'); ?> <?php echo CHtml::activeDropDownList($model,'category_id', CHtml::listData(Category::model()->findAll(), 'id', 'name')); ?> <?php // echo $form->error($model,'content'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?> </div> <?php $this->endWidget(); ?> The error is: Property "Post.category_id" is not defined. I am quite confused. What should I be doing to correct this?

    Read the article

  • Yii 'limit' on related model's scope

    - by pethee
    I have a model called Guesses that has_many Comments. I'm making eager queries to this to then pass on as JSON as response to an API call. The relations are obviously set between the two models and they are correct(one2many <= belongs2) I added a scope to Comments called 'api' like this: public function scopes() { return array( 'api' => array( 'select' => 'id, comment, date', 'limit'=>3, 'order'=>'date DESC', 'together'=>true, ), ); } And I'm running the following one-liner query: $data = Guesses::model()->with('comments:api')->findAll(); The issue here is that when calling the 'api' scope using a with('relation'), the limit property simply doesn't apply. I added the 'together'=true there for another type of scope, plus I hear it might help. It doesn't make a difference. I don't need all the comments of all Guesses. I want the top 3 (or 5). I am also trying to keep the one-liner call intact and simple, manage everything through scopes, relations and parameterized functions so that the API call itself is clean and simple. Any advice?

    Read the article

  • PHP Frameworks: Codeigniter vs. Yii vs. Custom?

    - by Industrial
    Hi everybody, I have used codeigniter for a some years now. Why I chosed to work with codeigniter back then? Pretty much for the extensive documentation that were available and the big user community. It made me as a totally newbie to the MVC pattern able to get a site up and running really fast. I think what is priorited from my side is that the framework doesn't affect performance too much, which Codeigniter seems to be pretty good at (when compared to other frameworks out there) and Yii, an even better option. Since the time has gone from when I started out with codeigniter, the project sizes have also increased and thereby the demand of the framework and it's footprint on the code. I have thought a few times about writing a whole new MVC framework to do only the thing's I want it to do, but it feels like reinventing the wheel and I cannot yet justify it. I am not sure whether or not it's a good solution to build a site that have the potential to become really big on either Yii or Codeigniter. I have tried to find as much as possible documentation about this comparision/issue online before posting here, but have found very few real-life arguments and stories from people that have shifted between the two PHP frameworks or have been in the same situation as me. So - what's your thoughts about Codeigniter vs. Yii vs. going custom? References: http://daniel.carrera.bz/2009/01/comparison-of-php-frameworks-part-i/ http://www.beyondcoding.com/2009/03/02/choosing-a-php-framework-round-2-yii-vs-kohana-vs-codeigniter/

    Read the article

  • Am I making the right choice in choosing Yii as my PHP Framework?

    - by Bara
    I am about to begin development of a new website and have been doing research on PHP Frameworks. I'm not an advanced PHP developer, but I have been developing web sites and apps (in asp.net) for a few years now. My website will primarily be AJAX-based (using jQuery) and making lots of calls to web services. After some research, here's what I came up with: CakePHP: Originally started developing in this, but found it too complex. The fact that it forces you to use and learn all this new stuff just to use it was a bit daunting, so I put it aside for the time being. Zend: The performance of the framework leaves me a bit skeptical, but I heard it has great support for creating web services. I also heard it was a bit complex. CodeIgniter: No real reason for not using this one. Based on what I've read CodeIgniter and Yii are very similar, but Yii is a bit faster and doesn't have un-needed code for PHP4 (since I plan on developing exclusively in PHP5). As far as Yii, the only things that scare me about it are that it is newer than the other frameworks so it has a smaller community. It also doesn't seem to have a ton of web service support (only SOAP, from my understanding) as opposed to Zend. So my questions come down to: Should these things worry me? (not as big of a community, poor web service support) Is there anything else I should look into? Is my choice of Yii over the other frameworks ok for a primarily AJAX-based web app? Bara

    Read the article

  • Referencing a module component class in GridView

    - by keeg
    I'm loading bootstrap into a module: 'modules'=>array( 'admin'=>array( 'preload'=>array('bootstrap'), 'components'=>array( 'bootstrap'=>array( 'class'=>'ext.bootstrap.components.Bootstrap', 'responsiveCss' => true, ), ) ), ), in a GridView I'm trying to create a TbButtonColumn: array( 'class'=>'bootstrap.widgets.TbButtonColumn', 'htmlOptions'=>array('style'=>'width: 50px'), ), This returns a CException Property "CWebApplication.bootstrap" is not defined. as it points to a bootstrap in the main config app which obviously doesn't exist, how do I reference bootstrap when it is loaded in the module? I tried: components.bootstrap.widgets.TbButtonColumn admin.components.bootstrap.widgets.TbButtonColumn admin.bootstrap.widgets.TbButtonColumn

    Read the article

  • Update CGridView when a dropdown value changes

    - by Gautam Borad
    I have a CGridView with columns from a table "product" => {'product_id','category_id',...} I have another table "category" => {'category_id','category_name'} category_id is the FK in the product table. Now i want a dropdown list of the category table and on selecting a particular value the CGridView of product should be updated to show only the rows with that category_id. I also need the column filtering/sorting for the CGridView to work (using AJAX). I was able to refresh the CGridView when a value is selected from the dropdown, however i am not able to send the category_id with the 'data' for the CGridView: clientScript-registerScript('search', " $('.cat_dropdown').change(function(){ $.fn.yiiGridView.update('order-grid', { data: $(this).serialize(), }); return false; }); "); The data: $(this).serialize() sends only the values that are present in the filtering text fields of the CGridView. How do i append the category_id with it? If the above method is not the right one, please suggest an alternative method.

    Read the article

  • How to add Ajax validation in a master where I have fields for other tables based on jqrelcopy?

    - by AravindRaj
    In a master page(_form) I want to save three fields drop down text box Option list and if a certain option from the option list is selected I need a JQrelcopy to appear and the user can add many values using JQrelcopy. The values, which are stored in JQrelcopy has to be saved in some other table. Now the problem is I want to give AJAX validation like the field cannot be blank, Only alphabetical characters are allowed for the fields which are inserted through JQrelcopy. I thought about creating a scenario, but I can't get it right

    Read the article

  • What method is used to create the password?

    - by Gortron
    Hello, I am developing on to a Groupon clone app called Couponic on behalf of a client. Can anyone help in pinpointing how Couponic generates user passwords? I want to be able to generate new passwords in the same method Couponic uses in a separate PHP script if possible, so that users of an existing site will also be able to log in to the Couponic site without re-creating an account. Couponic is built using the YII PHP framework, I can't find anything in the YII documentation. Any help would be greatly appreciated.

    Read the article

  • yiic shell: failed to perform 'crud'

    - by ufw
    Debian Squeeze, PHP 5.3.2-1, Yii 1.1.2, PHP $path to php is /usr/bin/php, permissions are '777'. When I try to run 'crud Test' in yii shell, I get the following error message: PHP Warning: include(/var/www/test/protected/models/Test.php): failed to open stream: No such file or directory in /var/www/yii/framework/YiiBase.php on line 335 PHP Warning: include(): Failed opening '/var/www/test/protected/models/Test.php' for inclusion (include_path='.:/var/www/test/protected/components:/var/www/test/protected/models:/usr/share/php:/usr/share/pear') in /var/www/yii/framework/YiiBase.php on line 335 PHP Fatal error: Class 'Test' not found in /var/www/yii/framework/db/ar/CActiveRecord.php on line 341

    Read the article

  • how to get the second batch and 3rd batch in the same query result in oracle sql + yii framework?

    - by sasori
    let' say i have 20 results in the sql query. if am gonna use the limit in the yii active record, I'll obviously get the first four from the result, but what if i wanna get the 2nd four and then 3rd four in the same query result ? how to query that via sql ? e.g $criteria2 = new CDbCriteria(); $criteria2->select = 'USERID, ADID ,ADTYPE, ADTITLE, ADDESC, PAGEVIEW, DISPPUBLISHDATE'; $criteria2->addCondition("STATUS = 1"); $criteria2->order = '"t".PAGEVIEW DESC,"t".PUBLISHDATE DESC'; $criteria2->limit = 4; $criteria2->with = array('subcat','adimages'); $result = $this->findAll($criteria2); return $result;

    Read the article

  • Penny auction concept and how the timer works

    - by madi
    I am creating a penny auction site using PHP yii framework. The main consideration of the system is to update the database records of all active auctions (max 15 auctions) with the current ticker timer. I am seeking for advice on how i should design the system where every auction item will have a its own countdown timer stored in the database and when someone bids the auction item, the counter resets to 2 min. Every users who are connected to the system should see the same countdown timer for that particular auction. I am little confused on how i should design the system. Will there be a performance issue when there are frequent updates to the database (Mysql) where 15 active auctions are updated every seconds, the countdown timer decreases by a second in the database table for the particular auction. Schema Sample for auction_lots: Auction_id,startdatetime,counter_timer,status I am seeking for advice on how I should design this. Please help. Thank you!

    Read the article

  • Why my json_encode get corrupted

    - by Cullen SUN
    $model = new XUploadForm; $model->file = CUploadedFile::getInstance( $model, 'file' ); //We check that the file was successfully uploaded if( $model->file !== null ) { //Grab some data $model->mime_type = $model->file->getType( ); $model->size = $model->file->getSize( ); $model->name = $model->file->getName( ); $file_extention = $model->file->getExtensionName( ); //(optional) Generate a random name for our file $file_tem_name = md5(Yii::app( )->user->id.microtime( ).$model->name); $file_thumb_name = $file_tem_name.'_thumb.'.$file_extention; $file_image_name = $file_tem_name.".".$file_extention; if( $model->validate( ) ) { //Move our file to our temporary dir $model->file->saveAs( $path.$file_image_name ); if(chmod($path.$file_image_name, 0777 )){ // Yii::import("ext.EPhpThumb.EPhpThumb"); // $thumb_=new EPhpThumb(); // $thumb_->init(); // $thumb_->create($path.$file_image_name) // ->resize(110,80) // ->save($path.$file_thumb_name); } //here you can also generate the image versions you need //using something like PHPThumb //Now we need to save this path to the user's session if( Yii::app( )->user->hasState( 'images' ) ) { $userImages = Yii::app( )->user->getState( 'images' ); } else { $userImages = array(); } $userImages[] = array( "filename" => $file_image_name, 'size' => $model->size, 'mime' => $model->mime_type, "path" => $path.$file_image_name, // "thumb" => $path.$file_thumb_name, ); Yii::app( )->user->setState('images', $userImages); //Now we need to tell our widget that the upload was succesfull //We do so, using the json structure defined in // https://github.com/blueimp/jQuery-File-Upload/wiki/Setup echo json_encode( array( array( "type" => $model->mime_type, "size" => $model->size, "url" => $publicPath.$file_image_name, //"thumbnail_url" => $publicPath.$file_thumb_name, //"thumbnail_url" => $publicPath."thumbs/$filename", "delete_url" => $this->createUrl( "upload", array( "_method" => "delete", "file" => $file_image_name ) ), "delete_type" => "POST" ) ) ); Above code give me correct response, [{"type":"image/jpeg","size":2266,"url":"/uploads/tmp/0b00cbaee07c6410241428c74aae1dca.jpeg","delete_url":"/api/imageUpload/upload?_method=delete&file=0b00cbaee07c6410241428c74aae1dca.jpeg","delete_type":"POST"}] but if I uncomment the following // Yii::import("ext.EPhpThumb.EPhpThumb"); // $thumb_=new EPhpThumb(); // $thumb_->init(); // $thumb_->create($path.$file_image_name) // ->resize(110,80) // ->save($path.$file_thumb_name); it gave me corrupted response: Mac OS X 2??ATTR?dA??Y?Ycom.apple.quarantine0001;50655994;Google\x20Chrome.app;2599ECF9-69C5-4386-B3D9-9F5CC7E0EE1D|com.google.ChromeThis resource fork intentionally left blank ??[{"type":"image/jpeg","size":1941,"url":"/uploads/tmp/409c5921c6d20944e1a81f32b12fc380.jpeg","delete_url":"/api/imageUpload/upload?_method=delete&file=409c5921c6d20944e1a81f32b12fc380.jpeg","delete_type":"POST"}]

    Read the article

  • Yii CGridView: how to add a static WHERE condtion?

    - by realtebo
    I've a standard Gii created admin view, which use a CGridView, and it's showing my user table data. the problem is that user with name 'root' must NOT BE VISIBLE. Is there a way to add a static where condition " ... and username !='root' " ? admin.php [view] 'columns'=>array( 'id', 'username', 'password', 'realname', 'email', ..... user.php [model] public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria=new CDbCriteria; $criteria->compare('id',$this->id); $criteria->compare('username',$this->username,true); $criteria->compare('password',$this->password,true); $criteria->compare('realname',$this->realname,true); $criteria->compare('email',$this->email,true); ...... return new CActiveDataProvider($this, array( 'criteria'=>$criteria, )); }

    Read the article

  • Trying to move away from PHP/Yii: RoR, Python/Django or ASP.NET MVC? Your opinions please [closed]

    - by Örs
    I have a CS degree and I've been working as a web developer (front & backend) for about 2 years now. I've been working with PHP mostly because it was easy to pick up and find a job, but I've grown to dislike the language and want to try something new, and possibly get a better paying job. That last point is especially important because in my area (Romania/Eastern Europe) PHP jobs are mostly for people fresh out of college/high school, hence the pay is rather low. I've been working with the Yii framework which, if I understand correctly, borrows a lot from Ruby on Rails (convention over configuration, MVC, Active Record, scaffolding). Other than PHP I only know curly-brace languages (C/C++/Java) and bash so Python/Ruby might be a bit challenging. On the other hand I've been using Linux (with vim and recently Sublime Text 2) for almost 4 years now so Windows and a lack of a terminal would have its downsides as well. I'm leaning towards Python/Ruby because of my *nix bias (plus both look like fun), but I've heard great things about ASP.NET MVC as well. Any suggestions? PS: I think there are more jobs in ASP.NET around here, but that's not necessarily a plus, because there are a lot of CS graduates as well. tl;dr: Romanian PHP/Yii developer trying to move to Python/Django or Ruby/Rails or C#/ASP.NET MVC. Suggestions?

    Read the article

  • Is there a codeigniter api reference?

    - by ajsie
    whenever using a framework it's so good with a api reference so you could lookup the classes' methods and properties, which class they extend from and so on. is there a api reference for codeigniter similar to yii's excellent api referenc? http://www.yiiframework.com/doc/api/ how else could you know more about the details about the classes if there isn't a good api reference. java's api reference is also great: http://java.sun.com/j2se/1.4.2/docs/api/ why can't i find codeigniter's. thanks.

    Read the article

  • is thera a codeigniter api reference?

    - by ajsie
    whenever using a framework it's so good with a api reference so you could lookup the classes' methods and properties, which class they extend from and so on. is there a api reference for codeigniter similar to yii's excellent api referenc? http://www.yiiframework.com/doc/api/ thanks.

    Read the article

  • yiic webapp problem

    - by bgreen1989
    hi, i'm still new to yii framework. so, i want to try running yiic so that i could see the structure of the files created. but, i could not run it in console. Does anyone have a solution? thanks. I'm using wamp on win xp. i go to the directory of the yiic framework its in D:\wamp\www\framework\ and run yiic and any other variations per Larry Ullman's blog. but still got: "..." is not a recognizable internal/ external command... How should i be able to run yiic? thanks.

    Read the article

  • Is it possible to cancel function override in parent class and use function from top level parent

    - by Anatoliy Gusarov
    class TopParent { protected function foo() { $this->bar(); } private function bar() { echo 'Bar'; } } class MidParent extends TopParent { protected function foo() { $this->midMethod(); parent::foo(); } public function midMethod() { echo 'Mid'; } public function generalMethod() { echo 'General'; } } Now the question is if I have a class, that extends MidParent because I need to call class Target extends MidParent { //How to override this method to return TopParent::foo(); ? protected function foo() { } } So I need to do this: $mid = new MidParent(); $mid->foo(); // MidBar $taget = new Target(); $target->generalMethod(); // General $target->foo(); // Bar UPDATE Top parent is ActiveRecord class, mid is my model object. I want to use model in yii ConsoleApplication. I use 'user' module in this model, and console app doesn't support this module. So I need to override method afterFind, where user module is called. So the Target class is the class that overrides some methods from model which uses some modules that console application doesn't support.

    Read the article

< Previous Page | 1 2 3 4 5  | Next Page >