diff --git a/ActiveRecord.php b/ActiveRecord.php index 084587547..14b244154 100644 --- a/ActiveRecord.php +++ b/ActiveRecord.php @@ -40,11 +40,11 @@ function activerecord_autoload($class_name) foreach ($namespaces as $directory) $directories[] = $directory; - $root .= DIRECTORY_SEPARATOR . implode($directories, DIRECTORY_SEPARATOR); + $root .= DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $directories); } $file = "$root/$class_name.php"; if (file_exists($file)) require_once $file; -} \ No newline at end of file +} diff --git a/lib/Model.php b/lib/Model.php index 99667b41f..1e4ae51c1 100644 --- a/lib/Model.php +++ b/lib/Model.php @@ -1666,8 +1666,17 @@ public static function find_by_pk($values, $options) $list = $table->find($options); } $results = count($list); + if ( !is_array( $values ) ) { + $values = array( $values ); + } - if ($results != ($expected = count($values))) + if ( is_array($values) ){ + $expected = count($values); + } else { + $expected = 1; + $values = array( $values ); + } + if ($results != $expected) { $class = get_called_class(); if (is_array($values))