File indexing completed on 2024-05-12 06:02:26

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Db
0017  * @subpackage Table
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 /**
0024  * @see Zend_Db_Table_Abstract
0025  */
0026 // require_once 'Zend/Db/Table/Abstract.php';
0027 
0028 /**
0029  * @see Zend_Db_Table_Definition
0030  */
0031 // require_once 'Zend/Db/Table/Definition.php';
0032 
0033 /**
0034  * Class for SQL table interface.
0035  *
0036  * @category   Zend
0037  * @package    Zend_Db
0038  * @subpackage Table
0039  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0040  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0041  */
0042 class Zend_Db_Table extends Zend_Db_Table_Abstract
0043 {
0044 
0045     /**
0046      * __construct() - For concrete implementation of Zend_Db_Table
0047      *
0048      * @param string|array $config string can reference a Zend_Registry key for a db adapter
0049      *                             OR it can reference the name of a table
0050      * @param array|Zend_Db_Table_Definition $definition
0051      */
0052     public function __construct($config = array(), $definition = null)
0053     {
0054         if ($definition !== null && is_array($definition)) {
0055             $definition = new Zend_Db_Table_Definition($definition);
0056         }
0057 
0058         if (is_string($config)) {
0059             if (Zend_Registry::isRegistered($config)) {
0060                 trigger_error(__CLASS__ . '::' . __METHOD__ . '(\'registryName\') is not valid usage of Zend_Db_Table, '
0061                     . 'try extending Zend_Db_Table_Abstract in your extending classes.',
0062                     E_USER_NOTICE
0063                     );
0064                 $config = array(self::ADAPTER => $config);
0065             } else {
0066                 // process this as table with or without a definition
0067                 if ($definition instanceof Zend_Db_Table_Definition
0068                     && $definition->hasTableConfig($config)) {
0069                     // this will have DEFINITION_CONFIG_NAME & DEFINITION
0070                     $config = $definition->getTableConfig($config);
0071                 } else {
0072                     $config = array(self::NAME => $config);
0073                 }
0074             }
0075         }
0076 
0077         parent::__construct($config);
0078     }
0079 }