本文整理汇总了PHP中POD::insertId方法的典型用法代码示例。如果您正苦于以下问题:PHP POD::insertId方法的具体用法?PHP POD::insertId怎么用?PHP POD::insertId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类POD
的用法示例。
在下文中一共展示了POD::insertId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replace
public function replace($option = null)
{
$this->id = null;
if (empty($this->table)) {
return false;
}
$attributes = array_merge($this->_qualifiers, $this->_attributes);
if (empty($attributes)) {
return false;
}
$pairs = $attributes;
foreach ($pairs as $key => $value) {
if (is_null($value)) {
$pairs[$key] = 'NULL';
}
}
$attributeFields = $this->_capsulateFields(array_keys($attributes));
if (in_array(POD::dbms(), array('MySQL', 'MySQLi', 'SQLite3'))) {
// Those supports 'REPLACE'
$this->_query = 'REPLACE INTO ' . $this->table . ' (' . implode(',', $attributeFields) . ') VALUES(' . implode(',', $pairs) . ')';
if ($option == 'count') {
return POD::queryCount($this->_query);
}
if (POD::query($this->_query)) {
$this->id = POD::insertId();
return true;
}
return false;
} else {
$this->_query = 'SELECT * FROM ' . $this->table . $this->_makeWhereClause() . ' LIMIT 1';
if (POD::queryExistence($this->_query)) {
return $this->update($option);
} else {
return $this->insert($option);
}
}
}
示例2: replace
public function replace($option = null)
{
$this->id = null;
if (empty($this->table)) {
return false;
}
$this->_called = true;
// Use first qualifiers when multiple conditions exist.
$qualifiers = array();
if (!empty($this->_qualifiers)) {
foreach ($this->_qualifiers as $key => $index) {
$qualifiers[$key] = reset($index);
}
}
$attributes = array_merge($qualifiers, $this->_attributes);
if (empty($attributes)) {
return false;
}
$pairs = $attributes;
foreach ($pairs as $key => $value) {
if (is_null($value)) {
$pairs[$key] = 'NULL';
}
}
$attributeFields = $this->_capsulateFields(array_keys($attributes));
if (in_array(POD::dbms(), array('MySQLnd', 'MySQLi', 'SQLite3'))) {
// Those supports 'REPLACE'
$this->_query = 'REPLACE INTO ' . $this->_getTableName() . ' (' . implode(',', $attributeFields) . ') VALUES(' . implode(',', $pairs) . ')';
if ($option == 'count') {
return POD::queryCount($this->_query);
}
$result = POD::query($this->_query);
if ($result) {
$this->id = POD::insertId();
$this->_manage_pool_stack();
return true;
}
return false;
} else {
$this->_query = 'SELECT * FROM ' . $this->_getTableName() . $this->_makeWhereClause() . ' LIMIT 1';
$result = POD::queryExistence($this->_query);
if ($result) {
return $this->update($option);
} else {
return $this->insert($option);
}
}
}