Last active
November 17, 2016 15:25
-
-
Save acyuta/974ff2ae4b778e59d6004aa9d2bce6dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class A { | |
// ..... | |
public static function prepareDbQuery($sql, $cut_args_array = []) | |
{ | |
global $wpdb; | |
return array_map(function ($e) use ($cut_args_array) { | |
if ($cut_args_array != null) | |
foreach ($cut_args_array as $arg) unset($e[$arg]); | |
return static::newInstance($e); | |
}, $wpdb->get_results($sql)); | |
} | |
// ..... | |
} | |
abstract class B { | |
// ..... | |
public static function prepareDbQuery($sql) | |
{ | |
global $wpdb; | |
$arr = []; | |
foreach ($wpdb->get_results($sql) as $r) { | |
$arr[] = new static($r); | |
} | |
return $arr; | |
} | |
// ..... | |
} | |
//Класс А не работает. | |
//Класс B работает |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment