Esempio n. 1
0
    /**
     * UPDATE文を実行する
     * @return bool
     */
    public function update()
    {
        if (empty($this->setArr)) {
            // SET句がない場合はエラー
            return false;
        }
        $query = <<<SQL
UPDATE {$this->table}
SQL;
        list($query, $bindings) = $this->buildSet($query);
        list($query, $build_bindings) = $this->buildWhere($query);
        $bindings = array_merge($bindings, $build_bindings);
        $this->reset();
        $this->logs[] = array('query' => $query, 'bindings' => $bindings);
        return $this->DB->update($query, $bindings);
    }
Esempio n. 2
0
 /**
  * @test
  */
 public function update()
 {
     $pdoStatementMock = m::mock('PDOStatement');
     $pdoStatementMock->shouldReceive('execute')->andReturn(true);
     $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->update('', array());
     $this->assertTrue($actual);
 }