CakePHPをさらにDRYにする、ドライケーキレシピ akiyan.com 秋田真宏

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    3 Favorites

    CakePHPをさらにDRYにする、ドライケーキレシピ akiyan.com 秋田真宏 - Presentation Transcript

    1. ( )
    2. $this->User->findAll( array( ‘status’ => ‘active’, ‘confirmed_email’ => ‘yes’, ) )
    3. $this->User->findAll( ” status = ‘active’ AND confirmed_email = ‘YES’ ” )
    4. Don’t Repeat Yourself
    5. Class User extends AppModel { var $name = ‘User’; function getActiveUser() { return $this->User->findAll(array( ‘status’ => ‘active’, ‘confirmed_email’ => ‘yes’, )); } } $this->User->getActiveUser();
    6. Class User extends AppModel { var $name = ‘User’; function getActiveUser($limit = null, $page = null) { return $this->User->findAll(array( ‘status’ => ‘active’, ‘confirmed_email’ => ‘yes’, ), null, null, $limit, $page); } }
    7. Class User extends AppModel { var $name = ‘User’; function getActiveUser($order = null, $limit = null, $page = null) { return $this->User->findAll(array( ‘status’ => ‘active’, ‘confirmed_email’ => ‘yes’, ), null, $order, $limit, $page); } }
    8. Class User extends AppModel { var $name = ‘User’; var $cond_activeuser = array( ‘status’ => ‘active’, ‘confirmed_email’ => ‘yes’, }; } $this->User->findAll($this->User->cond_activeuser);
    9. // $this->User->findAll( am( $this->User->cond_activeuser, array(‘sex’ => ‘male’) ) );
    10. // $this->User->findAll( am( $this->User->cond_activeuser, array(‘sex’ => ‘male’) ) );
    11. // $this->User->findAll( am( $this->User->cond_activeuser, array(‘sex’ => ‘male’) ) ); ‘ ’ ‘ ’
    12. // Array( [status] => active [confirmed_email] => yes [sex] => male )
    13. Class User extends AppModel { var $name = ‘User’; var $cond_activeuser = array( ‘or’ => array( array( ‘status’ => ‘active’, ‘confirmed_email’ => ‘yes’, ), array( ‘status’ => ‘active’, ‘confirmed_phone’ => ‘yes’, ), ), ); }
    14. Array ( [or] => Array ( [0] => Array ( [status] => active [confirmed_email] => yes ) [1] => Array ( [status] => active [confirmed_phone] => yes ) ) )
    15. array_merge_recursive($this->User->cond_activeuser, array( 'or' => array( array('sex' => 'male'), ) ) )
    16. 結果
    17. Array ( [or] => Array ( [0] => Array ( [status] => active [confirmed_email] => yes ) [1] => Array ( [status] => active [confirmed_phone] => yes ) [2] => Array ( [sex] => male ) ) )
    18. $cond = $this->User->cond_activeuser; $cond[‘or’][0][‘sex’] = ‘male’; $cond[‘or’][1][‘sex’] = ‘male’;
    19. Class User extends AppModel { var $name = ‘User’; function getActiveCond($merger) { return am(array( ‘status’ => ‘active’, ‘confirmed_email’ => ‘yes’, ), $merger); } }
    20. $this->User->getActiveCond(array(‘sex’ => ‘male’)); Array( [status] => active [confirmed_email] => yes [sex] => male )
    21. Class User extends AppModel { var $name = ‘User’; function getActiveCond($merger) { return array( ‘or’ => array( am(array( ‘status’ => ‘active’, ‘confirmed_email’ => ‘yes’, ), $merger), am(array( ‘status’ => ‘active’, ‘confirmed_phone’ => ‘yes’, ), $merger), ), ); } }
    22. $this->User->getActiveCond(array(‘sex’ => ‘male’)); Array ( [or] => Array ( [0] => Array ( [status] => active [confirmed_email] => yes [sex] => male ) [1] => Array ( [status] => active [confirmed_phone] => yes [sex] => male ) ) )
    23. ← 銀座 洋菓子舗 ウエストに Dry cake というケーキがあるらしい http://www.ginza-west.co.jp/

    + akiyanakiyan, 2 years ago

    custom

    4882 views, 3 favs, 3 embeds more stats

    http://www.akiyan.com/

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 4882
      • 3597 on SlideShare
      • 1285 from embeds
    • Comments 0
    • Favorites 3
    • Downloads 53
    Most viewed embeds
    • 1283 views on http://www.akiyan.com
    • 1 views on http://www.netvibes.com
    • 1 views on http://www.ideaxidea.com

    more

    All embeds
    • 1283 views on http://www.akiyan.com
    • 1 views on http://www.netvibes.com
    • 1 views on http://www.ideaxidea.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories