Prado\Data\ActiveRecord\TActiveRecord::__call PHP Method

__call() public method

Method name starting with "findBy" only returns 1 record. Method name starting with "findAllBy" returns 0 or more records. Method name starting with "deleteBy" deletes records by the trail criteria. The condition is taken as part of the method name after "findBy", "findAllBy" or "deleteBy". The following are equivalent: $finder->findByName($name) $finder->find('Name = ?', $name); $finder->findByUsernameAndPassword($name,$pass); // OR may be used $finder->findBy_Username_And_Password($name,$pass); // _OR_ may be used $finder->find('Username = ? AND Password = ?', $name, $pass); $finder->findAllByAge($age); $finder->findAll('Age = ?', $age); $finder->deleteAll('Name = ?', $name); $finder->deleteByName($name);
public __call ( $method, $args ) : mixed
return mixed single record if method name starts with "findBy", 0 or more records if method name starts with "findAllBy"
    public function __call($method, $args)
    {
        $delete = false;
        if (strncasecmp($method, 'with', 4) === 0) {
            $property = $method[4] === '_' ? substr($method, 5) : substr($method, 4);
            return $this->getRelationHandler($property, $args);
        } else {
            if ($findOne = strncasecmp($method, 'findby', 6) === 0) {
                $condition = $method[6] === '_' ? substr($method, 7) : substr($method, 6);
            } else {
                if (strncasecmp($method, 'findallby', 9) === 0) {
                    $condition = $method[9] === '_' ? substr($method, 10) : substr($method, 9);
                } else {
                    if ($delete = strncasecmp($method, 'deleteby', 8) === 0) {
                        $condition = $method[8] === '_' ? substr($method, 9) : substr($method, 8);
                    } else {
                        if ($delete = strncasecmp($method, 'deleteallby', 11) === 0) {
                            $condition = $method[11] === '_' ? substr($method, 12) : substr($method, 11);
                        } else {
                            if ($this->getInvalidFinderResult() == TActiveRecordInvalidFinderResult::Exception) {
                                throw new TActiveRecordException('ar_invalid_finder_method', $method);
                            } else {
                                return null;
                            }
                        }
                    }
                }
            }
        }
        $criteria = $this->getRecordGateway()->getCommand($this)->createCriteriaFromString($method, $condition, $args);
        if ($delete) {
            return $this->deleteAll($criteria);
        } else {
            return $findOne ? $this->find($criteria) : $this->findAll($criteria);
        }
    }