File indexing completed on 2024-12-22 05:36:27

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_Amf
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  * @version    $Id$
0020  */
0021 
0022 /**
0023  * This class implements authentication against XML file with roles for Flex Builder.
0024  *
0025  * @package    Zend_Amf
0026  * @subpackage Adobe
0027  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0028  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0029  */
0030 class Zend_Amf_Adobe_DbInspector
0031 {
0032 
0033     /**
0034      * Connect to the database
0035      *
0036      * @param string $dbType Database adapter type for Zend_Db
0037      * @param array|object $dbDescription Adapter-specific connection settings
0038      * @return Zend_Db_Adapter_Abstract
0039      * @see Zend_Db::factory()
0040      */
0041     protected function _connect($dbType, $dbDescription)
0042     {
0043         if(is_object($dbDescription)) {
0044             $dbDescription = get_object_vars($dbDescription);
0045         }
0046         return Zend_Db::factory($dbType, $dbDescription);
0047     }
0048 
0049     /**
0050      * Describe database object.
0051      *
0052      * Usage example:
0053      * $inspector->describeTable('Pdo_Mysql',
0054      *     array(
0055      *         'host'     => '127.0.0.1',
0056      *         'username' => 'webuser',
0057      *         'password' => 'xxxxxxxx',
0058      *         'dbname'   => 'test'
0059      *     ),
0060      *     'mytable'
0061      * );
0062      *
0063      * @param string $dbType Database adapter type for Zend_Db
0064      * @param array|object $dbDescription Adapter-specific connection settings
0065      * @param string $tableName Table name
0066      * @return array Table description
0067      * @see Zend_Db::describeTable()
0068      * @see Zend_Db::factory()
0069      */
0070     public function describeTable($dbType, $dbDescription, $tableName)
0071     {
0072         $db = $this->_connect($dbType, $dbDescription);
0073         return $db->describeTable($tableName);
0074     }
0075 
0076     /**
0077      * Test database connection
0078      *
0079      * @param string $dbType Database adapter type for Zend_Db
0080      * @param array|object $dbDescription Adapter-specific connection settings
0081      * @return bool
0082      * @see Zend_Db::factory()
0083      */
0084     public function connect($dbType, $dbDescription)
0085     {
0086         $db = $this->_connect($dbType, $dbDescription);
0087         $db->listTables();
0088         return true;
0089     }
0090 
0091     /**
0092      * Get the list of database tables
0093      *
0094      * @param string $dbType Database adapter type for Zend_Db
0095      * @param array|object $dbDescription Adapter-specific connection settings
0096      * @return array List of the tables
0097      */
0098     public function getTables($dbType, $dbDescription)
0099     {
0100         $db = $this->_connect($dbType, $dbDescription);
0101         return $db->listTables();
0102     }
0103 }