Table.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Db
  17. * @subpackage Table
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Db_Table_Abstract
  24. */
  25. #require_once 'Zend/Db/Table/Abstract.php';
  26. /**
  27. * @see Zend_Db_Table_Definition
  28. */
  29. #require_once 'Zend/Db/Table/Definition.php';
  30. /**
  31. * Class for SQL table interface.
  32. *
  33. * @category Zend
  34. * @package Zend_Db
  35. * @subpackage Table
  36. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  37. * @license http://framework.zend.com/license/new-bsd New BSD License
  38. */
  39. class Zend_Db_Table extends Zend_Db_Table_Abstract
  40. {
  41. /**
  42. * __construct() - For concrete implementation of Zend_Db_Table
  43. *
  44. * @param string|array $config string can reference a Zend_Registry key for a db adapter
  45. * OR it can reference the name of a table
  46. * @param array|Zend_Db_Table_Definition $definition
  47. */
  48. public function __construct($config = array(), $definition = null)
  49. {
  50. if ($definition !== null && is_array($definition)) {
  51. $definition = new Zend_Db_Table_Definition($definition);
  52. }
  53. if (is_string($config)) {
  54. if (Zend_Registry::isRegistered($config)) {
  55. trigger_error(__CLASS__ . '::' . __METHOD__ . '(\'registryName\') is not valid usage of Zend_Db_Table, '
  56. . 'try extending Zend_Db_Table_Abstract in your extending classes.',
  57. E_USER_NOTICE
  58. );
  59. $config = array(self::ADAPTER => $config);
  60. } else {
  61. // process this as table with or without a definition
  62. if ($definition instanceof Zend_Db_Table_Definition
  63. && $definition->hasTableConfig($config)) {
  64. // this will have DEFINITION_CONFIG_NAME & DEFINITION
  65. $config = $definition->getTableConfig($config);
  66. } else {
  67. $config = array(self::NAME => $config);
  68. }
  69. }
  70. }
  71. parent::__construct($config);
  72. }
  73. }