Commit a97b8b7f authored by Taylor Otwell's avatar Taylor Otwell

added exception for wrong number of parameters to dynamic finders.

parent 319dcbe7
...@@ -17,12 +17,12 @@ class Dynamic { ...@@ -17,12 +17,12 @@ class Dynamic {
// --------------------------------------------------------- // ---------------------------------------------------------
// Strip the "where_" off of the method. // Strip the "where_" off of the method.
// --------------------------------------------------------- // ---------------------------------------------------------
$method = substr($method, 6); $finder = substr($method, 6);
// --------------------------------------------------------- // ---------------------------------------------------------
// Split the column names from the connectors. // Split the column names from the connectors.
// --------------------------------------------------------- // ---------------------------------------------------------
$segments = preg_split('/(_and_|_or_)/i', $method, -1, PREG_SPLIT_DELIM_CAPTURE); $segments = preg_split('/(_and_|_or_)/i', $finder, -1, PREG_SPLIT_DELIM_CAPTURE);
// --------------------------------------------------------- // ---------------------------------------------------------
// The connector variable will determine which connector // The connector variable will determine which connector
...@@ -44,6 +44,11 @@ class Dynamic { ...@@ -44,6 +44,11 @@ class Dynamic {
{ {
if ($segment != '_and_' and $segment != '_or_') if ($segment != '_and_' and $segment != '_or_')
{ {
if ( ! array_key_exists($index, $parameters))
{
throw new \Exception("Wrong number of parameters for dynamic finder [$method].");
}
$query->where($segment, '=', $parameters[$index], $connector); $query->where($segment, '=', $parameters[$index], $connector);
$index++; $index++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment