本文整理匯總了PHP中dibi::insertId方法的典型用法代碼示例。如果您正苦於以下問題:PHP dibi::insertId方法的具體用法?PHP dibi::insertId怎麽用?PHP dibi::insertId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dibi
的用法示例。
在下文中一共展示了dibi::insertId方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: AddItemToSql
function AddItemToSql($values)
{
if ($values['name'] == "") {
throw new Exception("Musite vyplnit nazov");
}
$sequence = dibi::fetchSingle("SELECT MAX(sequence) as max FROM menu_item WHERE parent=%i", $values['parent'], " ORDER BY sequence") + 1;
if ($values['slug'] == "") {
$values['slug'] = $values['name'];
}
$values['slug'] = $this->url_identifier($values['slug'], '');
if ($values['parent'] == NULL) {
$values['parent'] = 0;
} else {
// $parent_url = self::getUrlIdentifier($values['parent']);
}
$collums = Tools::getCollum('menu_item');
foreach ($values as $k => $v) {
if (!in_array($k, $collums)) {
unset($values[$k]);
}
}
$values['id_menu'] = $this->id_menu;
dibi::query("INSERT INTO menu_item", $values);
$id_menu_item = dibi::insertId();
// self::doSequence($values ['parent']);
$this->repairUrls();
$this->pageModel->invalidateCache();
return $id_menu_item;
}
示例2: add_new_article
public function add_new_article($article, $user_id)
{
$array = get_object_vars($article);
$array["link_pdf"] = explode("/", $array["link_pdf"])[1];
//$array["link_pdf"] = $array["name"];
unset($array["name"]);
dibi::query('INSERT INTO article', $array);
$last_id = dibi::insertId();
$arr_owner = array("user_id_user" => $user_id, "article_id_article" => $last_id);
dibi::query('INSERT INTO user_has_article', $arr_owner);
}
示例3: createOrder
static function createOrder($values, $id_product_params, $id_lang, $user)
{
dibi::begin();
// print_r($values);exit;
dibi::query("INSERT INTO [order]", $values);
$order_id = dibi::insertId();
foreach ($id_product_params as $id_product_param => $count) {
self::insertProduct($id_product_param, $count, $order_id, $id_lang, $user);
}
dibi::commit();
return $order_id;
}
示例4: createUser
public static function createUser(array $form)
{
$password = hash(HASH_TYPE, $form['password1']);
dibi::query('INSERT INTO user ( `userName`,
`password`,
`time`,
`firstName`,
`surname`,
`title`,
`email`,
`icq`,
`skype`,
`mobile`) VALUES (%s, %s, %i, %s, %s, %s, %s, %iN, %sN, %s)', $form['userName'], $password, time(), $form['firstName'], $form['surname'], $form['title'], $form['email'], (int) $form['icq'], $form['skype'], $form['mobile']);
//Zjistíme id nově přidaného uživatele
$id = dibi::insertId();
// Vložíme do tabulky userRole role nového uživatele
foreach ($form['prava'] as $n => $row) {
dibi::query('INSERT INTO userRole (userId, roleId, active) VALUES (%i, %i, 1)', $id, $row);
}
}
示例5: duplicateNode
function duplicateNode($id_menu_item, $new_id_menu_item)
{
$sourceNode = dibi::fetchAll("SELECT * FROM [node] WHERE id_menu_item = %i", $id_menu_item);
$node = new Node();
foreach ($sourceNode as $sn) {
// $arr = array(
// 'id_user' => $session['id_user'],
// 'id_menu_item' => $_GET['id_menu_item'],
// 'sequence' => $sequence,
// 'id_type_modul' => $id_type_modul,
// );
$tmp_id_node = $sn['id_node'];
unset($sn['id_node']);
$sn['id_menu_item'] = $new_id_menu_item;
dibi::query("INSERT INTO node ", $sn);
$last_id = dibi::insertId();
$node->nodeFactory($sn['id_type_modul'])->duplicate($tmp_id_node, $last_id);
}
}
示例6: add
public static function add($values)
{
dibi::query("INSERT INTO poll ", $values);
return dibi::insertId();
}
示例7: insert
public function insert($data)
{
$ua = array('username' => 1, 'role' => 1, 'password' => 1, 'active' => 1, 'id' => 1, 'name' => 1, 'surname' => 1, 'email' => 1, 'homepage' => 1, 'telephone' => 1, 'street' => 1, 'city' => 1, 'country' => 1, 'zip' => 1, 'icq' => 1, 'aim' => 1, 'jabber' => 1, 'skype' => 1, 'birthday' => 1, 'description' => 1, 'country_id' => 1, 'language_id' => 1, 'sex' => 1, 'created' => 1);
if ($data['password'] != '') {
$data['password'] = hash("sha512", $data['password'] . str_repeat('!@#$%^&*()_+_()*&^%$#@!', 10));
}
$data['created'] = new DibiDateTime();
dibi::query('INSERT INTO [user]', array_intersect_key($data, $ua));
$data['id'] = dibi::insertId();
return $data['id'];
}
示例8: nodeAction
function nodeAction()
{
$node = NodeModel::init();
//-------------------------------//
//--------AJAX REQUEST-----------//
//------------------------------//
if (@$_GET['ajax_change_modul_position']) {
if (is_numeric(@$_GET['id_node_ajax']) and is_numeric($_GET['position'])) {
dibi::query("UPDATE node SET position=%i", $_GET['position'], " WHERE id_node=%i", $_GET['id_node_ajax']);
$node->invalidateCache();
}
exit;
}
if (@$_GET['ajax_change_modul_visible']) {
if (is_numeric(@$_GET['id_node_ajax']) and is_numeric($_GET['modul_visible'])) {
dibi::query("UPDATE node SET visible=%s", $_GET['modul_visible'], " WHERE id_node=%i", $_GET['id_node_ajax']);
}
$node->invalidateCache();
// echo dibi::$sql;
exit;
}
//------SITE MAP pre premiestnenie modulu
if (isset($_GET['ajax_show_site_map_for_modul'])) {
$m = new MenuItem();
$m->doTreeSelectMoveModul(0, 0, $_GET['id_menu_item'], $_GET['id_type_modul']);
echo '<form action="" method="post">
<select name="id_menu_item_for_change">';
echo $m->doTreeSelectMoveModulText;
echo '<input type="hidden" name="id_type_modul" value="' . htmlspecialchars($_GET['id_type_modul']) . '" />
<input type="hidden" name="id_node" value="' . htmlspecialchars($_GET['id_node']) . '" />
<input type="submit" name="changeModulParent" value="Ulož" />
</form>';
exit;
}
if (isset($_POST['changeModulParent'])) {
$this->changeModulParent();
$node->invalidateCache();
header("Location: ?id_menu_item=" . $_POST['id_menu_item_for_change'] . "&showModulsOnPage=1");
exit;
}
if (isset($_GET['id_menu_item']) and isset($_GET['id_type_modul']) and isset($_GET['id_modul'])) {
if (!dibi::fetchSingle("SELECT COUNT(*) FROM node WHERE id_menu_item=%i", $_GET['id_menu_item'], " AND id_type_modul=%i", $_GET['id_type_modul'], " AND id_node=%i", $_GET['id_modul'])) {
header("Location:admin.php");
exit;
}
}
if (isset($_GET['addnode']) and isset($_GET['id_type_modul']) or isset($_POST['addModulToMenu'])) {
if (isset($_POST['addModulToMenu'])) {
$id_type_modul = $_POST['id_type_modul'];
} else {
$id_type_modul = $_GET['id_type_modul'];
}
$sequence = dibi::fetchSingle("SELECT MAX(sequence) FROM node WHERE id_menu_item=%i", $_GET['id_menu_item']) + 1;
$session = NEnvironment::getSession('Authentication');
$config = NEnvironment::getConfig();
$arr = array('id_user' => NEnvironment::getUser()->getIdentity()->id, 'id_menu_item' => $_GET['id_menu_item'], 'sequence' => $sequence, 'id_type_modul' => $id_type_modul, 'visible' => $config['NODE_VISIBLE']);
dibi::query("INSERT INTO node ", $arr);
$this->addModul(dibi::insertId(), $id_type_modul);
$node->invalidateCache();
}
//zmenenie poradia
if (isset($_GET['modul_id_up']) or isset($_GET['modul_id_down'])) {
$this->changeOrderNode();
$node->invalidateCache();
header("Location: admin.php?id_menu_item=" . $_GET['id_menu_item'] . "&showModulsOnPage=1");
exit;
}
//ak je iba jeden modul, hned sa zobrazi ale iba ak nieje setnuta section a showModulsOnPage
if (isset($_GET['id_menu_item']) and !isset($_GET['id_type_modul']) and !isset($_GET['section']) and !isset($_GET['showModulsOnPage']) and !isset($_GET['changeMenuItem'])) {
$l = dibi::fetch("SELECT *, COUNT(*) as node_count FROM node WHERE id_menu_item=%i", $_GET['id_menu_item'], " ORDER BY sequence");
if ($l['node_count'] == 1) {
header("Location: admin.php?id_menu_item=" . $_GET['id_menu_item'] . "&id_type_modul=" . $l['id_type_modul'] . "&id_modul=" . $l['id_node']);
exit;
}
}
//pridanie do premenej activeModul instanciu objektu
if (isset($_GET['id_type_modul']) and isset($_GET['id_modul'])) {
$this->activeModul = $this->nodeFactory($_GET['id_type_modul']);
$this->activeModul->action();
}
if (isset($_GET['id_modul_del']) and is_numeric($_GET['id_modul_del'])) {
$this->deleteNode(NULL, $_GET['id_modul_del']);
$node->invalidateCache();
header("Location: admin.php?id_menu_item=" . $_GET['id_menu_item']);
exit;
}
}
示例9: addPage
public static function addPage($data)
{
//lang supplied in $data
if (!isset($data['published'])) {
$data['published'] = 0;
}
if (!isset($data['ord'])) {
$data['ord'] = 1 + dibi::fetchSingle('SELECT max(ord) FROM pages WHERE lang=%s', $data['lang'], " AND id_parent=%s", $data['id_parent']);
}
dibi::query('INSERT INTO pages', $data);
$new_page_id = dibi::insertId();
return $new_page_id;
}
示例10: register
public function register(array $me)
{
exit;
UserModel::insert(array('login' => $me['email'], 'fbuid' => $me['id'], 'name' => $me['first_name'], 'surname' => $me['last_name'], 'activate' => 1, 'password' => Tools::random(12), 'newsletter' => 0, 'iso' => 'SVK'));
return UserModel::get(dibi::insertId());
}
示例11: addUser
public function addUser($form)
{
if ($form->isValid()) {
$values = $form->getValues();
if (!isset($values['user_role'])) {
$values['user_role'] = 0;
}
if (dibi::fetchSingle("SELECT 1 FROM auth_user WHERE login=%s", $values['login']) == 1) {
throw new Exception("Dané prihlasovacie meno už existuje. Zadajte iné prosím.");
}
$arr = array('login' => $values['login'], 'password' => UserModel::getHash($values['password']), 'name' => $values['name'], 'surname' => $values['surname']);
dibi::query("INSERT INTO auth_user", $arr);
$last_id = dibi::insertId();
dibi::query("INSERT INTO [auth_user_role]", array('id_auth_user' => $last_id, 'id_auth_role' => $values['id_auth_role']));
Log::addLog($this, 'Pridanie noveho uzivatela');
} else {
throw new Exception('Nespavne vyplneny formular');
}
}
示例12: insert
static function insert($values)
{
$user_value['name'] = @$values['name'];
$user_value['surname'] = @$values['surname'];
// $user_value['email'] = $values['email'];
$user_value['login'] = $values['login'];
$user_value['activate'] = $values['activate'];
$user_value['password'] = self::getHash($values['password']);
$user_value['fbuid'] = @$values['fbuid'];
$user_value['google_id'] = @$values['google_id'];
$user_value['newsletter'] = @$values['newsletter'];
$user_value['discount'] = @$values['discount'];
unset($values['name'], $values['surname'], $values['login'], $values['password'], $values['activate'], $values['fbuid'], $values['newsletter'], $values['discount']);
dibi::begin();
dibi::insert(TABLE_USERS, $user_value)->execute();
$values['user_id'] = dibi::insertId();
dibi::insert(TABLE_USERS_INFO, $values)->execute();
dibi::commit();
return $values['user_id'];
}
示例13: add
static function add($values)
{
$sequence = dibi::fetchSingle("SELECT sequence FROM [category]\n\t\t\tWHERE \n\t\t\t%if", $values['id_parent'] != '', "id_parent = %i", $values['id_parent'], "%else id_parent IS NULL %end ORDER BY sequence DESC");
$sequence++;
$values['sequence'] = $sequence;
if ($values['id_parent'] == '') {
unset($values['id_parent']);
}
dibi::query("INSERT INTO [category]", $values);
self::invalidateCache();
return dibi::insertId();
}
示例14: addFileNode
public function addFileNode($type_module, $id_module)
{
dibi::query("INSERT INTO [file_node]", array('type_module' => $type_module, 'id_module' => $id_module));
return dibi::insertId();
}
示例15: add
static function add($values)
{
$values['product_sequence'] = dibi::fetchSingle("SELECT MAX(product_sequence) + 1 FROM [product]");
dibi::query("INSERT INTO [product]", $values);
return dibi::insertId();
}