添加 Piwik 到代码库中。
+YUCHENG HU+ git-svn-id: https://svn.code.sf.net/p/hawebs/svn@442 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Exception
|
||||
*/
|
||||
// require_once 'Zend/Exception.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Config_Exception extends Zend_Exception {}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Writer.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Config_Writer
|
||||
{
|
||||
/**
|
||||
* Option keys to skip when calling setOptions()
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_skipOptions = array(
|
||||
'options'
|
||||
);
|
||||
|
||||
/**
|
||||
* Config object to write
|
||||
*
|
||||
* @var Zend_Config
|
||||
*/
|
||||
protected $_config = null;
|
||||
|
||||
/**
|
||||
* Create a new adapter
|
||||
*
|
||||
* $options can only be passed as array or be omitted
|
||||
*
|
||||
* @param null|array $options
|
||||
*/
|
||||
public function __construct(array $options = null)
|
||||
{
|
||||
if (is_array($options)) {
|
||||
$this->setOptions($options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set options via a Zend_Config instance
|
||||
*
|
||||
* @param Zend_Config $config
|
||||
* @return Zend_Config_Writer
|
||||
*/
|
||||
public function setConfig(Zend_Config $config)
|
||||
{
|
||||
$this->_config = $config;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set options via an array
|
||||
*
|
||||
* @param array $options
|
||||
* @return Zend_Config_Writer
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
foreach ($options as $key => $value) {
|
||||
if (in_array(strtolower($key), $this->_skipOptions)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$method = 'set' . ucfirst($key);
|
||||
if (method_exists($this, $method)) {
|
||||
$this->$method($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a Zend_Config object to it's target
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract public function write();
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Array.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Config_Writer
|
||||
*/
|
||||
// require_once 'Zend/Config/Writer/FileAbstract.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Config_Writer_Array extends Zend_Config_Writer_FileAbstract
|
||||
{
|
||||
/**
|
||||
* Render a Zend_Config into a PHP Array config string.
|
||||
*
|
||||
* @since 1.10
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$data = $this->_config->toArray();
|
||||
$sectionName = $this->_config->getSectionName();
|
||||
|
||||
if (is_string($sectionName)) {
|
||||
$data = array($sectionName => $data);
|
||||
}
|
||||
|
||||
$arrayString = "<?php\n"
|
||||
. "return " . var_export($data, true) . ";\n";
|
||||
|
||||
return $arrayString;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Config
|
||||
* @package Writer
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
// require_once "Zend/Config/Writer.php";
|
||||
|
||||
/**
|
||||
* Abstract File Writer
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_package
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: FileAbstract.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
class Zend_Config_Writer_FileAbstract extends Zend_Config_Writer
|
||||
{
|
||||
/**
|
||||
* Filename to write to
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_filename = null;
|
||||
|
||||
/**
|
||||
* Wether to exclusively lock the file or not
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_exclusiveLock = false;
|
||||
|
||||
/**
|
||||
* Set the target filename
|
||||
*
|
||||
* @param string $filename
|
||||
* @return Zend_Config_Writer_Array
|
||||
*/
|
||||
public function setFilename($filename)
|
||||
{
|
||||
$this->_filename = $filename;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set wether to exclusively lock the file or not
|
||||
*
|
||||
* @param boolean $exclusiveLock
|
||||
* @return Zend_Config_Writer_Array
|
||||
*/
|
||||
public function setExclusiveLock($exclusiveLock)
|
||||
{
|
||||
$this->_exclusiveLock = $exclusiveLock;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write configuration to file.
|
||||
*
|
||||
* @param string $filename
|
||||
* @param Zend_Config $config
|
||||
* @param bool $exclusiveLock
|
||||
* @return void
|
||||
*/
|
||||
public function write($filename = null, Zend_Config $config = null, $exclusiveLock = null)
|
||||
{
|
||||
if ($filename !== null) {
|
||||
$this->setFilename($filename);
|
||||
}
|
||||
|
||||
if ($config !== null) {
|
||||
$this->setConfig($config);
|
||||
}
|
||||
|
||||
if ($exclusiveLock !== null) {
|
||||
$this->setExclusiveLock($exclusiveLock);
|
||||
}
|
||||
|
||||
if ($this->_filename === null) {
|
||||
// require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception('No filename was set');
|
||||
}
|
||||
|
||||
if ($this->_config === null) {
|
||||
// require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception('No config was set');
|
||||
}
|
||||
|
||||
$configString = $this->render();
|
||||
|
||||
$flags = 0;
|
||||
|
||||
if ($this->_exclusiveLock) {
|
||||
$flags |= LOCK_EX;
|
||||
}
|
||||
|
||||
$result = @file_put_contents($this->_filename, $configString, $flags);
|
||||
|
||||
if ($result === false) {
|
||||
// require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception('Could not write to file "' . $this->_filename . '"');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a Zend_Config into a config file string.
|
||||
*
|
||||
* @since 1.10
|
||||
* @todo For 2.0 this should be redone into an abstract method.
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Ini.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Config_Writer
|
||||
*/
|
||||
// require_once 'Zend/Config/Writer/FileAbstract.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Config_Writer_Ini extends Zend_Config_Writer_FileAbstract
|
||||
{
|
||||
/**
|
||||
* String that separates nesting levels of configuration data identifiers
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_nestSeparator = '.';
|
||||
|
||||
/**
|
||||
* If true the ini string is rendered in the global namespace without sections.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_renderWithoutSections = false;
|
||||
|
||||
/**
|
||||
* Set the nest separator
|
||||
*
|
||||
* @param string $filename
|
||||
* @return Zend_Config_Writer_Ini
|
||||
*/
|
||||
public function setNestSeparator($separator)
|
||||
{
|
||||
$this->_nestSeparator = $separator;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if rendering should occour without sections or not.
|
||||
*
|
||||
* If set to true, the INI file is rendered without sections completely
|
||||
* into the global namespace of the INI file.
|
||||
*
|
||||
* @param bool $withoutSections
|
||||
* @return Zend_Config_Writer_Ini
|
||||
*/
|
||||
public function setRenderWithoutSections($withoutSections=true)
|
||||
{
|
||||
$this->_renderWithoutSections = (bool)$withoutSections;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a Zend_Config into a INI config string.
|
||||
*
|
||||
* @since 1.10
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$iniString = '';
|
||||
$extends = $this->_config->getExtends();
|
||||
$sectionName = $this->_config->getSectionName();
|
||||
|
||||
if($this->_renderWithoutSections == true) {
|
||||
$iniString .= $this->_addBranch($this->_config);
|
||||
} else if (is_string($sectionName)) {
|
||||
$iniString .= '[' . $sectionName . ']' . "\n"
|
||||
. $this->_addBranch($this->_config)
|
||||
. "\n";
|
||||
} else {
|
||||
foreach ($this->_config as $sectionName => $data) {
|
||||
if (!($data instanceof Zend_Config)) {
|
||||
$iniString .= $sectionName
|
||||
. ' = '
|
||||
. $this->_prepareValue($data)
|
||||
. "\n";
|
||||
} else {
|
||||
if (isset($extends[$sectionName])) {
|
||||
$sectionName .= ' : ' . $extends[$sectionName];
|
||||
}
|
||||
|
||||
$iniString .= '[' . $sectionName . ']' . "\n"
|
||||
. $this->_addBranch($data)
|
||||
. "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $iniString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a branch to an INI string recursively
|
||||
*
|
||||
* @param Zend_Config $config
|
||||
* @return void
|
||||
*/
|
||||
protected function _addBranch(Zend_Config $config, $parents = array())
|
||||
{
|
||||
$iniString = '';
|
||||
|
||||
foreach ($config as $key => $value) {
|
||||
$group = array_merge($parents, array($key));
|
||||
|
||||
if ($value instanceof Zend_Config) {
|
||||
$iniString .= $this->_addBranch($value, $group);
|
||||
} else {
|
||||
$iniString .= implode($this->_nestSeparator, $group)
|
||||
. ' = '
|
||||
. $this->_prepareValue($value)
|
||||
. "\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $iniString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare a value for INI
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
protected function _prepareValue($value)
|
||||
{
|
||||
if (is_integer($value) || is_float($value)) {
|
||||
return $value;
|
||||
} elseif (is_bool($value)) {
|
||||
return ($value ? 'true' : 'false');
|
||||
} elseif (strpos($value, '"') === false) {
|
||||
return '"' . $value . '"';
|
||||
} else {
|
||||
/** @see Zend_Config_Exception */
|
||||
// require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception('Value can not contain double quotes "');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Xml.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Config_Writer
|
||||
*/
|
||||
// require_once 'Zend/Config/Writer/FileAbstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Config_Xml
|
||||
*/
|
||||
// require_once 'Zend/Config/Xml.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Config_Writer_Xml extends Zend_Config_Writer_FileAbstract
|
||||
{
|
||||
/**
|
||||
* Render a Zend_Config into a XML config string.
|
||||
*
|
||||
* @since 1.10
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$xml = new SimpleXMLElement('<zend-config xmlns:zf="' . Zend_Config_Xml::XML_NAMESPACE . '"/>');
|
||||
$extends = $this->_config->getExtends();
|
||||
$sectionName = $this->_config->getSectionName();
|
||||
|
||||
if (is_string($sectionName)) {
|
||||
$child = $xml->addChild($sectionName);
|
||||
|
||||
$this->_addBranch($this->_config, $child, $xml);
|
||||
} else {
|
||||
foreach ($this->_config as $sectionName => $data) {
|
||||
if (!($data instanceof Zend_Config)) {
|
||||
$xml->addChild($sectionName, (string) $data);
|
||||
} else {
|
||||
$child = $xml->addChild($sectionName);
|
||||
|
||||
if (isset($extends[$sectionName])) {
|
||||
$child->addAttribute('zf:extends', $extends[$sectionName], Zend_Config_Xml::XML_NAMESPACE);
|
||||
}
|
||||
|
||||
$this->_addBranch($data, $child, $xml);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dom = dom_import_simplexml($xml)->ownerDocument;
|
||||
$dom->formatOutput = true;
|
||||
|
||||
$xmlString = $dom->saveXML();
|
||||
|
||||
return $xmlString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a branch to an XML object recursively
|
||||
*
|
||||
* @param Zend_Config $config
|
||||
* @param SimpleXMLElement $xml
|
||||
* @param SimpleXMLElement $parent
|
||||
* @return void
|
||||
*/
|
||||
protected function _addBranch(Zend_Config $config, SimpleXMLElement $xml, SimpleXMLElement $parent)
|
||||
{
|
||||
$branchType = null;
|
||||
|
||||
foreach ($config as $key => $value) {
|
||||
if ($branchType === null) {
|
||||
if (is_numeric($key)) {
|
||||
$branchType = 'numeric';
|
||||
$branchName = $xml->getName();
|
||||
$xml = $parent;
|
||||
|
||||
unset($parent->{$branchName});
|
||||
} else {
|
||||
$branchType = 'string';
|
||||
}
|
||||
} else if ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
|
||||
// require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception('Mixing of string and numeric keys is not allowed');
|
||||
}
|
||||
|
||||
if ($branchType === 'numeric') {
|
||||
if ($value instanceof Zend_Config) {
|
||||
$child = $parent->addChild($branchName);
|
||||
|
||||
$this->_addBranch($value, $child, $parent);
|
||||
} else {
|
||||
$parent->addChild($branchName, (string) $value);
|
||||
}
|
||||
} else {
|
||||
if ($value instanceof Zend_Config) {
|
||||
$child = $xml->addChild($key);
|
||||
|
||||
$this->_addBranch($value, $child, $xml);
|
||||
} else {
|
||||
$xml->addChild($key, (string) $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Xml.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Config
|
||||
*/
|
||||
// require_once 'Zend/Config.php';
|
||||
|
||||
/**
|
||||
* XML Adapter for Zend_Config
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Config
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Config_Xml extends Zend_Config
|
||||
{
|
||||
/**
|
||||
* XML namespace for ZF-related tags and attributes
|
||||
*/
|
||||
const XML_NAMESPACE = 'http://framework.zend.com/xml/zend-config-xml/1.0/';
|
||||
|
||||
/**
|
||||
* Whether to skip extends or not
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_skipExtends = false;
|
||||
|
||||
/**
|
||||
* Loads the section $section from the config file (or string $xml for
|
||||
* access facilitated by nested object properties.
|
||||
*
|
||||
* Sections are defined in the XML as children of the root element.
|
||||
*
|
||||
* In order to extend another section, a section defines the "extends"
|
||||
* attribute having a value of the section name from which the extending
|
||||
* section inherits values.
|
||||
*
|
||||
* Note that the keys in $section will override any keys of the same
|
||||
* name in the sections that have been included via "extends".
|
||||
*
|
||||
* @param string $xml XML file or string to process
|
||||
* @param mixed $section Section to process
|
||||
* @param boolean $options Whether modifications are allowed at runtime
|
||||
* @throws Zend_Config_Exception When xml is not set or cannot be loaded
|
||||
* @throws Zend_Config_Exception When section $sectionName cannot be found in $xml
|
||||
*/
|
||||
public function __construct($xml, $section = null, $options = false)
|
||||
{
|
||||
if (empty($xml)) {
|
||||
// require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception('Filename is not set');
|
||||
}
|
||||
|
||||
$allowModifications = false;
|
||||
if (is_bool($options)) {
|
||||
$allowModifications = $options;
|
||||
} elseif (is_array($options)) {
|
||||
if (isset($options['allowModifications'])) {
|
||||
$allowModifications = (bool) $options['allowModifications'];
|
||||
}
|
||||
if (isset($options['skipExtends'])) {
|
||||
$this->_skipExtends = (bool) $options['skipExtends'];
|
||||
}
|
||||
}
|
||||
|
||||
set_error_handler(array($this, '_loadFileErrorHandler')); // Warnings and errors are suppressed
|
||||
if (strstr($xml, '<?xml')) {
|
||||
$config = simplexml_load_string($xml);
|
||||
} else {
|
||||
$config = simplexml_load_file($xml);
|
||||
}
|
||||
|
||||
restore_error_handler();
|
||||
// Check if there was a error while loading file
|
||||
if ($this->_loadFileErrorStr !== null) {
|
||||
// require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception($this->_loadFileErrorStr);
|
||||
}
|
||||
|
||||
if ($section === null) {
|
||||
$dataArray = array();
|
||||
foreach ($config as $sectionName => $sectionData) {
|
||||
$dataArray[$sectionName] = $this->_processExtends($config, $sectionName);
|
||||
}
|
||||
|
||||
parent::__construct($dataArray, $allowModifications);
|
||||
} else if (is_array($section)) {
|
||||
$dataArray = array();
|
||||
foreach ($section as $sectionName) {
|
||||
if (!isset($config->$sectionName)) {
|
||||
// require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception("Section '$sectionName' cannot be found in $xml");
|
||||
}
|
||||
|
||||
$dataArray = array_merge($this->_processExtends($config, $sectionName), $dataArray);
|
||||
}
|
||||
|
||||
parent::__construct($dataArray, $allowModifications);
|
||||
} else {
|
||||
if (!isset($config->$section)) {
|
||||
// require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception("Section '$section' cannot be found in $xml");
|
||||
}
|
||||
|
||||
$dataArray = $this->_processExtends($config, $section);
|
||||
if (!is_array($dataArray)) {
|
||||
// Section in the XML file contains just one top level string
|
||||
$dataArray = array($section => $dataArray);
|
||||
}
|
||||
|
||||
parent::__construct($dataArray, $allowModifications);
|
||||
}
|
||||
|
||||
$this->_loadedSection = $section;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to process each element in the section and handle
|
||||
* the "extends" inheritance attribute.
|
||||
*
|
||||
* @param SimpleXMLElement $element XML Element to process
|
||||
* @param string $section Section to process
|
||||
* @param array $config Configuration which was parsed yet
|
||||
* @throws Zend_Config_Exception When $section cannot be found
|
||||
* @return array
|
||||
*/
|
||||
protected function _processExtends(SimpleXMLElement $element, $section, array $config = array())
|
||||
{
|
||||
if (!isset($element->$section)) {
|
||||
// require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception("Section '$section' cannot be found");
|
||||
}
|
||||
|
||||
$thisSection = $element->$section;
|
||||
$nsAttributes = $thisSection->attributes(self::XML_NAMESPACE);
|
||||
|
||||
if (isset($thisSection['extends']) || isset($nsAttributes['extends'])) {
|
||||
$extendedSection = (string) (isset($nsAttributes['extends']) ? $nsAttributes['extends'] : $thisSection['extends']);
|
||||
$this->_assertValidExtend($section, $extendedSection);
|
||||
|
||||
if (!$this->_skipExtends) {
|
||||
$config = $this->_processExtends($element, $extendedSection, $config);
|
||||
}
|
||||
}
|
||||
|
||||
$config = $this->_arrayMergeRecursive($config, $this->_toArray($thisSection));
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string or an associative and possibly multidimensional array from
|
||||
* a SimpleXMLElement.
|
||||
*
|
||||
* @param SimpleXMLElement $xmlObject Convert a SimpleXMLElement into an array
|
||||
* @return array|string
|
||||
*/
|
||||
protected function _toArray(SimpleXMLElement $xmlObject)
|
||||
{
|
||||
$config = array();
|
||||
$nsAttributes = $xmlObject->attributes(self::XML_NAMESPACE);
|
||||
|
||||
// Search for parent node values
|
||||
if (count($xmlObject->attributes()) > 0) {
|
||||
foreach ($xmlObject->attributes() as $key => $value) {
|
||||
if ($key === 'extends') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = (string) $value;
|
||||
|
||||
if (array_key_exists($key, $config)) {
|
||||
if (!is_array($config[$key])) {
|
||||
$config[$key] = array($config[$key]);
|
||||
}
|
||||
|
||||
$config[$key][] = $value;
|
||||
} else {
|
||||
$config[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Search for local 'const' nodes and replace them
|
||||
if (count($xmlObject->children(self::XML_NAMESPACE)) > 0) {
|
||||
if (count($xmlObject->children()) > 0) {
|
||||
// require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception("A node with a 'const' childnode may not have any other children");
|
||||
}
|
||||
|
||||
$dom = dom_import_simplexml($xmlObject);
|
||||
$namespaceChildNodes = array();
|
||||
|
||||
// We have to store them in an array, as replacing nodes will
|
||||
// confuse the DOMNodeList later
|
||||
foreach ($dom->childNodes as $node) {
|
||||
if ($node instanceof DOMElement && $node->namespaceURI === self::XML_NAMESPACE) {
|
||||
$namespaceChildNodes[] = $node;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($namespaceChildNodes as $node) {
|
||||
switch ($node->localName) {
|
||||
case 'const':
|
||||
if (!$node->hasAttributeNS(self::XML_NAMESPACE, 'name')) {
|
||||
// require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception("Misssing 'name' attribute in 'const' node");
|
||||
}
|
||||
|
||||
$constantName = $node->getAttributeNS(self::XML_NAMESPACE, 'name');
|
||||
|
||||
if (!defined($constantName)) {
|
||||
// require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception("Constant with name '$constantName' was not defined");
|
||||
}
|
||||
|
||||
$constantValue = constant($constantName);
|
||||
|
||||
$dom->replaceChild($dom->ownerDocument->createTextNode($constantValue), $node);
|
||||
break;
|
||||
|
||||
default:
|
||||
// require_once 'Zend/Config/Exception.php';
|
||||
throw new Zend_Config_Exception("Unknown node with name '$node->localName' found");
|
||||
}
|
||||
}
|
||||
|
||||
return (string) simplexml_import_dom($dom);
|
||||
}
|
||||
|
||||
// Search for children
|
||||
if (count($xmlObject->children()) > 0) {
|
||||
foreach ($xmlObject->children() as $key => $value) {
|
||||
if (count($value->children()) > 0 || count($value->children(self::XML_NAMESPACE)) > 0) {
|
||||
$value = $this->_toArray($value);
|
||||
} else if (count($value->attributes()) > 0) {
|
||||
$attributes = $value->attributes();
|
||||
if (isset($attributes['value'])) {
|
||||
$value = (string) $attributes['value'];
|
||||
} else {
|
||||
$value = $this->_toArray($value);
|
||||
}
|
||||
} else {
|
||||
$value = (string) $value;
|
||||
}
|
||||
|
||||
if (array_key_exists($key, $config)) {
|
||||
if (!is_array($config[$key]) || !array_key_exists(0, $config[$key])) {
|
||||
$config[$key] = array($config[$key]);
|
||||
}
|
||||
|
||||
$config[$key][] = $value;
|
||||
} else {
|
||||
$config[$key] = $value;
|
||||
}
|
||||
}
|
||||
} else if (!isset($xmlObject['extends']) && !isset($nsAttributes['extends']) && (count($config) === 0)) {
|
||||
// Object has no children nor attributes and doesn't use the extends
|
||||
// attribute: it's a string
|
||||
$config = (string) $xmlObject;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Zend_Db_Adapter_Exception
|
||||
*/
|
||||
// require_once 'Zend/Db/Adapter/Exception.php';
|
||||
|
||||
/**
|
||||
* Zend_Db_Adapter_Db2_Exception
|
||||
*
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Db2_Exception extends Zend_Db_Adapter_Exception
|
||||
{
|
||||
protected $code = '00000';
|
||||
protected $message = 'unknown exception';
|
||||
|
||||
function __construct($message = 'unknown exception', $code = '00000', Exception $e = null)
|
||||
{
|
||||
parent::__construct($message, $code, $e);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Zend_Db_Exception
|
||||
*/
|
||||
// require_once 'Zend/Db/Exception.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Exception extends Zend_Db_Exception
|
||||
{
|
||||
protected $_chainedException = null;
|
||||
|
||||
public function __construct($message = '', $code = 0, Exception $e = null)
|
||||
{
|
||||
if ($e && (0 === $code)) {
|
||||
$code = $e->getCode();
|
||||
}
|
||||
parent::__construct($message, $code, $e);
|
||||
}
|
||||
|
||||
public function hasChainedException()
|
||||
{
|
||||
return ($this->_previous !== null);
|
||||
}
|
||||
|
||||
public function getChainedException()
|
||||
{
|
||||
return $this->getPrevious();
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Zend
|
||||
*/
|
||||
// require_once 'Zend/Db/Adapter/Exception.php';
|
||||
|
||||
/**
|
||||
* Zend_Db_Adapter_Mysqli_Exception
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Mysqli_Exception extends Zend_Db_Adapter_Exception
|
||||
{
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Zend_Db_Adapter_Exception
|
||||
*/
|
||||
// require_once 'Zend/Db/Adapter/Exception.php';
|
||||
|
||||
/**
|
||||
* Zend_Db_Adapter_Oracle_Exception
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Oracle_Exception extends Zend_Db_Adapter_Exception
|
||||
{
|
||||
protected $message = 'Unknown exception';
|
||||
protected $code = 0;
|
||||
|
||||
function __construct($error = null, $code = 0) {
|
||||
if (is_array($error)) {
|
||||
if (!isset($error['offset'])) {
|
||||
$this->message = $error['code'] .' '. $error['message'];
|
||||
} else {
|
||||
$this->message = $error['code'] .' '. $error['message']." "
|
||||
. substr($error['sqltext'], 0, $error['offset'])
|
||||
. "*"
|
||||
. substr($error['sqltext'], $error['offset']);
|
||||
}
|
||||
$this->code = $error['code'];
|
||||
} else if (is_string($error)) {
|
||||
$this->message = $error;
|
||||
}
|
||||
if (!$this->code && $code) {
|
||||
$this->code = $code;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,228 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Db2.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
|
||||
/** @see Zend_Db_Adapter_Pdo_Ibm */
|
||||
// require_once 'Zend/Db/Adapter/Pdo/Ibm.php';
|
||||
|
||||
/** @see Zend_Db_Statement_Pdo_Ibm */
|
||||
// require_once 'Zend/Db/Statement/Pdo/Ibm.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Pdo_Ibm_Db2
|
||||
{
|
||||
/**
|
||||
* @var Zend_Db_Adapter_Abstract
|
||||
*/
|
||||
protected $_adapter = null;
|
||||
|
||||
/**
|
||||
* Construct the data server class.
|
||||
*
|
||||
* It will be used to generate non-generic SQL
|
||||
* for a particular data server
|
||||
*
|
||||
* @param Zend_Db_Adapter_Abstract $adapter
|
||||
*/
|
||||
public function __construct($adapter)
|
||||
{
|
||||
$this->_adapter = $adapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the tables in the database.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listTables()
|
||||
{
|
||||
$sql = "SELECT tabname "
|
||||
. "FROM SYSCAT.TABLES ";
|
||||
return $this->_adapter->fetchCol($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* DB2 catalog lookup for describe table
|
||||
*
|
||||
* @param string $tableName
|
||||
* @param string $schemaName OPTIONAL
|
||||
* @return array
|
||||
*/
|
||||
public function describeTable($tableName, $schemaName = null)
|
||||
{
|
||||
$sql = "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno,
|
||||
c.typename, c.default, c.nulls, c.length, c.scale,
|
||||
c.identity, tc.type AS tabconsttype, k.colseq
|
||||
FROM syscat.columns c
|
||||
LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc
|
||||
ON (k.tabschema = tc.tabschema
|
||||
AND k.tabname = tc.tabname
|
||||
AND tc.type = 'P'))
|
||||
ON (c.tabschema = k.tabschema
|
||||
AND c.tabname = k.tabname
|
||||
AND c.colname = k.colname)
|
||||
WHERE "
|
||||
. $this->_adapter->quoteInto('UPPER(c.tabname) = UPPER(?)', $tableName);
|
||||
if ($schemaName) {
|
||||
$sql .= $this->_adapter->quoteInto(' AND UPPER(c.tabschema) = UPPER(?)', $schemaName);
|
||||
}
|
||||
$sql .= " ORDER BY c.colno";
|
||||
|
||||
$desc = array();
|
||||
$stmt = $this->_adapter->query($sql);
|
||||
|
||||
/**
|
||||
* To avoid case issues, fetch using FETCH_NUM
|
||||
*/
|
||||
$result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
|
||||
|
||||
/**
|
||||
* The ordering of columns is defined by the query so we can map
|
||||
* to variables to improve readability
|
||||
*/
|
||||
$tabschema = 0;
|
||||
$tabname = 1;
|
||||
$colname = 2;
|
||||
$colno = 3;
|
||||
$typename = 4;
|
||||
$default = 5;
|
||||
$nulls = 6;
|
||||
$length = 7;
|
||||
$scale = 8;
|
||||
$identityCol = 9;
|
||||
$tabconstype = 10;
|
||||
$colseq = 11;
|
||||
|
||||
foreach ($result as $key => $row) {
|
||||
list ($primary, $primaryPosition, $identity) = array(false, null, false);
|
||||
if ($row[$tabconstype] == 'P') {
|
||||
$primary = true;
|
||||
$primaryPosition = $row[$colseq];
|
||||
}
|
||||
/**
|
||||
* In IBM DB2, an column can be IDENTITY
|
||||
* even if it is not part of the PRIMARY KEY.
|
||||
*/
|
||||
if ($row[$identityCol] == 'Y') {
|
||||
$identity = true;
|
||||
}
|
||||
|
||||
$desc[$this->_adapter->foldCase($row[$colname])] = array(
|
||||
'SCHEMA_NAME' => $this->_adapter->foldCase($row[$tabschema]),
|
||||
'TABLE_NAME' => $this->_adapter->foldCase($row[$tabname]),
|
||||
'COLUMN_NAME' => $this->_adapter->foldCase($row[$colname]),
|
||||
'COLUMN_POSITION' => $row[$colno]+1,
|
||||
'DATA_TYPE' => $row[$typename],
|
||||
'DEFAULT' => $row[$default],
|
||||
'NULLABLE' => (bool) ($row[$nulls] == 'Y'),
|
||||
'LENGTH' => $row[$length],
|
||||
'SCALE' => $row[$scale],
|
||||
'PRECISION' => ($row[$typename] == 'DECIMAL' ? $row[$length] : 0),
|
||||
'UNSIGNED' => false,
|
||||
'PRIMARY' => $primary,
|
||||
'PRIMARY_POSITION' => $primaryPosition,
|
||||
'IDENTITY' => $identity
|
||||
);
|
||||
}
|
||||
|
||||
return $desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a DB2-specific LIMIT clause to the SELECT statement.
|
||||
*
|
||||
* @param string $sql
|
||||
* @param integer $count
|
||||
* @param integer $offset OPTIONAL
|
||||
* @throws Zend_Db_Adapter_Exception
|
||||
* @return string
|
||||
*/
|
||||
public function limit($sql, $count, $offset = 0)
|
||||
{
|
||||
$count = intval($count);
|
||||
if ($count < 0) {
|
||||
/** @see Zend_Db_Adapter_Exception */
|
||||
// require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
|
||||
} else {
|
||||
$offset = intval($offset);
|
||||
if ($offset < 0) {
|
||||
/** @see Zend_Db_Adapter_Exception */
|
||||
// require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
|
||||
}
|
||||
|
||||
if ($offset == 0 && $count > 0) {
|
||||
$limit_sql = $sql . " FETCH FIRST $count ROWS ONLY";
|
||||
return $limit_sql;
|
||||
}
|
||||
/**
|
||||
* DB2 does not implement the LIMIT clause as some RDBMS do.
|
||||
* We have to simulate it with subqueries and ROWNUM.
|
||||
* Unfortunately because we use the column wildcard "*",
|
||||
* this puts an extra column into the query result set.
|
||||
*/
|
||||
$limit_sql = "SELECT z2.*
|
||||
FROM (
|
||||
SELECT ROW_NUMBER() OVER() AS \"ZEND_DB_ROWNUM\", z1.*
|
||||
FROM (
|
||||
" . $sql . "
|
||||
) z1
|
||||
) z2
|
||||
WHERE z2.zend_db_rownum BETWEEN " . ($offset+1) . " AND " . ($offset+$count);
|
||||
}
|
||||
return $limit_sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* DB2-specific last sequence id
|
||||
*
|
||||
* @param string $sequenceName
|
||||
* @return integer
|
||||
*/
|
||||
public function lastSequenceId($sequenceName)
|
||||
{
|
||||
$sql = 'SELECT PREVVAL FOR '.$this->_adapter->quoteIdentifier($sequenceName).' AS VAL FROM SYSIBM.SYSDUMMY1';
|
||||
$value = $this->_adapter->fetchOne($sql);
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* DB2-specific sequence id value
|
||||
*
|
||||
* @param string $sequenceName
|
||||
* @return integer
|
||||
*/
|
||||
public function nextSequenceId($sequenceName)
|
||||
{
|
||||
$sql = 'SELECT NEXTVAL FOR '.$this->_adapter->quoteIdentifier($sequenceName).' AS VAL FROM SYSIBM.SYSDUMMY1';
|
||||
$value = $this->_adapter->fetchOne($sql);
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,257 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Mysql.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Db_Adapter_Pdo_Abstract
|
||||
*/
|
||||
// require_once 'Zend/Db/Adapter/Pdo/Abstract.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class for connecting to MySQL databases and performing common operations.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Pdo_Mysql extends Zend_Db_Adapter_Pdo_Abstract
|
||||
{
|
||||
|
||||
/**
|
||||
* PDO type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_pdoType = 'mysql';
|
||||
|
||||
/**
|
||||
* Keys are UPPERCASE SQL datatypes or the constants
|
||||
* Zend_Db::INT_TYPE, Zend_Db::BIGINT_TYPE, or Zend_Db::FLOAT_TYPE.
|
||||
*
|
||||
* Values are:
|
||||
* 0 = 32-bit integer
|
||||
* 1 = 64-bit integer
|
||||
* 2 = float or decimal
|
||||
*
|
||||
* @var array Associative array of datatypes to values 0, 1, or 2.
|
||||
*/
|
||||
protected $_numericDataTypes = array(
|
||||
Zend_Db::INT_TYPE => Zend_Db::INT_TYPE,
|
||||
Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
|
||||
Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
|
||||
'INT' => Zend_Db::INT_TYPE,
|
||||
'INTEGER' => Zend_Db::INT_TYPE,
|
||||
'MEDIUMINT' => Zend_Db::INT_TYPE,
|
||||
'SMALLINT' => Zend_Db::INT_TYPE,
|
||||
'TINYINT' => Zend_Db::INT_TYPE,
|
||||
'BIGINT' => Zend_Db::BIGINT_TYPE,
|
||||
'SERIAL' => Zend_Db::BIGINT_TYPE,
|
||||
'DEC' => Zend_Db::FLOAT_TYPE,
|
||||
'DECIMAL' => Zend_Db::FLOAT_TYPE,
|
||||
'DOUBLE' => Zend_Db::FLOAT_TYPE,
|
||||
'DOUBLE PRECISION' => Zend_Db::FLOAT_TYPE,
|
||||
'FIXED' => Zend_Db::FLOAT_TYPE,
|
||||
'FLOAT' => Zend_Db::FLOAT_TYPE
|
||||
);
|
||||
|
||||
/**
|
||||
* Creates a PDO object and connects to the database.
|
||||
*
|
||||
* @return void
|
||||
* @throws Zend_Db_Adapter_Exception
|
||||
*/
|
||||
protected function _connect()
|
||||
{
|
||||
if ($this->_connection) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($this->_config['charset'])) {
|
||||
$initCommand = "SET NAMES '" . $this->_config['charset'] . "'";
|
||||
$this->_config['driver_options'][1002] = $initCommand; // 1002 = PDO::MYSQL_ATTR_INIT_COMMAND
|
||||
}
|
||||
|
||||
parent::_connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getQuoteIdentifierSymbol()
|
||||
{
|
||||
return "`";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the tables in the database.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listTables()
|
||||
{
|
||||
return $this->fetchCol('SHOW TABLES');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the column descriptions for a table.
|
||||
*
|
||||
* The return value is an associative array keyed by the column name,
|
||||
* as returned by the RDBMS.
|
||||
*
|
||||
* The value of each array element is an associative array
|
||||
* with the following keys:
|
||||
*
|
||||
* SCHEMA_NAME => string; name of database or schema
|
||||
* TABLE_NAME => string;
|
||||
* COLUMN_NAME => string; column name
|
||||
* COLUMN_POSITION => number; ordinal position of column in table
|
||||
* DATA_TYPE => string; SQL datatype name of column
|
||||
* DEFAULT => string; default expression of column, null if none
|
||||
* NULLABLE => boolean; true if column can have nulls
|
||||
* LENGTH => number; length of CHAR/VARCHAR
|
||||
* SCALE => number; scale of NUMERIC/DECIMAL
|
||||
* PRECISION => number; precision of NUMERIC/DECIMAL
|
||||
* UNSIGNED => boolean; unsigned property of an integer type
|
||||
* PRIMARY => boolean; true if column is part of the primary key
|
||||
* PRIMARY_POSITION => integer; position of column in primary key
|
||||
* IDENTITY => integer; true if column is auto-generated with unique values
|
||||
*
|
||||
* @param string $tableName
|
||||
* @param string $schemaName OPTIONAL
|
||||
* @return array
|
||||
*/
|
||||
public function describeTable($tableName, $schemaName = null)
|
||||
{
|
||||
// @todo use INFORMATION_SCHEMA someday when MySQL's
|
||||
// implementation has reasonably good performance and
|
||||
// the version with this improvement is in wide use.
|
||||
|
||||
if ($schemaName) {
|
||||
$sql = 'DESCRIBE ' . $this->quoteIdentifier("$schemaName.$tableName", true);
|
||||
} else {
|
||||
$sql = 'DESCRIBE ' . $this->quoteIdentifier($tableName, true);
|
||||
}
|
||||
$stmt = $this->query($sql);
|
||||
|
||||
// Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
|
||||
$result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
|
||||
|
||||
$field = 0;
|
||||
$type = 1;
|
||||
$null = 2;
|
||||
$key = 3;
|
||||
$default = 4;
|
||||
$extra = 5;
|
||||
|
||||
$desc = array();
|
||||
$i = 1;
|
||||
$p = 1;
|
||||
foreach ($result as $row) {
|
||||
list($length, $scale, $precision, $unsigned, $primary, $primaryPosition, $identity)
|
||||
= array(null, null, null, null, false, null, false);
|
||||
if (preg_match('/unsigned/', $row[$type])) {
|
||||
$unsigned = true;
|
||||
}
|
||||
if (preg_match('/^((?:var)?char)\((\d+)\)/', $row[$type], $matches)) {
|
||||
$row[$type] = $matches[1];
|
||||
$length = $matches[2];
|
||||
} else if (preg_match('/^decimal\((\d+),(\d+)\)/', $row[$type], $matches)) {
|
||||
$row[$type] = 'decimal';
|
||||
$precision = $matches[1];
|
||||
$scale = $matches[2];
|
||||
} else if (preg_match('/^float\((\d+),(\d+)\)/', $row[$type], $matches)) {
|
||||
$row[$type] = 'float';
|
||||
$precision = $matches[1];
|
||||
$scale = $matches[2];
|
||||
} else if (preg_match('/^((?:big|medium|small|tiny)?int)\((\d+)\)/', $row[$type], $matches)) {
|
||||
$row[$type] = $matches[1];
|
||||
// The optional argument of a MySQL int type is not precision
|
||||
// or length; it is only a hint for display width.
|
||||
}
|
||||
if (strtoupper($row[$key]) == 'PRI') {
|
||||
$primary = true;
|
||||
$primaryPosition = $p;
|
||||
if ($row[$extra] == 'auto_increment') {
|
||||
$identity = true;
|
||||
} else {
|
||||
$identity = false;
|
||||
}
|
||||
++$p;
|
||||
}
|
||||
$desc[$this->foldCase($row[$field])] = array(
|
||||
'SCHEMA_NAME' => null, // @todo
|
||||
'TABLE_NAME' => $this->foldCase($tableName),
|
||||
'COLUMN_NAME' => $this->foldCase($row[$field]),
|
||||
'COLUMN_POSITION' => $i,
|
||||
'DATA_TYPE' => $row[$type],
|
||||
'DEFAULT' => $row[$default],
|
||||
'NULLABLE' => (bool) ($row[$null] == 'YES'),
|
||||
'LENGTH' => $length,
|
||||
'SCALE' => $scale,
|
||||
'PRECISION' => $precision,
|
||||
'UNSIGNED' => $unsigned,
|
||||
'PRIMARY' => $primary,
|
||||
'PRIMARY_POSITION' => $primaryPosition,
|
||||
'IDENTITY' => $identity
|
||||
);
|
||||
++$i;
|
||||
}
|
||||
return $desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an adapter-specific LIMIT clause to the SELECT statement.
|
||||
*
|
||||
* @param string $sql
|
||||
* @param integer $count
|
||||
* @param integer $offset OPTIONAL
|
||||
* @throws Zend_Db_Adapter_Exception
|
||||
* @return string
|
||||
*/
|
||||
public function limit($sql, $count, $offset = 0)
|
||||
{
|
||||
$count = intval($count);
|
||||
if ($count <= 0) {
|
||||
/** @see Zend_Db_Adapter_Exception */
|
||||
// require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
|
||||
}
|
||||
|
||||
$offset = intval($offset);
|
||||
if ($offset < 0) {
|
||||
/** @see Zend_Db_Adapter_Exception */
|
||||
// require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
|
||||
}
|
||||
|
||||
$sql .= " LIMIT $count";
|
||||
if ($offset > 0) {
|
||||
$sql .= " OFFSET $offset";
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,297 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Sqlite.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Db_Adapter_Pdo_Abstract
|
||||
*/
|
||||
// require_once 'Zend/Db/Adapter/Pdo/Abstract.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class for connecting to SQLite2 and SQLite3 databases and performing common operations.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Pdo_Sqlite extends Zend_Db_Adapter_Pdo_Abstract
|
||||
{
|
||||
|
||||
/**
|
||||
* PDO type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_pdoType = 'sqlite';
|
||||
|
||||
/**
|
||||
* Keys are UPPERCASE SQL datatypes or the constants
|
||||
* Zend_Db::INT_TYPE, Zend_Db::BIGINT_TYPE, or Zend_Db::FLOAT_TYPE.
|
||||
*
|
||||
* Values are:
|
||||
* 0 = 32-bit integer
|
||||
* 1 = 64-bit integer
|
||||
* 2 = float or decimal
|
||||
*
|
||||
* @var array Associative array of datatypes to values 0, 1, or 2.
|
||||
*/
|
||||
protected $_numericDataTypes = array(
|
||||
Zend_Db::INT_TYPE => Zend_Db::INT_TYPE,
|
||||
Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
|
||||
Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
|
||||
'INTEGER' => Zend_Db::BIGINT_TYPE,
|
||||
'REAL' => Zend_Db::FLOAT_TYPE
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* $config is an array of key/value pairs containing configuration
|
||||
* options. Note that the SQLite options are different than most of
|
||||
* the other PDO adapters in that no username or password are needed.
|
||||
* Also, an extra config key "sqlite2" specifies compatibility mode.
|
||||
*
|
||||
* dbname => (string) The name of the database to user (required,
|
||||
* use :memory: for memory-based database)
|
||||
*
|
||||
* sqlite2 => (boolean) PDO_SQLITE defaults to SQLite 3. For compatibility
|
||||
* with an older SQLite 2 database, set this to TRUE.
|
||||
*
|
||||
* @param array $config An array of configuration keys.
|
||||
*/
|
||||
public function __construct(array $config = array())
|
||||
{
|
||||
if (isset($config['sqlite2']) && $config['sqlite2']) {
|
||||
$this->_pdoType = 'sqlite2';
|
||||
}
|
||||
|
||||
// SQLite uses no username/password. Stub to satisfy parent::_connect()
|
||||
$this->_config['username'] = null;
|
||||
$this->_config['password'] = null;
|
||||
|
||||
return parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for config options that are mandatory.
|
||||
* Throw exceptions if any are missing.
|
||||
*
|
||||
* @param array $config
|
||||
* @throws Zend_Db_Adapter_Exception
|
||||
*/
|
||||
protected function _checkRequiredOptions(array $config)
|
||||
{
|
||||
// we need at least a dbname
|
||||
if (! array_key_exists('dbname', $config)) {
|
||||
/** @see Zend_Db_Adapter_Exception */
|
||||
// require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'dbname' that names the database instance");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DSN builder
|
||||
*/
|
||||
protected function _dsn()
|
||||
{
|
||||
return $this->_pdoType .':'. $this->_config['dbname'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Special configuration for SQLite behavior: make sure that result sets
|
||||
* contain keys like 'column' instead of 'table.column'.
|
||||
*
|
||||
* @throws Zend_Db_Adapter_Exception
|
||||
*/
|
||||
protected function _connect()
|
||||
{
|
||||
/**
|
||||
* if we already have a PDO object, no need to re-connect.
|
||||
*/
|
||||
if ($this->_connection) {
|
||||
return;
|
||||
}
|
||||
|
||||
parent::_connect();
|
||||
|
||||
$retval = $this->_connection->exec('PRAGMA full_column_names=0');
|
||||
if ($retval === false) {
|
||||
$error = $this->_connection->errorInfo();
|
||||
/** @see Zend_Db_Adapter_Exception */
|
||||
// require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception($error[2]);
|
||||
}
|
||||
|
||||
$retval = $this->_connection->exec('PRAGMA short_column_names=1');
|
||||
if ($retval === false) {
|
||||
$error = $this->_connection->errorInfo();
|
||||
/** @see Zend_Db_Adapter_Exception */
|
||||
// require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception($error[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the tables in the database.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listTables()
|
||||
{
|
||||
$sql = "SELECT name FROM sqlite_master WHERE type='table' "
|
||||
. "UNION ALL SELECT name FROM sqlite_temp_master "
|
||||
. "WHERE type='table' ORDER BY name";
|
||||
|
||||
return $this->fetchCol($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the column descriptions for a table.
|
||||
*
|
||||
* The return value is an associative array keyed by the column name,
|
||||
* as returned by the RDBMS.
|
||||
*
|
||||
* The value of each array element is an associative array
|
||||
* with the following keys:
|
||||
*
|
||||
* SCHEMA_NAME => string; name of database or schema
|
||||
* TABLE_NAME => string;
|
||||
* COLUMN_NAME => string; column name
|
||||
* COLUMN_POSITION => number; ordinal position of column in table
|
||||
* DATA_TYPE => string; SQL datatype name of column
|
||||
* DEFAULT => string; default expression of column, null if none
|
||||
* NULLABLE => boolean; true if column can have nulls
|
||||
* LENGTH => number; length of CHAR/VARCHAR
|
||||
* SCALE => number; scale of NUMERIC/DECIMAL
|
||||
* PRECISION => number; precision of NUMERIC/DECIMAL
|
||||
* UNSIGNED => boolean; unsigned property of an integer type
|
||||
* PRIMARY => boolean; true if column is part of the primary key
|
||||
* PRIMARY_POSITION => integer; position of column in primary key
|
||||
* IDENTITY => integer; true if column is auto-generated with unique values
|
||||
*
|
||||
* @param string $tableName
|
||||
* @param string $schemaName OPTIONAL
|
||||
* @return array
|
||||
*/
|
||||
public function describeTable($tableName, $schemaName = null)
|
||||
{
|
||||
$sql = 'PRAGMA ';
|
||||
|
||||
if ($schemaName) {
|
||||
$sql .= $this->quoteIdentifier($schemaName) . '.';
|
||||
}
|
||||
|
||||
$sql .= 'table_info('.$this->quoteIdentifier($tableName).')';
|
||||
|
||||
$stmt = $this->query($sql);
|
||||
|
||||
/**
|
||||
* Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
|
||||
*/
|
||||
$result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
|
||||
|
||||
$cid = 0;
|
||||
$name = 1;
|
||||
$type = 2;
|
||||
$notnull = 3;
|
||||
$dflt_value = 4;
|
||||
$pk = 5;
|
||||
|
||||
$desc = array();
|
||||
|
||||
$p = 1;
|
||||
foreach ($result as $key => $row) {
|
||||
list($length, $scale, $precision, $primary, $primaryPosition, $identity) =
|
||||
array(null, null, null, false, null, false);
|
||||
if (preg_match('/^((?:var)?char)\((\d+)\)/i', $row[$type], $matches)) {
|
||||
$row[$type] = $matches[1];
|
||||
$length = $matches[2];
|
||||
} else if (preg_match('/^decimal\((\d+),(\d+)\)/i', $row[$type], $matches)) {
|
||||
$row[$type] = 'DECIMAL';
|
||||
$precision = $matches[1];
|
||||
$scale = $matches[2];
|
||||
}
|
||||
if ((bool) $row[$pk]) {
|
||||
$primary = true;
|
||||
$primaryPosition = $p;
|
||||
/**
|
||||
* SQLite INTEGER primary key is always auto-increment.
|
||||
*/
|
||||
$identity = (bool) ($row[$type] == 'INTEGER');
|
||||
++$p;
|
||||
}
|
||||
$desc[$this->foldCase($row[$name])] = array(
|
||||
'SCHEMA_NAME' => $this->foldCase($schemaName),
|
||||
'TABLE_NAME' => $this->foldCase($tableName),
|
||||
'COLUMN_NAME' => $this->foldCase($row[$name]),
|
||||
'COLUMN_POSITION' => $row[$cid]+1,
|
||||
'DATA_TYPE' => $row[$type],
|
||||
'DEFAULT' => $row[$dflt_value],
|
||||
'NULLABLE' => ! (bool) $row[$notnull],
|
||||
'LENGTH' => $length,
|
||||
'SCALE' => $scale,
|
||||
'PRECISION' => $precision,
|
||||
'UNSIGNED' => null, // Sqlite3 does not support unsigned data
|
||||
'PRIMARY' => $primary,
|
||||
'PRIMARY_POSITION' => $primaryPosition,
|
||||
'IDENTITY' => $identity
|
||||
);
|
||||
}
|
||||
return $desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an adapter-specific LIMIT clause to the SELECT statement.
|
||||
*
|
||||
* @param string $sql
|
||||
* @param integer $count
|
||||
* @param integer $offset OPTIONAL
|
||||
* @return string
|
||||
*/
|
||||
public function limit($sql, $count, $offset = 0)
|
||||
{
|
||||
$count = intval($count);
|
||||
if ($count <= 0) {
|
||||
/** @see Zend_Db_Adapter_Exception */
|
||||
// require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
|
||||
}
|
||||
|
||||
$offset = intval($offset);
|
||||
if ($offset < 0) {
|
||||
/** @see Zend_Db_Adapter_Exception */
|
||||
// require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
|
||||
}
|
||||
|
||||
$sql .= " LIMIT $count";
|
||||
if ($offset > 0) {
|
||||
$sql .= " OFFSET $offset";
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20629 2010-01-25 21:17:23Z ralph $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Db_Adapter_Exception
|
||||
*/
|
||||
// require_once 'Zend/Db/Adapter/Exception.php';
|
||||
|
||||
/**
|
||||
* Zend_Db_Adapter_Sqlsrv_Exception
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Sqlsrv_Exception extends Zend_Db_Adapter_Exception
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* If $message is an array, the assumption is that the return value of
|
||||
* sqlsrv_errors() was provided. If so, it then retrieves the most recent
|
||||
* error from that stack, and sets the message and code based on it.
|
||||
*
|
||||
* @param null|array|string $message
|
||||
* @param null|int $code
|
||||
*/
|
||||
public function __construct($message = null, $code = 0)
|
||||
{
|
||||
if (is_array($message)) {
|
||||
// Error should be array of errors
|
||||
// We only need first one (?)
|
||||
if (isset($message[0])) {
|
||||
$message = $message[0];
|
||||
}
|
||||
|
||||
$code = (int) $message['code'];
|
||||
$message = (string) $message['message'];
|
||||
}
|
||||
parent::__construct($message, $code, new Exception($message, $code));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Zend_Exception
|
||||
*/
|
||||
// require_once 'Zend/Exception.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Exception extends Zend_Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to [email protected] so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Expr
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Expr.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class for SQL SELECT fragments.
|
||||
*
|
||||
* This class simply holds a string, so that fragments of SQL statements can be
|
||||
* distinguished from identifiers and values that should be implicitly quoted
|
||||
* when interpolated into SQL statements.
|
||||
*
|
||||
* For example, when specifying a primary key value when inserting into a new
|
||||
* row, some RDBMS brands may require you to use an expression to generate the
|
||||
* new value of a sequence. If this expression is treated as an identifier,
|
||||
* it will be quoted and the expression will not be evaluated. Another example
|
||||
* is that you can use Zend_Db_Expr in the Zend_Db_Select::order() method to
|
||||
* order by an expression instead of simply a column name.
|
||||
*
|
||||
* The way this works is that in each context in which a column name can be
|
||||
* specified to methods of Zend_Db classes, if the value is an instance of
|
||||
* Zend_Db_Expr instead of a plain string, then the expression is not quoted.
|
||||
* If it is a plain string, it is assumed to be a plain column name.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Expr
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Expr
|
||||
{
|
||||
/**
|
||||
* Storage for the SQL expression.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_expression;
|
||||
|
||||
/**
|
||||
* Instantiate an expression, which is just a string stored as
|
||||
* an instance member variable.
|
||||
*
|
||||
* @param string $expression The string containing a SQL expression.
|
||||
*/
|
||||
public function __construct($expression)
|
||||
{
|
||||
$this->_expression = (string) $expression;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string The string of the SQL expression stored in this object.
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->_expression;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user