added exception for wrong number of parameters to dynamic finders.
This commit is contained in:
parent
319dcbe777
commit
a97b8b7fda
|
@ -17,12 +17,12 @@ public static function build($method, $parameters, $query)
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// 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 @@ public static function build($method, $parameters, $query)
|
||||||
{
|
{
|
||||||
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++;
|
||||||
|
|
Loading…
Reference in New Issue