Redaxscript\Db::forTablePrefix PHP Method

forTablePrefix() public static method

for table with prefix
Since: 2.2.0
public static forTablePrefix ( string $table = null, string $connection = self::DEFAULT_CONNECTION ) : Db
$table string name of the table
$connection string which connection to use
return Db
    public static function forTablePrefix($table = null, $connection = self::DEFAULT_CONNECTION)
    {
        self::_setupDb($connection);
        return new self(self::$_config->get('dbPrefix') . $table, [], $connection);
    }

Usage Example

コード例 #1
0
ファイル: Login.php プロジェクト: redaxmedia/redaxscript
 /**
  * process the class
  *
  * @since 3.0.0
  *
  * @return string
  */
 public function process()
 {
     $specialFilter = new Filter\Special();
     $emailFilter = new Filter\Email();
     $emailValidator = new Validator\Email();
     $loginValidator = new Validator\Login();
     $auth = new Auth($this->_request);
     /* process post */
     $postArray = ['password' => $specialFilter->sanitize($this->_request->getPost('password')), 'task' => $this->_request->getPost('task'), 'solution' => $this->_request->getPost('solution')];
     /* user and email */
     $users = Db::forTablePrefix('users');
     if ($emailValidator->validate($this->_request->getPost('user')) === Validator\ValidatorInterface::PASSED) {
         $postArray['user'] = $emailFilter->sanitize($this->_request->getPost('user'));
         $users->where('email', $postArray['user']);
     } else {
         if ($loginValidator->validate($this->_request->getPost('user')) === Validator\ValidatorInterface::PASSED) {
             $postArray['user'] = $specialFilter->sanitize($this->_request->getPost('user'));
             $users->where('user', $postArray['user']);
         }
     }
     $user = $users->where('status', 1)->findOne();
     /* handle error */
     $messageArray = $this->_validate($postArray, $user);
     if ($messageArray) {
         return $this->_error(['message' => $messageArray]);
     }
     /* handle success */
     if ($auth->login($user->id)) {
         return $this->_success();
     }
     return $this->_error(['message' => $this->_language->get('something_wrong')]);
 }
All Usage Examples Of Redaxscript\Db::forTablePrefix