예제 #1
0
파일: mysql.php 프로젝트: Zunair/xataface
 /**
  * Determines the number of rows affected by a data maniuplation query
  *
  * 0 is returned for queries that don't manipulate data.
  *
  * @return int  the number of rows.  A DB_Error object on failure.
  */
 function affectedRows()
 {
     if (DB::isManip($this->last_query)) {
         return @xf_db_affected_rows($this->connection);
     } else {
         return 0;
     }
 }
예제 #2
0
 function test_translateDeleteQuery()
 {
     $app =& Dataface_Application::getInstance();
     // Try to insert only values into both the base table and the
     // translated table.
     $sql = 'Delete FROM PeopleIntl where PersonID=5';
     $translator = new Dataface_QueryTranslator('en');
     $tsql = $translator->translateQuery($sql);
     //print_r($tsql);exit;
     $affected_rows = array();
     foreach ($tsql as $q) {
         $res = xf_db_query($q, $app->db());
         if (!$res) {
             die(xf_db_error($app->db()));
         }
         $affected_rows[$q] = xf_db_affected_rows($app->db());
     }
     $this->assertEquals(array("delete from `PeopleIntl` where `PersonID` = 5", "delete from `PeopleIntl_en` where `PersonID` = 5", "delete from `PeopleIntl_fr` where `PersonID` = 5"), $tsql);
     $this->assertEquals(array("delete from `PeopleIntl` where `PersonID` = 5" => 1, "delete from `PeopleIntl_en` where `PersonID` = 5" => 0, "delete from `PeopleIntl_fr` where `PersonID` = 5" => 0), $affected_rows);
 }
예제 #3
0
파일: DB_Test.php 프로젝트: Zunair/xataface
 function test_query()
 {
     $sql = "select PubType, BiblioString from Publications where PublicationID='1'";
     $res = $this->DB->query($sql);
     $this->assertTrue($res);
     if (!$res) {
         echo xf_db_error();
     }
     $row = xf_db_fetch_assoc($res);
     $this->assertEquals(array('PubType' => 'Refereed Journal', 'BiblioString' => 'Amit, H. Autonomous, metamorphic technology for B-Trees. In POT NOSSDAV (Dec. 1991).'), $row);
     $sql = "Update Publications set PubType = 'Experimental' where PublicationID='1'";
     $res = $this->DB->query($sql);
     $this->assertTrue($res);
     if (!$res) {
         echo xf_db_error();
     }
     $this->assertTrue(xf_db_affected_rows() === 1);
     $sql = "Insert into Publications (PubType) VALUES ('My new type')";
     $res = $this->DB->query($sql);
     $this->assertTrue($res);
     if (!$res) {
         echo xf_db_error();
     }
     $this->assertTrue(xf_db_affected_rows() === 1);
 }