显示下拉菜单

Test of PDOStatement::fetch() 本页面仅提供英文版本。

Example #1 : test success
Example #2 : test success
Example #3 : test success
Example #4 : test success
Example #5 : test success
Example #1
$input = [
  
'exec_statement' => 'CREATE TABLE fruit
                    (name, colour, calories INT];

                INSERT INTO fruit VALUES
                    (\'apple\', \'red\', 150],
                    (\'banana\', \'yellow\', 250],
                    (\'kiwi\', \'brown\', 75],
                    (\'lemon\', \'yellow\', 25],
                    (\'orange\', \'orange\', 300],
                    (\'pear\', \'green\', 150],
                    (\'watermelon\', \'pink\', 90)'
,
  
'statement' => 'SELECT name, colour, calories FROM fruit',
  
=> 'PDO::FETCH_ASSOC',
]
$expected_output = $test_output
$test_output = [
  
'result' => [
    
'pdo' => 'PDO instance',
    
'int' => 7,
    
'pdostatement' => 'PDOStatement instance',
    
'bool' => true,
    
'mixed' => [
      
'name' => 'apple',
      
'colour' => 'red',
      
'calories' => '150',
    ],
  ],
  
'php_version' => '7.1.33 Linux x86_64',
]
Example #2
$input = [
  
'exec_statement' => 'CREATE TABLE fruit
                    (name, colour, calories INT];

                INSERT INTO fruit VALUES
                    (\'apple\', \'red\', 150],
                    (\'banana\', \'yellow\', 250],
                    (\'kiwi\', \'brown\', 75],
                    (\'lemon\', \'yellow\', 25],
                    (\'orange\', \'orange\', 300],
                    (\'pear\', \'green\', 150],
                    (\'watermelon\', \'pink\', 90)'
,
  
'statement' => 'SELECT name, colour, calories FROM fruit',
  
=> 'PDO::FETCH_BOTH',
]
$expected_output = $test_output
$test_output = [
  
'result' => [
    
'pdo' => 'PDO instance',
    
'int' => 7,
    
'pdostatement' => 'PDOStatement instance',
    
'bool' => true,
    
'mixed' => [
      
'name' => 'apple',
      
=> 'apple',
      
'colour' => 'red',
      
=> 'red',
      
'calories' => '150',
      
=> '150',
    ],
  ],
  
'php_version' => '7.1.33 Linux x86_64',
]
Example #3
$input = [
  
'exec_statement' => 'CREATE TABLE fruit
                    (name, colour, calories INT];

                INSERT INTO fruit VALUES
                    (\'apple\', \'red\', 150],
                    (\'banana\', \'yellow\', 250],
                    (\'kiwi\', \'brown\', 75],
                    (\'lemon\', \'yellow\', 25],
                    (\'orange\', \'orange\', 300],
                    (\'pear\', \'green\', 150],
                    (\'watermelon\', \'pink\', 90)'
,
  
'statement' => 'SELECT name, colour, calories FROM fruit',
  
'driver_options' => [
    
'PDO::ATTR_CASE' => 'PDO::CASE_UPPER',
  ],
  
=> 'PDO::FETCH_OBJ',
]
$expected_output = $test_output
$test_output = [
  
'result' => [
    
'pdo' => 'PDO instance',
    
'int' => 7,
    
'pdostatement' => 'PDOStatement instance',
    
'bool' => true,
    
'mixed' => 
    
stdClass::__set_state(array(
       
'NAME' => 'apple',
       
'COLOUR' => 'red',
       
'CALORIES' => '150',
    )],
  ],
  
'php_version' => '7.1.33 Linux x86_64',
]
Example #4
$input = [
  
'exec_statement' => 'CREATE TABLE fruit
                    (name, colour, calories INT];

                INSERT INTO fruit VALUES
                    (\'apple\', \'red\', 150],
                    (\'banana\', \'yellow\', 250],
                    (\'kiwi\', \'brown\', 75],
                    (\'lemon\', \'yellow\', 25],
                    (\'orange\', \'orange\', 300],
                    (\'pear\', \'green\', 150],
                    (\'watermelon\', \'pink\', 90)'
,
  
'statement' => 'SELECT name, colour, calories
                FROM fruit
                WHERE calories <= :calories AND colour = :colour'
,
  
'input_parameters' => [
    
':calories' => 150,
    
':colour' => 'red',
  ],
  
=> 'PDO::FETCH_ASSOC',
]
$expected_output = $test_output
$test_output = [
  
'result' => [
    
'pdo' => 'PDO instance',
    
'int' => 7,
    
'pdostatement' => 'PDOStatement instance',
    
'bool' => true,
    
'mixed' => [
      
'name' => 'apple',
      
'colour' => 'red',
      
'calories' => '150',
    ],
  ],
  
'php_version' => '7.1.33 Linux x86_64',
]
Example #5
$input = [
  
'exec_statement' => 'CREATE TABLE fruit
                    (name, colour, calories INT];

                INSERT INTO fruit VALUES
                    (\'apple\', \'red\', 150)'
,
  
'statement' => 'SELECT name, colour, calories
                FROM fruit
                WHERE calories 150 AND colour = \'red\''
,
  
'driver_options' => [
    
'PDO::ATTR_CURSOR' => 'PDO::CURSOR_SCROLL',
  ],
]
$expected_output = $test_output
$test_output = [
  
'result' => [
    
'pdo' => 'PDO instance',
    
'int' => 1,
    
'pdostatement' => false,
  ],
  
'php_version' => '7.1.33 Linux x86_64',
]