Пример #1
0
    /**
     * DELETE文を実行する
     * @return bool
     */
    public function delete()
    {
        if (empty($this->wheres)) {
            // wheres句がない場合はエラー
            return false;
        }
        $query = <<<SQL
DELETE FROM {$this->table}
SQL;
        list($query, $build_bindings) = $this->buildWhere($query);
        $bindings = array_merge(array(), $build_bindings);
        $this->reset();
        $this->logs[] = array('query' => $query, 'bindings' => $bindings);
        return $this->DB->delete($query, $bindings);
    }
Пример #2
0
 /**
  * @test
  */
 public function fetch()
 {
     $obj = new \stdClass();
     $pdoStatementMock = m::mock('PDOStatement');
     $pdoStatementMock->shouldReceive('setFetchMode');
     $pdoStatementMock->shouldReceive('execute');
     $pdoStatementMock->shouldReceive('fetch')->andReturn($obj);
     $pdoMock = m::mock('PDO');
     $pdoMock->shouldReceive('prepare')->andReturn($pdoStatementMock);
     $connectorInterfaceMock = m::mock('Poulsen\\Connectors\\ConnectorInterface');
     $connectorInterfaceMock->shouldReceive('connect')->andReturn($pdoMock);
     $factoryMock = m::mock('Poulsen\\Connectors\\ConnectorFactory');
     $factoryMock->shouldReceive('make')->andReturn($connectorInterfaceMock);
     $Manager = new Manager($factoryMock);
     $actual = $Manager->fetch('', array());
     $this->assertEquals($actual, $obj);
 }