本文整理汇总了PHP中Zend_Db_Table_Abstract::info方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Table_Abstract::info方法的具体用法?PHP Zend_Db_Table_Abstract::info怎么用?PHP Zend_Db_Table_Abstract::info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Table_Abstract
的用法示例。
在下文中一共展示了Zend_Db_Table_Abstract::info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Construct Dataset Table from Zend_Db_Table object
*
* @param Zend_Db_Table_Abstract $table
* @param string|Zend_Db_Select|null $where
* @param string|null $order
* @param int $count
* @param int $offset
*/
public function __construct(Zend_Db_Table_Abstract $table, $where = null, $order = null, $count = null, $offset = null)
{
$this->tableName = $table->info('name');
$this->_columns = $table->info('cols');
$this->_table = $table;
$this->_where = $where;
$this->_order = $order;
$this->_count = $count;
$this->_offset = $offset;
}
示例2: setModel
public function setModel(Zend_Db_Table_Abstract $model)
{
$this->_model = $model;
$this->_setPrimaryIndex($this->_model->getPrimaryIndex());
$info = $model->info();
$this->_columns = $info['cols'];
}
示例3: setTable
/**
* Set the table object, to re-establish a live connection
* to the database for a Row that has been de-serialized.
*
* @param Zend_Db_Table_Abstract $table
* @return boolean
* @throws Zend_Db_Table_Row_Exception
*/
public function setTable(Zend_Db_Table_Abstract $table = null)
{
if ($table == null) {
$this->_table = null;
$this->_connected = false;
return false;
}
$tableClass = get_class($table);
if (!$table instanceof $this->_tableClass) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception("The specified Table is of class {$tableClass}, expecting class to be instance of {$this->_tableClass}");
}
$this->_table = $table;
$this->_tableClass = $tableClass;
$info = $this->_table->info();
if ($info['cols'] != array_keys($this->_data)) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception('The specified Table does not have the same columns as the Row');
}
if (!array_intersect((array) $this->_primary, $info['primary']) == (array) $this->_primary) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception("The specified Table '{$tableClass}' does not have the same primary key as the Row");
}
$this->_connected = true;
return true;
}
示例4: __construct
/**
* Creating a query using a Model.
*
* @param Zend_Db_Table_Abstract $model
* @param array $relationmap Relation map for joins
*
* @return $this
*/
public function __construct(Zend_Db_Table_Abstract $model, array $relationMap = array())
{
$this->_model = $model;
$this->_relationMap = $relationMap;
$info = $model->info();
$select = $model->select();
$map = $info['referenceMap'];
$map = array_merge_recursive($map, $this->_relationMap);
if (is_array($map) && count($map) > 0) {
$select->setIntegrityCheck(false);
$columnsToRemove = array();
foreach ($map as $sel) {
if (is_array($sel['columns'])) {
$columnsToRemove = array_merge($columnsToRemove, $sel['columns']);
} else {
$columnsToRemove[] = $sel['columns'];
}
}
$columnsMainTable = array_diff($info['cols'], $columnsToRemove);
$select->from($info['name'], $columnsMainTable, $info['schema']);
$tAlias = array($info['name'] => 1);
$this->_setJoins($info['name'], $map, $select, $tAlias);
} else {
$select->from($info['name'], $info['cols'], $info['schema']);
}
parent::__construct($select);
return $this;
}
示例5: analyzeTable
/**
* Start analyzer
*
* @param Zend_Db_Table_Abstract $table
*
* @return array
*/
public function analyzeTable(Zend_Db_Table_Abstract $table)
{
$info = $table->info();
$info['uniques'] = array();
unset($info['sequence'], $info['schema'], $info['rowClass'], $info['rowsetClass'], $info['dependentTables'], $info['referenceMap']);
$adapter = $table->getAdapter();
foreach ($info['metadata'] as $property => $details) {
// match php types
$info['phptypes'][$property] = $this->convertMysqlTypeToPhp($details['DATA_TYPE']);
// find uniques
$tmp = $adapter->fetchRow('DESCRIBE `' . $info['name'] . '` `' . $property . '`;');
if (!empty($tmp['Key']) && $tmp['Key'] != 'MUL') {
$info['uniques'][$property] = $property;
}
}
// get f-keys
$result = $adapter->fetchAll('SHOW CREATE TABLE `' . $info['name'] . '`');
$query = $result[0]['Create Table'];
$lines = explode("\n", $query);
$tblinfo = array();
$keys = array();
foreach ($lines as $line) {
preg_match('/^\\s*CONSTRAINT `(\\w+)` FOREIGN KEY \\(`(\\w+)`\\) REFERENCES `(\\w+)` \\(`(\\w+)`\\)/', $line, $tblinfo);
if (sizeof($tblinfo) > 0) {
$keys[] = $tmp = array('key' => $tblinfo[1], 'column' => $tblinfo[2], 'fk_table' => $tblinfo[3], 'fk_column' => $tblinfo[4]);
$this->getDependencyChecker()->isChild($info['name'], $tmp['column'], $tmp['key'], $tmp['fk_table'], $tmp['fk_column']);
}
}
$info['foreign_keys'] = $keys;
return $info;
}
示例6: info
/**
* Override parent info() method to allow returning default order configuration
* option.
* @param string $key The specific info part to return. OPTIONAL.
* @return mixed
*/
public function info($key = null)
{
if ($key == self::DEFAULT_ORDER) {
return $this->getDefaultOrder();
} else {
return parent::info($key);
}
}
示例7: lockTable
/**
* lockTable
* @author Thomas Schedler <tsh@massiveart.com>
* @version 1.0
*/
public function lockTable()
{
try {
$this->objTable->getAdapter()->query('LOCK TABLES ' . $this->objTable->info(Zend_Db_Table_Abstract::NAME) . ' WRITE;');
} catch (Exception $exc) {
$this->core->logger->err($exc);
}
}
示例8: cleanData
/**
*
* @access public
* @param array $data
* @return array
*/
public function cleanData(array $data)
{
$fields = parent::info(parent::COLS);
foreach ($data as $key => $value) {
if (!in_array($key, $fields)) {
unset($data[$key]);
}
}
return $data;
}
示例9: getSelect
/**
* Get basic select (select {$fields} from {$table}) and add filters, order and limit info from request
* @param Zend_Db_Table_Abstract $table
* @param string|array $fields array of fields or "*" Use as {@see Zend_Db_Select::from()} second params
* @return Zend_Db_Select
*/
public function getSelect(Zend_Db_Table_Abstract $table, $fields = "*")
{
//create basic selects
$select = $table->getAdapter()->select()->from($table->info(Zend_Db_Table_Abstract::NAME), $fields);
$cols = $table->info(Zend_Db_Table::COLS);
//add filters support
foreach ((array) $this->getRequest()->getParam('filter') as $value) {
$field = $value['field'];
if (in_array($field, $cols)) {
$filter = System_Controller_Action_Helper_GridFilter_Abstract::factory($value['data']);
$filter->setField($field);
$filter->filter($select);
}
}
//add sort
$sortCol = $this->getRequest()->getParam('sort');
if (in_array($sortCol, $cols)) {
$select->order($sortCol . ' ' . $this->_getDirState('dir'));
}
//set limit
$select->limit((int) $this->getRequest()->getParam('limit', 25), (int) $this->getRequest()->getParam('start'));
return $select;
}
示例10: getDbTable
/**
* Get configured database table
*
* @return Zend_Db_Table_Abstract|string
*/
public function getDbTable()
{
if (null === $this->_dbTable) {
throw new Engine_ServiceLocator_Exception('Invalid database table');
} else {
if (is_string($this->_dbTable)) {
return $this->_dbTable;
} else {
if ($this->_dbTable instanceof Zend_Db_Table_Abstract) {
return $this->_dbTable->info('name');
} else {
throw new Engine_ServiceLocator_Exception('Invalid database table');
}
}
}
}
示例11: _loadAndReturnRow
protected function _loadAndReturnRow($position)
{
if (!isset($this->_data[$position])) {
throw new Zend_Db_Table_Rowset_Exception("Data for provided position does not exist");
}
// do we already have a row object for this position?
if (empty($this->_rows[$position])) {
$this->_rows[$position] = new $this->_rowClass(array('table' => $this->_table, 'data' => $this->_data[$position], 'stored' => $this->_stored, 'readOnly' => $this->_readOnly));
if ($this->_table instanceof Zend_Db_Table_Abstract) {
$info = $this->_table->info();
if ($this->_rows[$position] instanceof Zend_Db_Table_Row_Abstract) {
if ($info['cols'] == array_keys($this->_data[$position])) {
$this->_rows[$position]->setTable($this->getTable());
}
}
} else {
$this->_rows[$position]->setTable(null);
}
}
// return the row object
return $this->_rows[$position];
}
示例12: _getTable
/**
* @return string
*/
private function _getTable()
{
return $this->obj->info('name');
}
示例13: _getTableName
/**
* Return the name of a table object
*
* @param \Zend_Db_Table_Abstract $table
* @return string
*/
protected function _getTableName(\Zend_Db_Table_Abstract $table)
{
return $table->info(\Zend_Db_Table_Abstract::NAME);
}
示例14: from
/**
* Adds a FROM table and optional columns to the query.
*
* The table name can be expressed
*
* @param array|string|Zend_Db_Expr|Zend_Db_Table_Abstract $name The table name or an
associative array relating
table name to correlation
name.
* @param array|string|Zend_Db_Expr $cols The columns to select from this table.
* @param string $schema The schema name to specify, if any.
* @return Zend_Db_Table_Select This Zend_Db_Table_Select object.
*/
public function from($name, $cols = '*', $schema = null)
{
if ($name instanceof Zend_Db_Table_Abstract) {
$info = $name->info();
$name = $info[Zend_Db_Table_Abstract::NAME];
}
return $this->joinInner($name, null, $cols, $schema);
}
示例15: _prepareReference
/**
* Prepares a table reference for lookup.
*
* Ensures all reference keys are set and properly formatted.
*
* @param Zend_Db_Table_Abstract $parentTable
* @param string $tableClass
* @param string $ruleKey
* @return array
*/
protected function _prepareReference(Zend_Db_Table_Abstract $table, $tableClass, $ruleKey)
{
$map = $table->getReference($tableClass, $ruleKey);
if (!is_array($map[Zend_Db_Table_Abstract::COLUMNS])) {
$map[Zend_Db_Table_Abstract::COLUMNS] = (array) $map[Zend_Db_Table_Abstract::COLUMNS];
}
if (!isset($map[Zend_Db_Table_Abstract::REF_COLUMNS])) {
$info = $table->info();
$map[Zend_Db_Table_Abstract::REF_COLUMNS] = $info['primary'];
}
if (!is_array($map[Zend_Db_Table_Abstract::REF_COLUMNS])) {
$map[Zend_Db_Table_Abstract::REF_COLUMNS] = (array) $map[Zend_Db_Table_Abstract::REF_COLUMNS];
}
return $map;
}