Prado\Data\DataGateway\TTableGateway::__call PHP Метод

__call() публичный Метод

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: $table->findByName($name) $table->find('Name = ?', $name); $table->findByUsernameAndPassword($name,$pass); // OR may be used $table->findBy_Username_And_Password($name,$pass); // _OR_ may be used $table->find('Username = ? AND Password = ?', $name, $pass); $table->findAllByAge($age); $table->findAll('Age = ?', $age); $table->deleteAll('Name = ?', $name); $table->deleteByName($name);
public __call ( $method, $args ) : mixed
Результат 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 ($findOne = substr(strtolower($method), 0, 6) === 'findby') {
            $condition = $method[6] === '_' ? substr($method, 7) : substr($method, 6);
        } else {
            if (substr(strtolower($method), 0, 9) === 'findallby') {
                $condition = $method[9] === '_' ? substr($method, 10) : substr($method, 9);
            } else {
                if ($delete = substr(strtolower($method), 0, 8) === 'deleteby') {
                    $condition = $method[8] === '_' ? substr($method, 9) : substr($method, 8);
                } else {
                    if ($delete = substr(strtolower($method), 0, 11) === 'deleteallby') {
                        $condition = $method[11] === '_' ? substr($method, 12) : substr($method, 11);
                    } else {
                        return null;
                    }
                }
            }
        }
        $criteria = $this->getCommand()->createCriteriaFromString($method, $condition, $args);
        if ($delete) {
            return $this->deleteAll($criteria);
        } else {
            return $findOne ? $this->find($criteria) : $this->findAll($criteria);
        }
    }