本文整理汇总了PHP中ORM::get_last_statement方法的典型用法代码示例。如果您正苦于以下问题:PHP ORM::get_last_statement方法的具体用法?PHP ORM::get_last_statement怎么用?PHP ORM::get_last_statement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ORM
的用法示例。
在下文中一共展示了ORM::get_last_statement方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findRowsRoute
//.........这里部分代码省略.........
$table->where($params[0], $params[1]);
break;
case 'where_in':
$table->where_in($params[0], $params[1]);
break;
case 'where_not_in':
$table->where_not_in($params[0], $params[1]);
break;
case 'where_like':
$table->where_like($params[0], $params[1]);
break;
case 'where_not_like':
$table->where_not_like($params[0], $params[1]);
break;
case 'where_any_is':
$table->where_any_is($params[0], $params[1]);
break;
case 'where_not_equal':
$table->where_not_equal($params[0], $params[1]);
break;
case 'where_lt':
$table->where_lt($params[0], $params[1]);
break;
case 'where_gt':
$table->where_gt($params[0], $params[1]);
break;
case 'where_lte':
$table->where_lte($params[0], $params[1]);
break;
case 'where_gte':
$table->where_gte($params[0], $params[1]);
break;
case 'group_by':
$table->group_by($params);
break;
case 'join':
$table->join($params[0], array($params[1], $params[2], $params[3]));
break;
case 'inner_join':
$table->inner_join($params[0], array($params[1], $params[2], $params[3]));
break;
case 'left_outer_join':
$table->left_outer_join($params[0], array($params[1], $params[2], $params[3]));
break;
case 'right_outer_join':
$table->right_outer_join($params[0], array($params[1], $params[2], $params[3]));
break;
case 'limit':
$table->limit($params);
break;
case 'offset':
$table->offset($params);
break;
case 'order_by_asc':
$table->order_by_asc($params);
break;
case 'order_by_desc':
$table->order_by_desc($params);
break;
case 'select':
foreach ($params as $column) {
$table->select($column);
}
break;
default:
break;
}
}
}
// Attempt to run query
try {
switch ($query_method) {
case 'find':
$results = array();
// Returns rows found for "find"
$rows = $table->find_many();
foreach ($rows as $row) {
$result = $row->as_array();
$results[] = $result;
}
$response_body = array("results" => $results);
break;
case 'count':
// Get number of rows for "count" and return response
$count = intval($table->count());
$response_body = array("count" => $count);
break;
default:
break;
}
} catch (Exception $e) {
error_log(ORM::get_last_statement()->queryString);
error_log($e->getMessage());
$response_body = array("error" => $e->getMessage());
}
// Add data to response in JSON format
$newResponse->write(json_encode($response_body));
return $newResponse;
});
}
示例2: _run
/**
* Execute the SELECT query that has been built up by chaining methods
* on this class. Return an array of rows as associative arrays.
*/
protected function _run()
{
// allow parent method to run
if (!$this->cnt_query) {
// need a way to make sure this is set
if ($this->_is_raw_query) {
if (is_array($this->_raw_parameters)) {
foreach ($this->_raw_parameters as $k => $v) {
if (!is_numeric($v)) {
$v = '"' . $v . '"';
}
$this->_raw_query = str_replace(':' . $k, $v, $this->_raw_query);
}
}
}
return parent::_run();
}
// we are not caching the COUNT - @todo - implement caching
$query = $this->_build_select();
parent::_execute($query, $this->_values, $this->_connection_name);
$statement = parent::get_last_statement();
$rows = array();
while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
$rows[] = $row;
}
// reset Idiorm bound values
$this->_values = array();
return $rows;
}
示例3: create
public function create($create_absent = false)
{
if (!$create_absent && !$this->quantity) {
return false;
}
$new = $this->create_record();
$new->set($this->from(array('model', 'sku', 'quantity', 'manufacturer_id', 'image', 'shipping', 'price', 'minimum', 'status')));
if (property_exists($this, $this->id_field) && (int) $this->{$this->id_field} > 0) {
$new->set($this->id_field, $this->id());
}
$new->set_expr('date_added', 'NOW()');
$new->set_expr('date_modified', 'NOW()');
$new->set_expr('date_available', 'NOW()');
//p($new);
$created = $new->save();
$result = array('id' => $this->id(), 'created' => $created);
if ($created) {
$this->id($new->id());
$this->to_store();
$this->create_description();
//$this->prepare_categories();
//$this->to_category();
$this->to_url_alias($new->id());
if ($this->copy_image) {
$result['image'] = $this->download_image();
$this->create_extra_images();
}
} else {
$result += array('error' => \ORM::get_last_statement());
}
return $result;
}
示例4: get_last_statement
public static function get_last_statement()
{
return \ORM::get_last_statement();
}
示例5: post
public function post(\Classes\Opencart\Product $product, $create_absent = false)
{
if (!$create_absent && !$product->quantity) {
return false;
}
$new = \ORM::for_table($this->table('primary'))->create();
$new->set($this->from(array('model', 'quantity', 'image', 'shipping', 'price', 'minimum', 'status'), $product));
if (property_exists($product, $this->id_field)) {
$new->set($this->id_field, $product->product_id);
}
$new->set_expr('date_added', 'NOW()');
$new->set_expr('date_modified', 'NOW()');
$created = $new->save();
$result = array('id' => $product->product_id, 'created' => $created);
if ($created) {
$product->{$this->id_field} = $new->id();
$this->to_store($product);
$this->create_description($product);
$this->prepare_categories($product->category);
$this->to_category($product);
$this->to_url_alias($product);
if ($product->copy_image) {
$result['image'] = $product->download_image();
}
} else {
$result += array('error' => \ORM::get_last_statement());
}
return $result;
}
示例6: testCustomConnectionName
public function testCustomConnectionName()
{
$person3 = Model::factory('ModelWithCustomConnection')->find_one(1);
$statement = ORM::get_last_statement();
$this->assertInstanceOf('MockDifferentPDOStatement', $statement);
}