本文整理匯總了PHP中DboSource::introspectType方法的典型用法代碼示例。如果您正苦於以下問題:PHP DboSource::introspectType方法的具體用法?PHP DboSource::introspectType怎麽用?PHP DboSource::introspectType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DboSource
的用法示例。
在下文中一共展示了DboSource::introspectType方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testIntrospectType
/**
* testIntrospectType method
*
* @return void
*/
public function testIntrospectType()
{
$this->assertEquals('integer', $this->Dbo->introspectType(0));
$this->assertEquals('integer', $this->Dbo->introspectType(2));
$this->assertEquals('string', $this->Dbo->introspectType('2'));
$this->assertEquals('string', $this->Dbo->introspectType('2.2'));
$this->assertEquals('float', $this->Dbo->introspectType(2.2));
$this->assertEquals('string', $this->Dbo->introspectType('stringme'));
$this->assertEquals('string', $this->Dbo->introspectType('0stringme'));
$data = array(2.2);
$this->assertEquals('float', $this->Dbo->introspectType($data));
$data = array('2.2');
$this->assertEquals('float', $this->Dbo->introspectType($data));
$data = array(2);
$this->assertEquals('integer', $this->Dbo->introspectType($data));
$data = array('2');
$this->assertEquals('integer', $this->Dbo->introspectType($data));
$data = array('string');
$this->assertEquals('string', $this->Dbo->introspectType($data));
$data = array(2.2, '2.2');
$this->assertEquals('float', $this->Dbo->introspectType($data));
$data = array(2, '2');
$this->assertEquals('integer', $this->Dbo->introspectType($data));
$data = array('string one', 'string two');
$this->assertEquals('string', $this->Dbo->introspectType($data));
$data = array('2.2', 3);
$this->assertEquals('integer', $this->Dbo->introspectType($data));
$data = array('2.2', '0stringme');
$this->assertEquals('string', $this->Dbo->introspectType($data));
$data = array(2.2, 3);
$this->assertEquals('integer', $this->Dbo->introspectType($data));
$data = array(2.2, '0stringme');
$this->assertEquals('string', $this->Dbo->introspectType($data));
$data = array(2, 'stringme');
$this->assertEquals('string', $this->Dbo->introspectType($data));
$data = array(2, '2.2', 'stringgme');
$this->assertEquals('string', $this->Dbo->introspectType($data));
$data = array(2, '2.2');
$this->assertEquals('integer', $this->Dbo->introspectType($data));
$data = array(2, 2.2);
$this->assertEquals('integer', $this->Dbo->introspectType($data));
// null
$result = $this->Dbo->value(null, 'boolean');
$this->assertEquals('NULL', $result);
// EMPTY STRING
$result = $this->Dbo->value('', 'boolean');
$this->assertEquals("'0'", $result);
// BOOLEAN
$result = $this->Dbo->value('true', 'boolean');
$this->assertEquals("'1'", $result);
$result = $this->Dbo->value('false', 'boolean');
$this->assertEquals("'1'", $result);
$result = $this->Dbo->value(true, 'boolean');
$this->assertEquals("'1'", $result);
$result = $this->Dbo->value(false, 'boolean');
$this->assertEquals("'0'", $result);
$result = $this->Dbo->value(1, 'boolean');
$this->assertEquals("'1'", $result);
$result = $this->Dbo->value(0, 'boolean');
$this->assertEquals("'0'", $result);
$result = $this->Dbo->value('abc', 'boolean');
$this->assertEquals("'1'", $result);
$result = $this->Dbo->value(1.234, 'boolean');
$this->assertEquals("'1'", $result);
$result = $this->Dbo->value('1.234e05', 'boolean');
$this->assertEquals("'1'", $result);
// NUMBERS
$result = $this->Dbo->value(123, 'integer');
$this->assertEquals(123, $result);
$result = $this->Dbo->value('123', 'integer');
$this->assertEquals('123', $result);
$result = $this->Dbo->value('0123', 'integer');
$this->assertEquals("'0123'", $result);
$result = $this->Dbo->value('0x123ABC', 'integer');
$this->assertEquals("'0x123ABC'", $result);
$result = $this->Dbo->value('0x123', 'integer');
$this->assertEquals("'0x123'", $result);
$result = $this->Dbo->value(1.234, 'float');
$this->assertEquals(1.234, $result);
$result = $this->Dbo->value('1.234', 'float');
$this->assertEquals('1.234', $result);
$result = $this->Dbo->value(' 1.234 ', 'float');
$this->assertEquals("' 1.234 '", $result);
$result = $this->Dbo->value('1.234e05', 'float');
$this->assertEquals("'1.234e05'", $result);
$result = $this->Dbo->value('1.234e+5', 'float');
$this->assertEquals("'1.234e+5'", $result);
$result = $this->Dbo->value('1,234', 'float');
$this->assertEquals("'1,234'", $result);
$result = $this->Dbo->value('FFF', 'integer');
$this->assertEquals("'FFF'", $result);
$result = $this->Dbo->value('abc', 'integer');
$this->assertEquals("'abc'", $result);
// STRINGS
$result = $this->Dbo->value('123', 'string');
//.........這裏部分代碼省略.........