Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

php - Datamapper ORM/ CodeIgniter - using and displaying join tables -


i've got "steps" table, "id" , text of step named "step". have "customers" table "id" , other customer info. finally, have "customers_steps" join table "customer_id" , "step_id". goal have list of steps, , show ones completed. i'm stuck...

to make sure i'm not missing anything, in "customer" model, have

var $has_many = array ('step'); 

in "step" model, have

var $has_many = array('customer'); 

right now, i'm looping steps, looping through customer's steps see if match... it's lot of code, , know there has faster way, , i'm missing it:

$c = new customer(); $c->get_by_id(1); $c->step->get(); $s = new step(); $s->get(); foreach($s $step)  {    foreach($c $customer)     {       if($customer->step->id == $step->id)       {          $match = true;       }    }    if($match)    {      echo "match - " . $step->step;    }     else     {      echo $step->step;    } } 

this works... can make better? in advance.

you have many-to-many relationship, you'll never able in 1 go.

ideally, need left join between steps , customers_steps, produce resultset steps in it, , null value steps not present specific customer id. since datamapper relationships, can't report relations aren't there.

you use

// customer , steps $c = new customer(1); $c->step->get();  // create list of assigned step id's $list = array(); foreach ($c->step $step) {     $list[] = $step->id; }  // steps not assigned $s = new step(); $s->where_not_in('id', $list);  // @ point $c->steps contains matching steps // , $s steps don't match print_r($c->steps->all_to_array()); print_r($s->all_to_array()); 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -