Skip to content

Instantly share code, notes, and snippets.

@acyuta
Last active November 17, 2016 15:25
Show Gist options
  • Save acyuta/974ff2ae4b778e59d6004aa9d2bce6dc to your computer and use it in GitHub Desktop.
Save acyuta/974ff2ae4b778e59d6004aa9d2bce6dc to your computer and use it in GitHub Desktop.
<?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