本文整理汇总了PHP中Query::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::getTable方法的具体用法?PHP Query::getTable怎么用?PHP Query::getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query::getTable方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testShouldReturnRolesTable
public function testShouldReturnRolesTable()
{
$query = new Query('roles');
$result = $query->getTable();
$expected = 'roles';
$this->assertEquals($expected, $result);
}
示例2: query
public final function query(Query $query)
{
$result = $this->queryRaw($query->toDialectString($this->getDialect()));
if ($query instanceof InsertQuery && !empty($this->sequencePool[$name = $query->getTable() . '_id'])) {
$id = current($this->sequencePool[$name]);
Assert::isTrue($id instanceof Identifier, 'identifier was lost in the way');
$id->setId($this->getInsertId())->finalize();
unset($this->sequencePool[$name][key($this->sequencePool[$name])]);
}
return $result;
}
示例3: __construct
/**
* Throws UnexpectedValueException if the row class, either gleaned from Query::getTable() or
* provided directly, does not exist.
* Throws UnexpectedValueException if the above class does not have Model in its ancestry.
*
* @param Query $query
* @param string $class = null
*/
public function __construct(Query $query, $class = null)
{
if ($class) {
$this->class = trim($class);
} else {
$this->class = trim(StringFormat::className($query->getTable()));
}
if (!class_exists($this->class)) {
throw new UnexpectedValueException(sprintf('Class "%s" does not exist.', $this->class));
}
if (!is_a($this->class, 'Model', true)) {
throw new UnexpectedValueException(sprintf('Class "%s" does not inherit from Model.', $this->class));
}
$this->query = $query;
}
示例4: testGetTableTwoWordsWithAlias
/**
* @group subquery
* @covers Query::getTable
*/
function testGetTableTwoWordsWithAlias()
{
$q = new Query('SELECT testing', 'alias');
$this->assertEquals('SELECT testing', $q->getTable());
}
示例5: install
public function install(array $options = array())
{
$toret = false;
$this->error_msg = false;
if ($this->checkConnection()) {
$drop_table = array_key_exists('drop_table', $options) ? $options['drop_table'] : false;
$query = $this->getInstallSQL();
if ($query) {
if ($drop_table) {
$table = $this->getSource();
$drop_query = new CustomQuery('DROP TABLE IF EXISTS ' . Query::getTable($this) . '', array('connection' => $this->db));
$drop_query->execute();
Backend::addNotice('Dropping table ' . $table);
if (!empty($drop_query->error_msg)) {
$this->error_msg = $drop_query->error_msg;
}
}
$query = new CustomQuery($query, array('connection' => $this->db));
$toret = $query->execute();
if (!empty($query->error_msg)) {
$this->error_msg = $query->error_msg;
}
} else {
if (class_exists('BackendError', false)) {
BackendError::add(get_class($this) . ': No Install SQL', 'install');
}
$this->error_msg = 'No Install SQL for ' . class_name($this);
}
} else {
if (class_exists('BackendError', false)) {
BackendError::add(get_class($this) . ': DB Connection Error', 'install');
}
$this->error_msg = 'DB Connection error';
}
return $toret;
}
示例6: join
function join($type, $table, $conditions, array $options = array())
{
$this->query = false;
$type = strtoupper($type);
if (!in_array($type, array('RIGHT', 'LEFT', 'INNER', 'OUTER'))) {
throw new Exception('Unsupported Join Type');
}
if (!is_array($conditions)) {
$conditions = array($conditions);
}
if (!array_key_exists($type, $this->joins)) {
$this->joins[$type] = array();
}
if ($table instanceof Query) {
$table = $table->__toString();
if (array_key_exists('alias', $options)) {
$table = '(' . $table . ') AS ' . Query::enclose($options['alias']);
} else {
trigger_error('Joined sub queries should have aliases', E_USER_ERROR);
}
} else {
$table = Query::getTable($table);
if (array_key_exists('alias', $options)) {
$table = Query::enclose($table) . ' AS ' . Query::enclose($options['alias']);
}
}
if (array_key_exists($table, $this->joins[$type])) {
$this->joins[$type][$table] = array_merge($this->joins[$type][$table], $conditions);
} else {
$this->joins[$type][$table] = $conditions;
}
return $this;
}