SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,184
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)

    Lazy load causing problem

    The query that occurs at line 2 to get the controller's models is pointless. However, due to lazy loading it occurs.

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,184
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    PHP Code:
    $c = new Controller(1);

    $c->models[] = new Model(array('class'=>'ProfileDownload','location'=>'profile_download.class.php'));

    $c->save(); 
    line 1
    SELECT t0.`id` AS t0_id,t0.`name` AS t0_name,t0.`class` AS t0_class,t0.`location` AS t0_location,t0.`access` AS t0_access FROM controllers AS t0 WHERE t0.id = ?

    line 2 (this doesn't need to happen)
    SELECT t0.`id` AS t0_id,t0.`class` AS t0_class,t0.`location` AS t0_location,t1.`id` AS t1_id,t1.`controller_id` AS t1_controller_id,t1.`model_id` AS t1_model_id FROM models AS t0 INNER JOIN modelizations AS t1 ON t0.id = t1.model_id WHERE t1.controller_id = ?

    line 3
    INSERT INTO models (class,location) VALUES (?,?)
    INSERT INTO modelizations (controller_id,model_id) VALUES (?,?)

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,184
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    Yet, this is what I would like to be able to achieve using the former syntax.

    PHP Code:
    $c = new Controller(1);

    $c->addModels(
           new 
    Model(array('class'=>'ProfileDownload','location'=>'profile_download.class.php'))
    );

    $c->save(); 
    line 1
    SELECT t0.`id` AS t0_id,t0.`name` AS t0_name,t0.`class` AS t0_class,t0.`location` AS t0_location,t0.`access` AS t0_access FROM controllers AS t0 WHERE t0.id = ?

    line 2 (this doesn't need to happen)
    SELECT t0.`id` AS t0_id,t0.`class` AS t0_class,t0.`location` AS t0_location,t1.`id` AS t1_id,t1.`controller_id` AS t1_controller_id,t1.`model_id` AS t1_model_id FROM models AS t0 INNER JOIN modelizations AS t1 ON t0.id = t1.model_id WHERE t1.controller_id = ?


    line 3
    INSERT INTO models (class,location) VALUES (?,?)
    INSERT INTO modelizations (controller_id,model_id) VALUES (?,?)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •