本文整理汇总了PHP中ActiveRecord::connection方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::connection方法的具体用法?PHP ActiveRecord::connection怎么用?PHP ActiveRecord::connection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::connection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ActiveRecord
public function ActiveRecord($params = array())
{
$this->__class_name = $this->getClassName();
$this->__table_name = Inflector::tabelize($this->__class_name);
$this->__fields = ActiveRecord::connection()->getTableInfo($this->__table_name)->getFields();
$this->__primary_key = current(array_filter($this->__fields, array($this, '__pk')));
foreach ($params as $key => $value) {
$this->{$key} = $value;
}
}
示例2: execute
public function execute()
{
// 1. create a statement
$stmt = ActiveRecord::connection()->prepare($this->compile()->toSQL());
$stmt->setLimit($this->limit);
$stmt->setOffset($this->offset);
// 2. reflect on owner
$clazz = new ReflectionClass($this->owner);
// 3. return stuff.
if ($this->type == 'all') {
return $stmt->getAllRecords($this->bindings, $clazz);
} else {
return $clazz->newInstance($stmt->executeQuery($this->bindings)->next()->getRow());
}
}
示例3: create_result_set
/**
* Creates a ResultSet from a QueryBuilder
*
* @return ResultSet
*/
protected static function create_result_set(QueryBuilder $builder)
{
$timer = new MTimer();
$stmt = ActiveRecord::connection()->prepareStatement($builder->compile()->getQueryString());
$i = 1;
foreach ($builder->getBindings() as $binding) {
$stmt->set($i++, $binding);
}
if ($limit = $builder->getLimit()) {
$stmt->setLimit($limit);
}
if ($offset = $builder->getOffset()) {
$stmt->setOffset($offset);
}
$rs = $stmt->executeQuery();
ActiveRecord::log($timer);
$stmt->close();
return $rs;
}
示例4: create_result_set
/**
* Creates a ResultSet from a QueryBuilder
*
* @return ResultSet
*/
protected static function create_result_set(QueryBuilder $builder)
{
$stmt = ActiveRecord::connection()->prepareStatement($builder->compile()->getQueryString());
$i = 1;
foreach ($builder->getBindings() as $binding) {
$stmt->set($i++, $binding);
}
if ($limit = $builder->getLimit()) {
$stmt->setLimit($limit);
}
if ($offset = $builder->getOffset()) {
$stmt->setOffset($offset);
}
$rs = $stmt->executeQuery();
Registry::get('__logger')->debug('Query: ' . ActiveRecord::$conn->lastQuery);
$stmt->close();
return $rs;
}