当前位置: 首页>>代码示例>>PHP>>正文


PHP Database::insert_id方法代码示例

本文整理汇总了PHP中Database::insert_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::insert_id方法的具体用法?PHP Database::insert_id怎么用?PHP Database::insert_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Database的用法示例。


在下文中一共展示了Database::insert_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add

 public static function add($cmd, $type, $data = array(), $customer_id = null)
 {
     /* Kijken of het typen een day of month is (die worden ondersteund). */
     if ($type == 'day' || $type == 'month') {
         /* Maak van de data array een JSON string en escape deze. */
         $json = Database::escape(json_encode($data));
         /* Escape $cmd tegen mysql injecties. */
         $cmd = Database::escape($cmd);
         /* Escape $customer_id tegen mysql injecties. */
         $customer_id = Database::escape($customer_id);
         /* Uitzoeken in welke tabel de actie moet. */
         if ($type == 'day') {
             /* Insert het commando. */
             $insert = Database::query("INSERT INTO queue_day (customer_id, create_date, action, `data`) VALUES (" . $customer_id . ", NOW(), '" . $cmd . "', '" . $json . "')");
         } else {
             /* Insert het commando. */
             $insert = Database::query("INSERT INTO queue_month (customer_id, create_date, action, `data`) VALUES (" . $customer_id . ", NOW(), '" . $cmd . "', '" . $json . "')");
         }
         /* Controleren of de insert query is gelukt. */
         if ($insert) {
             /* Query gelukt, return het ID van het veld. */
             return Database::insert_id();
         } else {
             /* Query is mislukt. */
             throw new Exception('Er ging wat fout in de database tijdens het importeren van de taak.<br />' . Database::error());
         }
     } else {
         /* Onbekende type mee gekregen. */
         throw new Exception('De type \'' . $type . '\' wordt niet ondersteund.');
     }
 }
开发者ID:roaldnefs,项目名称:parkingcity,代码行数:31,代码来源:class.queue_manager.php

示例2: save_note

    /**
     * This functions stores the note in the database
     *
     * @param array $values
     * @return bool
     * @author Christian Fasanando <christian.fasanando@dokeos.com>
     * @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium
     * @version januari 2009, dokeos 1.8.6
     *
     */
    static function save_note($values)
    {
        if (!is_array($values) or empty($values['note_title'])) {
            return false;
        }
        // Database table definition
        $t_notebook = Database :: get_course_table(TABLE_NOTEBOOK);
        $course_id = api_get_course_int_id();

        $sql = "INSERT INTO $t_notebook (c_id, user_id, course, session_id, title, description, creation_date,update_date,status)
				VALUES(
					 $course_id,
					'" . api_get_user_id() . "',
					'" . Database::escape_string(api_get_course_id()) . "',
					'" . intval($_SESSION['id_session']) . "',
					'" . Database::escape_string($values['note_title']) . "',
					'" . Database::escape_string($values['note_comment']) . "',
					'" . Database::escape_string(date('Y-m-d H:i:s')) . "',
					'" . Database::escape_string(date('Y-m-d H:i:s')) . "',
					'0')";
        $result = Database::query($sql);
        $id = Database::insert_id();
        if ($id > 0) {
            //insert into item_property
            api_item_property_update(api_get_course_info(), TOOL_NOTEBOOK, $id, 'NotebookAdded', api_get_user_id());
        }
        $affected_rows = Database::affected_rows();
        if (!empty($affected_rows)) {
            return $id;
        }
    }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:41,代码来源:notebook.lib.php

示例3: insert

 public static function insert($inputData = array())
 {
     // End addons
     $totalArgs = count($inputData);
     $addMultiAgrs = '';
     if (isset($inputData[0]['foldername'])) {
         foreach ($inputData as $theRow) {
             $keyNames = array_keys($theRow);
             $insertKeys = implode(',', $keyNames);
             $keyValues = array_values($theRow);
             $insertValues = "'" . implode("','", $keyValues) . "'";
             $addMultiAgrs .= "({$insertValues}), ";
         }
         $addMultiAgrs = substr($addMultiAgrs, 0, strlen($addMultiAgrs) - 2);
     } else {
         $keyNames = array_keys($inputData);
         $insertKeys = implode(',', $keyNames);
         $keyValues = array_values($inputData);
         $insertValues = "'" . implode("','", $keyValues) . "'";
         $addMultiAgrs = "({$insertValues})";
     }
     Database::query("insert into plugins_meta({$insertKeys}) values" . $addMultiAgrs);
     if (!($error = Database::hasError())) {
         $id = Database::insert_id();
         return $id;
     }
     return false;
 }
开发者ID:neworldwebsites,项目名称:noblessecms,代码行数:28,代码来源:PluginsMeta.php

