コード例 #1
0
 /**
  * Test to make sure we can run a basic update statement
  *
  * @return  void
  **/
 public function testBasicAlter()
 {
     $dbo = $this->getMockDriver();
     $query = new Query($dbo);
     // Try to update an existing row
     $query->alter('users', 'id', 1, ['name' => 'Updated User', 'email' => '*****@*****.**']);
     // Get the current state of the database
     $queryTable = $this->getConnection()->createQueryTable('users', 'SELECT * FROM users');
     // Get our expected state of the database
     $expectedTable = $this->createFlatXmlDataSet(dirname(__FILE__) . DS . 'Fixtures' . DS . 'updatedUsers.xml')->getTable('users');
     // Now assert that updated and expected are the same
     $this->assertTablesEqual($expectedTable, $queryTable);
 }
コード例 #2
0
ファイル: Relational.php プロジェクト: kevinwojo/framework
 /**
  * Updates an existing item in the database
  *
  * @return  bool
  * @since   2.0.0
  **/
 private function modify()
 {
     // Add any automatic fields
     $this->parseAutomatics('renew');
     // Return the result of the query
     return $this->query->alter($this->getTableName(), $this->getPrimaryKey(), $this->getPkValue(), $this->attributes);
 }