test_fields.phpt 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. --TEST--
  2. Sybase-CT sybase_field_* functions
  3. --SKIPIF--
  4. <?php require('skipif.inc'); ?>
  5. --FILE--
  6. <?php
  7. /* This file is part of PHP test framework for ext/sybase_ct
  8. *
  9. * $Id$
  10. */
  11. require('test.inc');
  12. $db= sybase_connect_ex();
  13. // Issue a query
  14. $q= sybase_unbuffered_query('select
  15. 1 as "id",
  16. "Hello" as "caption",
  17. "timm" as "author",
  18. getdate() as "lastchange"
  19. ', $db, FALSE);
  20. var_dump($q);
  21. var_dump(sybase_num_fields($q));
  22. // Go through each field, dumping it
  23. while ($field= sybase_fetch_field($q)) {
  24. var_export($field); echo "\n";
  25. }
  26. // Seek to the second field and fetch it
  27. var_dump(sybase_field_seek($q, 1));
  28. var_export(sybase_fetch_field($q)); echo "\n";
  29. sybase_close($db);
  30. ?>
  31. --EXPECTF--
  32. resource(%d) of type (sybase-ct result)
  33. int(4)
  34. stdClass::__set_state(array(
  35. 'name' => 'id',
  36. 'max_length' => 11,
  37. 'column_source' => '',
  38. 'numeric' => 1,
  39. 'type' => 'int',
  40. ))
  41. stdClass::__set_state(array(
  42. 'name' => 'caption',
  43. 'max_length' => 5,
  44. 'column_source' => '',
  45. 'numeric' => 0,
  46. 'type' => 'string',
  47. ))
  48. stdClass::__set_state(array(
  49. 'name' => 'author',
  50. 'max_length' => 4,
  51. 'column_source' => '',
  52. 'numeric' => 0,
  53. 'type' => 'string',
  54. ))
  55. stdClass::__set_state(array(
  56. 'name' => 'lastchange',
  57. 'max_length' => 29,
  58. 'column_source' => '',
  59. 'numeric' => 0,
  60. 'type' => 'datetime',
  61. ))
  62. bool(true)
  63. stdClass::__set_state(array(
  64. 'name' => 'caption',
  65. 'max_length' => 5,
  66. 'column_source' => '',
  67. 'numeric' => 0,
  68. 'type' => 'string',
  69. ))