示例4: addCategoryInBDD

 /**
  * add Testcategory in the database if name doesn't already exists
  */
 public function addCategoryInBDD()
 {
     $t_cattable = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
     $v_name = $this->name;
     $v_name = Database::escape_string($v_name);
     $v_description = $this->description;
     $v_description = Database::escape_string($v_description);
     // check if name already exists
     $sql = "SELECT count(*) AS nb FROM {$t_cattable}\n              WHERE title = '{$v_name}' AND c_id=" . api_get_course_int_id();
     $result_verif = Database::query($sql);
     $data_verif = Database::fetch_array($result_verif);
     // lets add in BDD if not the same name
     if ($data_verif['nb'] <= 0) {
         $c_id = api_get_course_int_id();
         $sql = "INSERT INTO {$t_cattable} VALUES ('{$c_id}', '', '{$v_name}', '{$v_description}')";
         Database::query($sql);
         $new_id = Database::insert_id();
         // add test_category in item_property table
         $course_code = api_get_course_id();
         $course_info = api_get_course_info($course_code);
         api_item_property_update($course_info, TOOL_TEST_CATEGORY, $new_id, 'TestCategoryAdded', api_get_user_id());
         return $new_id;
     } else {
         return false;
     }
 }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:29,代码来源:testcategory.class.php

示例5: insert

 public static function insert($inputData = array())
 {
     // End addons
     // $totalArgs=count($inputData);
     $addMultiAgrs = '';
     if (isset($inputData[0]['userid'])) {
         foreach ($inputData as $theRow) {
             $keyNames = array_keys($theRow);
             $insertKeys = implode(',', $keyNames);
             $keyValues = array_values($theRow);
             $insertValues = "'" . implode("','", $keyValues) . "'";
             $addMultiAgrs .= "({$insertValues}), ";
         }
         $addMultiAgrs = substr($addMultiAgrs, 0, strlen($addMultiAgrs) - 2);
     } else {
         $keyNames = array_keys($inputData);
         $insertKeys = implode(',', $keyNames);
         $keyValues = array_values($inputData);
         $insertValues = "'" . implode("','", $keyValues) . "'";
         $addMultiAgrs = "({$insertValues})";
     }
     Database::query("insert into " . Database::getPrefix() . "address({$insertKeys}) values" . $addMultiAgrs);
     DBCache::removeDir('system/address');
     if (!($error = Database::hasError())) {
         $id = Database::insert_id();
         return $id;
     }
     return false;
 }
开发者ID:neworldwebsites,项目名称:noblessecms,代码行数:29,代码来源:Address.php

