本文整理汇总了PHP中Zend_Db_Table_Abstract::getAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Table_Abstract::getAdapter方法的具体用法?PHP Zend_Db_Table_Abstract::getAdapter怎么用?PHP Zend_Db_Table_Abstract::getAdapter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Table_Abstract
的用法示例。
在下文中一共展示了Zend_Db_Table_Abstract::getAdapter方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDbAdapter
/**
* Get configured database adapter
*
* @return Zend_Db_Adapter_Abstract
*/
public function getDbAdapter()
{
if (null === $this->_dbAdapter) {
if ($this->_dbTable instanceof Zend_Db_Table_Abstract) {
$this->_dbAdapter = $this->_dbTable->getAdapter();
} else {
throw new Engine_ServiceLocator_Exception('Database adapter not configured');
}
}
return $this->_dbAdapter;
}
示例2: isValid
public function isValid($value)
{
$db = $this->_model->getAdapter();
$where = $db->quoteInto($this->_field . ' = ?', $value);
if (null !== $this->_where) {
$where .= " AND {$this->_where}";
}
$rows = $this->_model->fetchAll($where);
if (count($rows)) {
$this->_messages[] = Axis::translate('core')->__("Record %s already exist", $value);
return $this->_not;
}
$this->_messages[] = Axis::translate('core')->__("Record %s doesn't found", $value);
return !$this->_not;
}
示例3: 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;
}
示例4: setTable
/**
* Sets the primary table name and retrieves the table schema.
*
* @param Zend_Db_Table_Abstract $adapter
* @return Zend_Db_Select This Zend_Db_Select object.
*/
public function setTable(Zend_Db_Table_Abstract $table)
{
$this->_adapter = $table->getAdapter();
$this->_info = $table->info();
$this->_table = $table;
return $this;
}
示例5: unlockTable
/**
* unlockTable
* @author Thomas Schedler <tsh@massiveart.com>
* @version 1.0
*/
public function unlockTable()
{
try {
$this->objTable->getAdapter()->query('UNLOCK TABLES;');
} catch (Exception $exc) {
$this->core->logger->err($exc);
}
}
示例6: deleteEntry
/**
* Delete Entry
*
* @param Postr_Model_Entry $entry
* @return Postr_Model_EntryMapper Provides a fluent interface
*/
public function deleteEntry(Postr_Model_Entry $entry)
{
$dbAdapter = $this->_entryTable->getAdapter();
$dbAdapter->beginTransaction();
$entryRow = $this->_entryTable->find($entry->getId())->current();
$entryRow->delete();
$dbAdapter->commit();
return $this;
}
示例7: _getWhereStatement
/**
* _getWhereStatement
*
* @param mixed $id
* @return mixed (string/array)
*/
private function _getWhereStatement($id)
{
if (is_numeric($id)) {
$where = $this->obj->getAdapter()->quoteInto($this->primaryKey[0] . ' = ?', $id);
} else {
$id = unserialize($id);
foreach ($id as $key => $value) {
$where[] = $this->obj->getAdapter()->quoteInto($key . ' = ?', $value);
}
}
return $where;
}
示例8: setTable
/**
* Set the table object, to re-establish a live connection
* to the database for a Rowset 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)
{
$this->_table = $table;
if ($this->_table->getAdapter() == null) {
$this->_connected = false;
return false;
}
$this->_connected = false;
// @todo This works only if we have iterated through
// the result set once to instantiate the rows.
foreach ($this->_rows as $row) {
$connected = $row->setTable($table);
if ($connected == true) {
$this->_connected = true;
}
}
return $this->_connected;
}
示例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: getTableFromString
public static function getTableFromString($tableName, Zend_Db_Table_Abstract $referenceTable = null)
{
if ($referenceTable instanceof Zend_Db_Table_Abstract) {
$tableDefinition = $referenceTable->getDefinition();
if ($tableDefinition !== null && $tableDefinition->hasTableConfig($tableName)) {
return new Zend_Db_Table($tableName, $tableDefinition);
}
}
// assume the tableName is the class name
if (!class_exists($tableName)) {
try {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($tableName);
} catch (Zend_Exception $e) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception($e->getMessage(), $e->getCode(), $e);
}
}
$options = array();
if ($referenceTable instanceof Zend_Db_Table_Abstract) {
$options['db'] = $referenceTable->getAdapter();
}
if (isset($tableDefinition) && $tableDefinition !== null) {
$options[Zend_Db_Table_Abstract::DEFINITION] = $tableDefinition;
}
return new $tableName($options);
}
示例11: getAdapter
/**
* The database adapter used by the model.
*
* @return \Zend_Db_Adapter_Abstract
*/
public function getAdapter()
{
return $this->_table->getAdapter();
}