فهرست منبع

Fixes repository bug when compound keys are involved.

Alan Lam 8 سال پیش
والد
کامیت
595d0ff7ea
1فایلهای تغییر یافته به همراه4 افزوده شده و 3 حذف شده
  1. 4 3
      engine/model.php

+ 4 - 3
engine/model.php

@@ -78,16 +78,17 @@ abstract class Model {
 	public static function get($id) {
 
 		$table = static::$table;
+		$is_compound_key = is_array(static::$id_field);
 
 		// Check repo for item
-		if(!is_array($id) && isset(static::$repositories[$table][$id])) {
+		if(!$is_compound_key && isset(static::$repositories[$table][$id])) {
 			return static::$repositories[$table][$id];
 		}
 
 		$id_field = static::$id_field;
 		$class = get_called_class();
 
-		if(is_array($id_field)) { // Compound key
+		if($is_compound_key) { // Compound key
 			$args = func_get_args();
 			$fields = $id_field;
 
@@ -109,7 +110,7 @@ abstract class Model {
 
 		if($object) {
 			$object = new $class($object);
-			if(!is_array($id)) {
+			if(!$is_compound_key) {
 				static::$repositories[$table][$id] = $object;
 			}
 		}