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


PHP db::insert方法代码示例

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


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

示例1: create

 public function create($values)
 {
     $values['parent'] = (int) $values['parent'];
     $position = (int) db::select('max(position)')->from(':table:')->where('parent = %i', $values['parent'])->fetchSingle();
     $values['position'] = $position + 1;
     db::insert(':table:', $values)->execute();
     return array('id' => db::getInsertId(), 'title' => $values['title'], 'parent_id' => $values['parent'], 'position' => $values['position']);
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:8,代码来源:AdminMenuItemsModel.php

示例2: _savePhotos

 public function _savePhotos($values)
 {
     db::addSubst('photos', 'site_photos');
     $pos = db::select('MAX(position) as max')->from(':photos:')->fetch('max');
     $pos = (int) $pos['max'] + 1;
     $values['position'] = $pos;
     return db::insert(':photos:', $values)->execute(db::IDENTIFIER);
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:8,代码来源:GalleryModuleModel.php

示例3: set_cache

 private static function set_cache($id, $video_data)
 {
     $success = db::insert('video_cache', array('id' => $id, 'video_data' => json_encode($video_data)));
     if ($success['status'] === 'error') {
         return false;
     }
     return true;
 }
开发者ID:codecuts,项目名称:lanningsmith-website,代码行数:8,代码来源:videos.php

示例4: insertar_usuario

 public function insertar_usuario($nombre, $email, $clave)
 {
     $array = array();
     $array['campos'] = array(":id", ":nombre", ":email", ":clave");
     $array['valores'] = array(":id" => null, ":nombre" => $nombre, ":email" => $email, ":clave" => md5($clave));
     parent::__construct($this->db, $this->tabla);
     if (parent::comprobacion_datos("email", $email)) {
         parent::insert($array);
     } else {
         echo "Esos datos ya existen";
     }
 }
开发者ID:numart,项目名称:Recetas_cocina,代码行数:12,代码来源:usuario.class.php

示例5: insertar_ingrediente

 public function insertar_ingrediente($nombre, $comentario)
 {
     $array = array();
     $array['campos'] = array(":id", ":nombre", ":comentario");
     $array['valores'] = array(":id" => null, ":nombre" => $nombre, ":comentario" => $comentario);
     parent::__construct($this->db, $this->tabla);
     if (parent::comprobacion_datos("nombre", $nombre)) {
         echo "inserta datos";
         parent::insert($array);
     } else {
         echo "Esos datos ya existen";
     }
 }
开发者ID:numart,项目名称:Recetas_cocina,代码行数:13,代码来源:ingredientes.class.php

示例6: upload

 function upload()
 {
     $dir = FILES_ROOT . 'all/';
     if (!empty($_FILES['file']['name'])) {
         $file_name = urldecode($_GET['file_name']);
         $file_type = files::info($_FILES['file']['name'], 'type');
         $file_size = files::info($_FILES['file']['tmp_name'], 'size');
         db::table('files');
         db::insert('', 'NOW()', $file_name, $file_type, $file_size);
         $file_id = mysql_insert_id();
         $file = $dir . $file_id . '.' . $file_type;
         copy($_FILES['file']['tmp_name'], $file);
         $file_icon = files::getFileIco($file_type);
         buffer::set('<p class="load"><img src="/i/fileicons/' . $file_icon . '.png" width="18" height="18" alt="" />&nbsp;<a href="/download/files/download/?file=' . $file_id . '">' . $file_name . '</a> <span>(' . $file_type . ', ' . round($file_size / 1000) . ' Кб)</span></p>');
     }
 }
开发者ID:rigidus,项目名称:ea,代码行数:16,代码来源:main.handler.php

示例7: testando

 function testando()
 {
     //senão o insere
     $db = new db();
     $db->clear();
     $db->setTabela('test');
     $dataValue = array('nome' => 'a');
     try {
         if ($db->insert($dataValue)) {
             echo 'inserido';
         } else {
             echo $db->getError();
         }
     } catch (error_db $e) {
         throw new Exception($e, 1);
     }
 }
开发者ID:Wellingtoncezar,项目名称:pfc,代码行数:17,代码来源:teste.controller.php

示例8: write

 public function write($id, $data)
 {
     $data = array('session_id' => $id, 'last_activity' => time(), 'data' => base64_encode($data));
     if ($this->session_id === NULL) {
         // Insert a new session
         $query = db::insert($this->table, $data)->execute($this->db);
     } elseif ($id === $this->session_id) {
         // Do not update the session_id
         unset($data['session_id']);
         // Update the existing session
         $query = db::update($this->table)->set($data)->where('session_id', '=', $id)->execute($this->db);
     } else {
         // Update the session and id
         $query = db::update($this->table)->set($data)->where('session_id', '=', $this->session_id)->execute($this->db);
         // Set the new session id
         $this->session_id = $id;
     }
     return (bool) $query->count();
 }
开发者ID:atlas1308,项目名称:testtesttestfarm,代码行数:19,代码来源:database.php

示例9: upload

 public function upload()
 {
     $database = new db();
     $database->db;
     $login = $_COOKIE['login'];
     $uploadfile = 'upload/' . $login . "/" . self::translitIt(basename($_FILES['userfile']['name']));
     if (!file_exists($uploadfile)) {
         if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
             $query = $database->select('id', 'user', "WHERE login='{$login}'");
             $record = mysql_fetch_assoc($query);
             $user_id = $record['id'];
             $hashForShare = self::RandomString();
             $database->insert('files', "(NULL, {$user_id}, '{$uploadfile}', '{$hashForShare}')");
             header("Location: /files");
         } else {
             echo "Download error!\n";
         }
     } else {
         header("Location: /files");
     }
 }
开发者ID:ylevkovich,项目名称:files,代码行数:21,代码来源:model_files.php

示例10: write

 /**
  * Write session data
  *
  * @param string $id
  * @param array $data
  * @return boolean
  */
 public function write($id, $data)
 {
     // we only count for presentational content types
     if (object_content_types::exists_static(['where' => ['no_virtual_controller_code' => application::get('flag.global.__content_type'), 'no_content_type_presentation' => 1]])) {
         $inc = 1;
     } else {
         $inc = 0;
     }
     $save = ['sm_session_id' => $id, 'sm_session_expires' => format::now('timestamp', ['add_seconds' => session::$default_options['gc_maxlifetime']]), 'sm_session_last_requested' => format::now('timestamp'), 'sm_session_pages_count,=,~~' => 'sm_session_pages_count + ' . $inc, 'sm_session_user_ip' => $_SESSION['numbers']['ip']['ip'], 'sm_session_user_id' => $_SESSION['numbers']['entity']['em_entity_id'] ?? 0, 'sm_session_data' => $data];
     $db = new db($this->model_seessions->db_link);
     // we update first
     $result = $db->update($this->model_seessions->name, $save, 'sm_session_id');
     if ($result['affected_rows'] == 0) {
         $save['sm_session_started'] = format::now('timestamp');
         $save['sm_session_pages_count'] = $inc;
         unset($save['sm_session_pages_count,=,~~']);
         // we insert
         $result = $db->insert($this->model_seessions->name, [$save]);
     }
     return $result['affected_rows'] ? true : false;
 }
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:28,代码来源:base.php

示例11: _save

 public function _save($values)
 {
     $values['slug'] = String::webalize($values['title']);
     if (isset($values['link'])) {
         if ($values['link'] > 0) {
             $link = array();
             $slug = $values['slug'];
             if ($values['category'] > 0) {
                 $cat_model = new Admin_CategoriesModel();
                 $cat = $cat_model->getById((int) $values['category']);
                 $slug = $cat->slug . '/' . $slug;
             }
             $link['title'] = $values['title'];
             $link['url'] = $slug;
             $link['parent'] = 0;
             $link['level'] = 1;
             $link['menu_id'] = (int) $values['link'];
             $link_model = new Admin_MenuItemsModel();
             $link_model->create($link);
             //refresh table alias
             $this->__after_startup();
         }
         unset($values['link']);
     }
     $values['content_type'] = 'page';
     if (!isset($values['publish_time'])) {
         $values['publish_time'] = time();
     }
     $values['publish_time'] = db::datetime($values['publish_time']);
     if (isset($values['homepage'])) {
         if ($values['homepage'] == 1) {
             $update = array('homepage' => 0);
             db::update(':table:', $update)->execute();
         }
     }
     db::insert(':table:', $values)->execute();
     return db::getInsertId();
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:38,代码来源:AdminPagesModel.php

示例12: dump

 function dump()
 {
     $tables = implode(', ', self::$tables);
     $conf = implode(', ', self::$conf);
     db::table('admin_log_trash');
     db::order('log_id', 'DESC');
     db::limit(31, 100);
     $res = db::select('log_id');
     if (db::rows() > 0) {
         while ($row = mysql_fetch_assoc($res)) {
             self::delete($row['log_id']);
         }
     }
     if (self::$files) {
         $log_tmpl = 1;
     } else {
         $log_tmpl = 0;
     }
     db::table('admin_log_trash');
     db::insert('', 'NOW()', '', $tables, $conf, '', $log_tmpl, ADMIN_USER_ID);
     $log_id = mysql_insert_id();
     dump::tables(self::$tables);
     dump::backup(SYS_ROOT . 'var/trash/' . $log_id . '_base.zip');
     if (self::$conf) {
         foreach (self::$conf as $v) {
             zipfile::add(SYS_ROOT . 'conf/web/' . $v . '.ini');
         }
         zipfile::create(SYS_ROOT . 'var/trash/' . $log_id . '_conf.zip');
     }
     if (self::$files) {
         foreach (self::$files as $v) {
             zipfile::add($v);
         }
         zipfile::create(SYS_ROOT . 'var/trash/' . $log_id . '_files.zip');
     }
 }
开发者ID:rigidus,项目名称:ea,代码行数:36,代码来源:trash.php

示例13: array

            $user_params = array(":email" => $return_params[":email"], ":name" => $name, ":usergroup" => $usergroup);
            if ($user_result = \db::query($user_SQL, array(":email" => $return_params[":email"]))) {
                $user_result = $user_result[0];
                if (\context::get("profile") && \context::get("profile") === \user::me()) {
                    $user_SQL = "UPDATE `{PREFIX}user` SET name = :name WHERE email = :email";
                    \db::query($user_SQL, $user_params);
                } elseif ($user_result["name"] != $name || $user_result["usergroup"] != $usergroup) {
                    $user_SQL = "UPDATE `{PREFIX}user` SET name = :name, usergroup = :usergroup WHERE email = :email";
                    \db::query($user_SQL, $user_params);
                }
            } else {
                if (\context::get("profile") && \context::get("profile") === \user::me() && !is_numeric($user_params[":usergroup"])) {
                    $user_params[":usergroup"] = 0;
                }
                $user_SQL = "INSERT INTO `{PREFIX}user` (`email`, `name`, `usergroup`) VALUES (:email, :name, :usergroup)";
                \db::insert($user_SQL, $user_params);
            }
        }
        if ($saved) {
            $url = \bootstrap::get("url");
            echo <<<HTML
<h1 class="client-form-success text-success">Saved successfully!</h1>
<script>
\tsetTimeout(function() {
\t\twindow.location.href = "admin/{$url}";
\t}, 1000);
</script>
HTML;
        }
    }
    if (!$saved) {
开发者ID:RetroscopeCreative,项目名称:RouterunnerCMS,代码行数:31,代码来源:memberform.frm.submit.php

示例14: db

require_once "libs/fc_sessoes.php";
require_once "libs/form2.class";
require_once "libs/funcoes.php";
require_once "libs/class_dbgrid.php";
require_once "libs/classes.class";
require_once "libs/class_interface.php";
require "classes/class_atendimento.php";
$db = new db();
$db->_DEBUG = 1;
$hab1 = 0;
$hab = 0;
$form = new form('', true, "libs", false, 5);
if ($_POST["gravado"] != 1) {
    $db->begin();
    $campos = array("com_delivery" => 0, "com_dtcomanda" => date("Y-m-d"), "com_aberta" => '1', "com_mesid" => $_GET["mes_id"]);
    $db->executa($db->insert($campos, "comandas"));
    $comanda = $db->last_id("comandas", "com_id");
    $gravado = 1;
    $db->commit();
}
//echo $comanda;
if (isset($_POST["btncadastrar"])) {
    echo $_POST["comanda"];
    $db->begin();
    $campos = array("cti_comid" => $_POST["com_id"], "cti_proid" => $_POST["cti_proid"], "cti_qtde" => $_POST["cti_qtde"]);
    $db->executa($db->insert($campos, "comanda_itens"));
    $item = $db->last_id("comanda_itens", "cti_id");
    if (is_array($_POST["itens"])) {
        $vi = '';
        $obs = "Sem: ";
        while (list($k, $v) = each($_POST["itens"])) {
开发者ID:tavo1981,项目名称:phpbar,代码行数:31,代码来源:ate_novacomanda.php

示例15: saveVersion

 function saveVersion($app, $tmpl_file, $code)
 {
     db::table('templates_versions');
     db::where('app', $app);
     db::where('tmpl_file', $tmpl_file);
     db::where('version_code', $code);
     db::order('version_date', 'DESC');
     db::limit(1);
     db::select();
     if (db::rows() == 0) {
         /*
         	delete over 10
         */
         db::table('templates_versions');
         db::where('app', $app);
         db::where('tmpl_file', $tmpl_file);
         db::order('version_date', 'DESC');
         db::limit(10, 100);
         db::delete();
         db::table('templates_versions');
         db::insert('', 'NOW()', $code, $app, $tmpl_file, 0, ADMIN_SITE_ID);
     }
 }
开发者ID:rigidus,项目名称:ea,代码行数:23,代码来源:apps.module.php


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