Ejemplo n.º 1
0
 /**
  * @param Board|PDO $target
  * @return PDOStatement
  * @throws Exception\RuntimeException
  */
 public function prepare($target, &$params = null)
 {
     $board = Board::cast($target, false);
     $pdo = $board->getPdo();
     $result = $this->render($board);
     $stmt = $pdo->prepare($result->getSql());
     $params = $result->getParams();
     if (!$stmt) {
         $error = $pdo->errorInfo();
         $message = '[' . $error[0] . '] ' . $error[2];
         throw Exception\RuntimeException($message, $error[1]);
     }
     return $stmt;
 }
Ejemplo n.º 2
0
 /**
  * @param Board $board
  * @param int $depth
  */
 protected function build(Board $board, $depth = 0)
 {
     $resolve = $board->getResolve();
     $params = $this->getParams();
     if ($resolve && !empty($params)) {
         $expr = $this->resolveParams($board);
     } else {
         $expr = $this->getExpr();
         foreach ($params as $p) {
             $board->add($p);
         }
     }
     $board->write($expr);
 }