~desarrollokumbia/kumbia/ActiveRecord

« back to all changes in this revision

Viewing changes to db_pool/table_meta_data.php

  • Committer: Emilio Silveira
  • Date: 2010-01-10 04:49:16 UTC
  • Revision ID: emilio.rst@gmail.com-20100110044916-qvymkocllio8mv43
Aun con la metadata

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/**
3
 
 * KumbiaPHP web & app 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://wiki.kumbiaphp.com/Licencia
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@kumbiaphp.com so we can send you a copy immediately.
14
 
 *
15
 
 * Clase que maneja los metadatos de las tablas
16
 
 * 
17
 
 * @category   Kumbia
18
 
 * @package    DbPool 
19
 
 * @copyright  Copyright (c) 2005-2009 Kumbia Team (http://www.kumbiaphp.com)
20
 
 * @license    http://wiki.kumbiaphp.com/Licencia     New BSD License
21
 
 */
22
 
 
23
 
/**
24
 
 * Clase que maneja los metadatos de las tablas
25
 
 *
26
 
 */
27
 
class TableMetaData
28
 
{
29
 
    /**
30
 
     * Metadatos de la tabla
31
 
     *
32
 
     * @var array
33
 
     **/
34
 
    private $_metadata = null;
35
 
 
36
 
    /**
37
 
     * Instancias de metadata
38
 
     *
39
 
     * @var array
40
 
     **/
41
 
    private static $_instances = array(); 
42
 
 
43
 
    private function __construct()
44
 
    {}
45
 
    
46
 
    /**
47
 
     * Asigna la metadata
48
 
     *
49
 
     * @param array $metadata
50
 
     **/
51
 
    public function setMetadata($metadata)
52
 
    {
53
 
        $this->_metadata = $metadata;
54
 
    }
55
 
    
56
 
    /**
57
 
     * Obtiene la metadata de un campo especifico
58
 
     *
59
 
     * @param string $field nombre de campo
60
 
     * @return array metadatos
61
 
     **/
62
 
    public function getField($field)
63
 
    {
64
 
        if(!isset($this->_metadata[$field])) {
65
 
            throw new KumbiaException("No existe la metadata para el campo $field");
66
 
        }
67
 
        
68
 
        return $this->_metadata[$field];
69
 
    }
70
 
    
71
 
    /**
72
 
     * Verifica si los metadatos estan cargados
73
 
     *
74
 
     * @return boolean
75
 
     **/
76
 
    public function isLoaded()
77
 
    {
78
 
        return !is_null($this->_metadata);
79
 
    }
80
 
    
81
 
    /**
82
 
     * Obtiene una instancia de la metadata para la tabla
83
 
     *
84
 
     * @param string $connection conexion a la bd
85
 
     * @param string $schema esquema de tabla
86
 
     * @param string $table nombre de tabla
87
 
     * @return TableMetaData
88
 
     **/
89
 
    public static function getInstance($connection, $schema, $table)
90
 
    {
91
 
        if(!isset(self::$_instances[$connection][$schema][$table])) {
92
 
            self::$_instances[$connection][$schema][$table] =  new self();
93
 
        }
94
 
        
95
 
        return self::$_instances[$connection][$schema][$table];
96
 
    }
97
 
}
 
 
b'\\ No newline at end of file'