boolean() public method

Translates between PHP boolean values and Database (faked) boolean values
public boolean ( mixed $data, boolean $quote = false ) : string | boolean
$data mixed Value to be translated
$quote boolean Whether or not the field should be cast to a string.
return string | boolean Converted boolean value
Exemplo n.º 1
0
 /**
  * Tests that different Postgres boolean 'flavors' are properly returned as native PHP booleans
  *
  * @access public
  * @return void
  */
 function testBooleanNormalization()
 {
     $this->assertTrue($this->db2->boolean('t'));
     $this->assertTrue($this->db2->boolean('true'));
     $this->assertTrue($this->db2->boolean('TRUE'));
     $this->assertTrue($this->db2->boolean(true));
     $this->assertTrue($this->db2->boolean(1));
     $this->assertTrue($this->db2->boolean(" "));
     $this->assertFalse($this->db2->boolean('f'));
     $this->assertFalse($this->db2->boolean('false'));
     $this->assertFalse($this->db2->boolean('FALSE'));
     $this->assertFalse($this->db2->boolean(false));
     $this->assertFalse($this->db2->boolean(0));
     $this->assertFalse($this->db2->boolean(''));
 }
Exemplo n.º 2
0
 /**
  * Tests that different Postgres boolean 'flavors' are properly returned as native PHP booleans
  *
  * @return void
  */
 public function testBooleanNormalization()
 {
     $this->assertEquals(true, $this->Dbo2->boolean('t', false));
     $this->assertEquals(true, $this->Dbo2->boolean('true', false));
     $this->assertEquals(true, $this->Dbo2->boolean('TRUE', false));
     $this->assertEquals(true, $this->Dbo2->boolean(true, false));
     $this->assertEquals(true, $this->Dbo2->boolean(1, false));
     $this->assertEquals(true, $this->Dbo2->boolean(" ", false));
     $this->assertEquals(false, $this->Dbo2->boolean('f', false));
     $this->assertEquals(false, $this->Dbo2->boolean('false', false));
     $this->assertEquals(false, $this->Dbo2->boolean('FALSE', false));
     $this->assertEquals(false, $this->Dbo2->boolean(false, false));
     $this->assertEquals(false, $this->Dbo2->boolean(0, false));
     $this->assertEquals(false, $this->Dbo2->boolean('', false));
 }
Exemplo n.º 3
0
 /**
  * Tests that different Postgres boolean 'flavors' are properly returned as native PHP booleans
  *
  * @return void
  */
 public function testBooleanNormalization()
 {
     $this->assertEquals(TRUE, $this->Dbo2->boolean('t', FALSE));
     $this->assertEquals(TRUE, $this->Dbo2->boolean('true', FALSE));
     $this->assertEquals(TRUE, $this->Dbo2->boolean('TRUE', FALSE));
     $this->assertEquals(TRUE, $this->Dbo2->boolean(TRUE, FALSE));
     $this->assertEquals(TRUE, $this->Dbo2->boolean(1, FALSE));
     $this->assertEquals(TRUE, $this->Dbo2->boolean(" ", FALSE));
     $this->assertEquals(FALSE, $this->Dbo2->boolean('f', FALSE));
     $this->assertEquals(FALSE, $this->Dbo2->boolean('false', FALSE));
     $this->assertEquals(FALSE, $this->Dbo2->boolean('FALSE', FALSE));
     $this->assertEquals(FALSE, $this->Dbo2->boolean(FALSE, FALSE));
     $this->assertEquals(FALSE, $this->Dbo2->boolean(0, FALSE));
     $this->assertEquals(FALSE, $this->Dbo2->boolean('', FALSE));
 }