PageRenderTime 30ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/dbal/src/drivers/sqlite/lmbSqliteColumnInfo.class.php

http://github.com/limb-php-framework/limb
PHP | 69 lines | 44 code | 12 blank | 13 comment | 0 complexity | 3229b0680f1192964440f0e901199a58 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-3.0, MPL-2.0-no-copyleft-exception, GPL-2.0
  1. <?php
  2. /*
  3. * Limb PHP Framework
  4. *
  5. * @link http://limb-project.com
  6. * @copyright Copyright &copy; 2004-2009 BIT(http://bit-creative.com)
  7. * @license LGPL http://www.gnu.org/copyleft/lesser.html
  8. */
  9. lmb_require('limb/dbal/src/drivers/lmbDbColumnInfo.class.php');
  10. lmb_require(dirname(__FILE__) . '/lmbSqliteTypeInfo.class.php');
  11. /**
  12. * class lmbSqliteColumnInfo.
  13. *
  14. * @package dbal
  15. * @version $Id$
  16. */
  17. class lmbSqliteColumnInfo extends lmbDbColumnInfo
  18. {
  19. protected $nativeType;
  20. protected $isAutoIncrement;
  21. protected $isExisting = false;
  22. function __construct(
  23. $table,
  24. $name,
  25. $nativeType = null,
  26. $size = null,
  27. $scale = null,
  28. $isNullable = null,
  29. $default = null,
  30. $isAutoIncrement = null,
  31. $isExisting = false)
  32. {
  33. $this->nativeType = $this->canonicalizeNativeType($nativeType);
  34. $this->isAutoIncrement = $this->canonicalizeIsAutoincrement($isAutoIncrement);
  35. $typeinfo = new lmbSqliteTypeInfo();
  36. $typemap = $typeinfo->getNativeToColumnTypeMapping();
  37. $type = $typemap[$this->nativeType];
  38. $this->isExisting = $isExisting;
  39. parent::__construct($table, $name, $type, $size, $scale, $isNullable, $default);
  40. }
  41. function getNativeType()
  42. {
  43. return $this->nativeType;
  44. }
  45. function canonicalizeNativeType($nativeType)
  46. {
  47. return strtolower($nativeType);
  48. }
  49. function isAutoIncrement()
  50. {
  51. return $this->isAutoIncrement === true;
  52. }
  53. function canonicalizeIsAutoIncrement($isAutoIncrement)
  54. {
  55. return is_null($isAutoIncrement) ? null : (bool) $isAutoIncrement;
  56. }
  57. }