示例6: add

 /**
  * Creates a new group
  *
  * @author Julio Montoya <gugli100@gmail.com>,
  *
  * @param	string	The URL of the site
  * @param	string  The description of the site
  * @param	int		is active or not
  * @param  int     the user_id of the owner
  * @return boolean if success
  */
 public static function add($name, $description, $url, $visibility, $picture = '')
 {
     $now = api_get_utc_datetime();
     $table = Database::get_main_table(TABLE_MAIN_GROUP);
     $sql = "INSERT INTO {$table}\n                   SET name \t= '" . Database::escape_string($name) . "',\n                   description = '" . Database::escape_string($description) . "',\n                   picture_uri = '" . Database::escape_string($picture) . "',\n                   url \t\t= '" . Database::escape_string($url) . "',\n                   visibility \t= '" . Database::escape_string($visibility) . "',\n                   created_on = '" . $now . "',\n                   updated_on = '" . $now . "'";
     Database::query($sql);
     $return = Database::insert_id();
     return $return;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:20,代码来源:group_portal_manager.lib.php

示例7: add

 /**
  * Creates a new group
  *
  * @author Julio Montoya <gugli100@gmail.com>,
  *
  * @param	string	$name The URL of the site
  * @param   string  $description The description of the site
  * @param   string  $url
  * @param	int		$visibility is active or not
  * @param   string  $picture
  *
  * @return boolean if success
  */
 public static function add($name, $description, $url, $visibility, $picture = '')
 {
     $now = api_get_utc_datetime();
     $table = Database::get_main_table(TABLE_MAIN_GROUP);
     $sql = "INSERT INTO {$table}\n                   SET name \t= '" . Database::escape_string($name) . "',\n                   description = '" . Database::escape_string($description) . "',\n                   picture_uri = '" . Database::escape_string($picture) . "',\n                   url \t\t= '" . Database::escape_string($url) . "',\n                   visibility \t= '" . Database::escape_string($visibility) . "',\n                   created_on = '" . $now . "',\n                   updated_on = '" . $now . "'";
     Database::query($sql);
     $id = Database::insert_id();
     if ($id) {
         Event::addEvent(LOG_GROUP_PORTAL_CREATED, LOG_GROUP_PORTAL_ID, $id);
         return $id;
     }
     return false;
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:26,代码来源:group_portal_manager.lib.php

示例8: insert

 /**
  * Ingresa datos en tabla
  * @param string $tabla
  * @param array $parametros
  * @return int identificador del nuevo registro
  */
 public function insert($parametros)
 {
     $campos_tabla = "";
     $valores_tabla = "";
     $coma = "";
     foreach ($parametros as $campo => $valor) {
         $campos_tabla .= $coma . $campo;
         $valores_tabla .= $coma . "?";
         $coma = ",";
     }
     $sql = "INSERT INTO " . $this->_table . "(" . $campos_tabla . ") VALUES(" . $valores_tabla . ")";
     $this->_db->query($sql, array_values($parametros));
     return $this->_db->insert_id();
 }
开发者ID:CarlosAyala,项目名称:midas-codeigniter-modulo-emergencias,代码行数:20,代码来源:QueryBuilder.php

示例9: add_sub_language

/**
 * Add sub-language
 * @param   string  Original language name (Occitan, Wallon, Vlaams)
 * @param   string  English language name (occitan, wallon, flanders)
 * @param   string  ISO code (fr_FR, ...)
 * @param   int     Whether the sublanguage is published (0=unpublished, 1=published)
 * @param   int     ID del idioma padre
 * @return  int     New sub language ID or false on error
 */
function add_sub_language($original_name, $english_name, $isocode, $sublanguage_available, $parent_id)
{
    $tbl_admin_languages = Database::get_main_table(TABLE_MAIN_LANGUAGE);
    $original_name = Database::escape_string($original_name);
    $english_name = Database::escape_string($english_name);
    $isocode = Database::escape_string($isocode);
    $sublanguage_available = Database::escape_string($sublanguage_available);
    $parent_id = Database::escape_string($parent_id);
    $sql = 'INSERT INTO ' . $tbl_admin_languages . '(original_name,english_name,isocode,dokeos_folder,available,parent_id) VALUES ("' . $original_name . '","' . $english_name . '","' . $isocode . '","' . $english_name . '","' . $sublanguage_available . '","' . $parent_id . '")';
    $res = Database::query($sql);
    if ($res === false) {
        return false;
    }
    return Database::insert_id();
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:24,代码来源:sub_language_add.php

示例10: register

 public static function register($username, $password, $verifypassword, $email)
 {
     $query = "SELECT * FROM " . self::$tUsers . " WHERE username = ? OR email = ?";
     $query = Database::query($query, [$username, $email]);
     if (Database::num_rows($query)) {
         throw new Exception('Username or Email already exists!');
     }
     if ($password != $verifypassword) {
         throw new Exception('Passwords do not match!');
     }
     $password = password_hash($password, PASSWORD_BCRYPT);
     $data = ['username' => $username, 'password' => $password, 'email' => $email];
     $query = Database::query("INSERT INTO " . self::$tUsers . "(username,password,email)VALUES(?,?,?)", [$username, $password, $email]);
     $id = Database::insert_id();
     return $id;
 }
开发者ID:modularr,项目名称:auth,代码行数:16,代码来源:Auth.php

示例11: InsertOnSubmit

 public static function InsertOnSubmit($listFieldInsert = '')
 {
     //        $freshConnnect=$this->fieldList['dbConnect'];
     $fieldList = $this->fieldList;
     $tableName = $fieldList['tableName'];
     unset($fieldList['dbConnect'], $fieldList['hasConnected'], $fieldList['tableName'], $fieldList['dbType'], $fieldList['error']);
     if (is_array($listFieldInsert)) {
         $fieldList = $listFieldInsert;
     }
     $listFieldNames = array_keys($fieldList);
     $listFieldValues = array_values($fieldList);
     $mergeField = implode(',', $listFieldNames);
     $mergeValue = "'" . implode("','", $listFieldValues) . "'";
     $queryStr = "INSERT INTO {$tableName}({$mergeField}) VALUES({$mergeValue})";
     Database::query($queryStr);
     $insert_id = Database::insert_id();
     return $insert_id;
 }
开发者ID:neworldwebsites,项目名称:noblessecms,代码行数:18,代码来源:DatabaseORM.php

示例12: new_invoice

 public function new_invoice($cid = null, $type = null)
 {
     /* Controleren of ייn van de twee input niet null is. */
     if ($cid != null && is_numeric($cid) || $type != null) {
         /* Insert query */
         $insert = Database::query("INSERT INTO invoice (customer_id, create_date, type_customer) VALUES (" . ($cid != null ? Database::escape($cid) : 'NULL') . ", NOW(), " . ($type != null ? "'" . Database::escape($type) . "'" : 'NULL') . ")");
         /* Controleren of de query is gelukt. */
         if ($insert) {
             /* Haal invoice ID op, en sla deze op in het object. */
             $this->id = Database::insert_id();
             /* Return het invoice ID. */
             return Database::escape($this->id);
         } else {
             /* MySQL Foutmelding. */
             throw new Exception('Er ging wat fout tijdens het aanmaken van een nieuw factuur.<br />' . Database::error());
         }
     } else {
         /* Er moet minimaal 1 van de twee types opgegeven worden. */
         throw new Exception('Er is geen geldig klant ID of klant type op gegeven.');
     }
 }
开发者ID:roaldnefs,项目名称:parkingcity,代码行数:21,代码来源:class.invoice.php

示例13: add_specific_field

/**
 * Add a specific field
 * @param string $name specific field name
 */
function add_specific_field($name)
{
    $table_sf = Database::get_main_table(TABLE_MAIN_SPECIFIC_FIELD);
    $name = trim($name);
    if (empty($name)) {
        return false;
    }
    $sql = 'INSERT INTO %s(id, code, name) VALUES(NULL, \'%s\', \'%s\')';
    $_safe_name = Database::escape_string($name);
    $_safe_code = substr($_safe_name, 0, 1);
    $_safe_code = get_specific_field_code_from_name($_safe_code);
    if ($_safe_code === false) {
        return false;
    }
    $sql = sprintf($sql, $table_sf, $_safe_code, $_safe_name);
    $result = Database::query($sql);
    if ($result) {
        return Database::insert_id();
    } else {
        return false;
    }
}
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:26,代码来源:specific_fields_manager.lib.php

示例14: add

 /**
  * Creates a new url access
  *
  * @author Julio Montoya <gugli100@gmail.com>,
  *
  * @param string The URL of the site
  * @param string The description of the site
  * @param int is active or not
  * @param int the user_id of the owner
  * @param int The type of URL (1=multiple-access-url, 2=sincro-server, 3=sincro-client)
  * @param array If the type is different than 1, then there might be extra URL parameters to take into account
  * @return boolean if success
  */
 public static function add($url, $description, $active, $type = 1, $extra_params)
 {
     $tms = time();
     $type = intval($type);
     $table_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL);
     $u = api_get_user_id();
     if ($u == 0) {
         $u = api_get_anonymous_id();
     }
     if ($type > 1) {
         $active = 0;
     }
     $sql = "INSERT INTO {$table_access_url} " . " SET url \t= '" . Database::escape_string($url) . "', " . " description = '" . Database::escape_string($description) . "', " . " active \t\t= {$active}, " . " created_by \t= {$u}, " . " url_type        = {$type}, " . " tms = FROM_UNIXTIME(" . $tms . ")";
     $result = Database::query($sql);
     $id = Database::insert_id();
     if ($result !== false && $type == 3 && count($extra_params) > 0) {
         // Register extra parameters in the branch_sync table
         $t = Database::get_main_table(TABLE_BRANCH_SYNC);
         $sql = "INSERT INTO {$t} SET " . " access_url_id = {$id} " . (!empty($extra_params['ip']) ? ", branch_ip = '" . Database::escape_string($extra_params['ip']) . "'" : "") . (!empty($extra_params['name']) ? ", branch_name = '" . Database::escape_string($extra_params['name']) . "'" : "") . (!empty($extra_params['last_sync']) ? ", last_sync_trans_id = '" . Database::escape_string($extra_params['last_sync']) . "'" : "") . (!empty($extra_params['dwn_speed']) ? ", dwn_speed = '" . Database::escape_string($extra_params['dwn_speed']) . "'" : "") . (!empty($extra_params['up_speed']) ? ", up_speed = '" . Database::escape_string($extra_params['up_speed']) . "'" : "") . (!empty($extra_params['delay']) ? ", delay = '" . Database::escape_string($extra_params['delay']) . "'" : "") . (!empty($extra_params['admin_mail']) ? ", admin_mail = '" . Database::escape_string($extra_params['admin_mail']) . "'" : "") . (!empty($extra_params['admin_name']) ? ", admin_name = '" . Database::escape_string($extra_params['admin_name']) . "'" : "") . (!empty($extra_params['admin_phone']) ? ", admin_phone = '" . Database::escape_string($extra_params['admin_phone']) . "'" : "") . (!empty($extra_params['latitude']) ? ", latitude = '" . Database::escape_string($extra_params['latitude']) . "'" : "") . (!empty($extra_params['longitude']) ? ", longitude = '" . Database::escape_string($extra_params['longitude']) . "'" : "") . ", last_sync_trans_date = '" . api_get_utc_datetime() . "'";
         $result = $result && Database::query($sql);
     }
     return $result;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:36,代码来源:urlmanager.lib.php

示例15:

 function insert_id()
 {
     parent::insert_id($id);
     return mysql_insert_id($this->link_id);
 }
开发者ID:archcidburnziso,项目名称:opencongress,代码行数:5,代码来源:db.inc.php


注:本文中的Database::insert_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。