Plugin Directory

Changeset 514067


Ignore:
Timestamp:
03/03/2012 11:08:02 PM (14 years ago)
Author:
tombenner
Message:

Allowing for IN () queries to be made by setting an array as the value of a 'conditions' entry, loading core's functions.php before loading plugins

Location:
wp-mvc
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wp-mvc/tags/1.2/core/loaders/mvc_loader.php

    r513645 r514067  
    5050            'controllers/mvc_admin_controller',
    5151            'controllers/mvc_public_controller',
     52            'functions/functions',
    5253            'models/mvc_database_adapter',
    5354            'models/mvc_database',
     
    242243   
    243244    protected function load_functions() {
    244    
    245         $this->file_includer->require_php_files_in_directory($this->core_path.'functions/');
    246245       
    247246        foreach ($this->plugin_app_paths as $plugin_app_path) {
  • wp-mvc/tags/1.2/core/models/mvc_database_adapter.php

    r513645 r514067  
    104104        foreach ($conditions as $key => $value) {
    105105            if (is_array($value)) {
    106                 $clauses = $this->get_where_sql_clauses($value);
    107                 $logical_operator = $key == 'OR' ? ' OR ' : ' AND ';
    108                 $sql_clauses[] = '('.implode($logical_operator, $clauses).')';
     106                if (is_string($key) && !in_array($key, array('OR', 'AND'))) {
     107                    $values = array();
     108                    foreach ($value as $val) {
     109                        $values[] = '"'.$this->escape($val).'"';
     110                    }
     111                    $values = implode(',', $values);
     112                    $sql_clauses[] = $this->escape($key).' IN ('.$values.')';
     113                } else {
     114                    $clauses = $this->get_where_sql_clauses($value);
     115                    $logical_operator = $key == 'OR' ? ' OR ' : ' AND ';
     116                    $sql_clauses[] = '('.implode($logical_operator, $clauses).')';
     117                }
    109118                continue;
    110119            }
  • wp-mvc/trunk/core/loaders/mvc_loader.php

    r513645 r514067  
    5050            'controllers/mvc_admin_controller',
    5151            'controllers/mvc_public_controller',
     52            'functions/functions',
    5253            'models/mvc_database_adapter',
    5354            'models/mvc_database',
     
    242243   
    243244    protected function load_functions() {
    244    
    245         $this->file_includer->require_php_files_in_directory($this->core_path.'functions/');
    246245       
    247246        foreach ($this->plugin_app_paths as $plugin_app_path) {
  • wp-mvc/trunk/core/models/mvc_database_adapter.php

    r513645 r514067  
    104104        foreach ($conditions as $key => $value) {
    105105            if (is_array($value)) {
    106                 $clauses = $this->get_where_sql_clauses($value);
    107                 $logical_operator = $key == 'OR' ? ' OR ' : ' AND ';
    108                 $sql_clauses[] = '('.implode($logical_operator, $clauses).')';
     106                if (is_string($key) && !in_array($key, array('OR', 'AND'))) {
     107                    $values = array();
     108                    foreach ($value as $val) {
     109                        $values[] = '"'.$this->escape($val).'"';
     110                    }
     111                    $values = implode(',', $values);
     112                    $sql_clauses[] = $this->escape($key).' IN ('.$values.')';
     113                } else {
     114                    $clauses = $this->get_where_sql_clauses($value);
     115                    $logical_operator = $key == 'OR' ? ' OR ' : ' AND ';
     116                    $sql_clauses[] = '('.implode($logical_operator, $clauses).')';
     117                }
    109118                continue;
    110119            }
Note: See TracChangeset for help on using the changeset viewer.