コード例 #1
0
 /**
  * @param  string $position
  * @return int
  * @throws InvalidArgumentException if position unknown
  * @access protected
  */
 protected function getPosition($position)
 {
     $c = get_class($this) . '::' . 'ORDER_' . strtoupper($position);
     if (!defined($c)) {
         throw new InvalidArgumentException(Message::get(Message::SQL_UNKNOWN_POS, $position), Message::SQL_UNKNOWN_POS);
     }
     return constant($c);
 }
コード例 #2
0
 /**
  * Pass any unkown method like 'get()' to the query executor
  *
  * @param  string $method
  * @param  array $arguments
  * @return mixed
  * @throws BadMethodCallException
  */
 public function __call($method, array $arguments)
 {
     $executor = $this->getBuilder()->getExecutor();
     if ($executor && method_exists($executor, $method)) {
         $sql = $this->getStatement();
         $val = $this->getBindings();
         return call_user_func_array([$executor, $method], [$sql, $val]);
     }
     throw new BadMethodCallException(Message::get(Message::BUILDER_UNKNOWN_METHOD, $method), Message::BUILDER_UNKNOWN_METHOD);
 }
コード例 #3
0
ファイル: Builder.php プロジェクト: phossa/phossa-query
 /**
  * Get the statement object
  *
  * @param  string $method
  * @param  bool $setTable set with builder tables
  * @return StatementInterface
  * @throws BadMethodCallException if no method found for this dialect
  * @access protected
  */
 protected function getDialectStatement($method, $setTable = true)
 {
     // dialect
     $dialect = $this->getDialect();
     // check method
     if (!method_exists($dialect, $method)) {
         throw new BadMethodCallException(Message::get(Message::BUILDER_UNKNOWN_METHOD, $method), Message::BUILDER_UNKNOWN_METHOD);
     }
     /* @var $statement StatementInterface */
     $statement = call_user_func([$dialect, $method], $this);
     // prevous statement like in UNION
     if ($this->hasPrevious()) {
         $statement->setPrevious($this->getPrevious());
         $this->setPrevious(null);
         // set tables
     } elseif ($setTable && count($this->tables)) {
         if (method_exists($statement, 'from')) {
             // FROM all tables
             $statement->from($this->tables);
         } else {
             // INTO the first table
             $statement->into($this->tables[array_keys($this->tables)[0]]);
         }
     }
     return $statement;
 }