Insert method to add new row
function createCupon($cliente_id, $numero) { $db = new MysqliDb(); $data = array('cliente_id' => $cliente_id, 'numero' => $numero); $result = $db->insert('cupones', $data); if ($result > -1) { echo json_encode(true); } else { echo json_encode(false); } }
/** * save next message * @param $text * @param $chatid * @param MysqliDb $db * @param TelegramBot\Api\BotApi $bot */ function setNextMessage($text, $chatid, $db, $bot) { if ($db->insert('nextMessages', array('text' => $text))) { $bot->sendMessage($chatid, 'پیام مورد نظر ثبت شد'); $db->update('adminOperations', array('next_status' => 0)); } }
function order_paid() { require_once './submodules/php-mysqli-database-class/MysqliDb.php'; require './includes/config.php'; $db = new MysqliDb($db_host, $db_user, $db_pass, $db_name); $payid = $_GET['out_trade_no']; $aPayId = explode('_', $payid); $mtrid = $aPayId[1]; $params = json_encode($_GET); //验证是否已经支付过 $db->where("mtr_id = '{$mtrid}'")->get('mark_trafficpolice_reward'); if ($db->count == 0) { $aNew = array('mtr_id' => $mtrid, 'pay_id' => $payid, 'pay_success' => 1, 'pay_money' => $_GET['total_fee'], 'pay_date' => $_GET['gmt_payment'], 'pay_params' => $params, 'created_date' => $db->now()); $id = $db->insert('mark_trafficpolice_reward', $aNew); //给用户增加余额 $sql = "SELECT mt.user_id,u.user_money FROM `mark_trafficpolice` mt\n LEFT JOIN mark_trafficpolice_received mtr ON mt.id=mtr.mt_id\n LEFT JOIN users u ON u.user_id=mt.user_id\n WHERE mtr.id= '{$mtrid}'"; $aUser = $db->rawQuery($sql); if ($db->count) { $aUpdate = array('user_money' => $aUser[0]['user_money'] + $_GET['total_fee'], 'updated_date' => $db->now()); $db->where('user_id', $aUser[0]['user_id']); $db->update('users', $aUpdate); } } else { echo "already rewarded"; } }
$decoded = json_decode($item); $db->where('revista_id', $decoded->revista_id); $results = $db->delete('revistas'); echo json_encode($results); } function save($item) { $db = new MysqliDb(); $decoded = json_decode($item); $data = array('nombre' => $decoded->nombre, 'link' => $decoded->link); $result = $db->insert('revistas', $data); if ($result > -1) {
$decoded = json_decode($item); $db->where('oferta_laboral_id', $decoded->oferta_laboral_id); $results = $db->delete('ofertas_laborales'); echo json_encode($results); } function create($item) { $db = new MysqliDb(); $decoded = json_decode($item); $data = array('titulo' => $decoded->titulo, 'detalle' => $decoded->detalle, 'cliente_id' => $decoded->cliente_id, 'status' => 1); $result = $db->insert('ofertas_laborales', $data); if ($result > -1) {
/** * @description Crea una sucursal * @param $sucursal */ function createSucursal($sucursal) { $db = new MysqliDb(); $db->startTransaction(); $sucursal_decoded = checkSucursal(json_decode($sucursal)); $data = array('nombre' => $sucursal_decoded->nombre, 'direccion' => $sucursal_decoded->direccion, 'telefono' => $sucursal_decoded->telefono); $result = $db->insert('sucursales', $data); if ($result > -1) { $db->commit(); echo json_encode($result); } else { $db->rollback(); echo json_encode(-1); } }
/** * @return mixed insert id or false in case of failure */ public function insert() { if (!empty($this->timestamps) && in_array("createdAt", $this->timestamps)) { $this->createdAt = date("Y-m-d H:i:s"); } $sqlData = $this->prepareData(); if (!$this->validate($sqlData)) { return false; } $id = $this->db->insert($this->dbTable, $sqlData); if (!empty($this->primaryKey) && !isset($this->data[$this->primaryKey])) { $this->data[$this->primaryKey] = $id; } $this->isNew = false; return $id; }
/** * @description Mueve una determinada cantidad de un producto a otra sucursal * @param $origen_id * @param $destino_id * @param $producto_id * @param $cantidad */ function trasladar($origen_id, $destino_id, $producto_id, $cantidad) { $db = new MysqliDb(); $cant_a_mover = $cantidad; $stock_origen = $db->rawQuery('select stock_id, cant_actual, costo_uni, proveedor_id from stock where sucursal_id = ' . $origen_id . ' and producto_id = ' . $producto_id . ' order by stock_id asc'); foreach ($stock_origen as $row) { if ($cant_a_mover > 0 && $row["cant_actual"] > 0) { if ($row["cant_actual"] < $cant_a_mover) { $db->where('stock_id', $row['stock_id']); $data = array('cant_actual' => 0); $db->update('stock', $data); $insertar = array('producto_id' => $producto_id, 'proveedor_id' => $row['proveedor_id'], 'sucursal_id' => $destino_id, 'cant_actual' => $cant_a_mover - $row["cant_actual"], 'cant_inicial' => $cant_a_mover - $row["cant_inicial"], 'costo_uni' => $row['costo_uni']); $db->insert('stock', $insertar); $cant_a_mover = $cant_a_mover - $row["cant_actual"]; } if ($row["cant_actual"] > $cant_a_mover) { $db->where('stock_id', $row['stock_id']); $data = array('cant_actual' => $row["cant_actual"] - $cant_a_mover); $db->update('stock', $data); $insertar = array('producto_id' => $producto_id, 'proveedor_id' => $row['proveedor_id'], 'sucursal_id' => $destino_id, 'cant_actual' => $cant_a_mover, 'cant_inicial' => $cant_a_mover, 'costo_uni' => $row['costo_uni']); $db->insert('stock', $insertar); $cant_a_mover = 0; } if ($row["cant_actual"] == $cant_a_mover) { $db->where('stock_id', $row['stock_id']); $data = array('cant_actual' => 0); $db->update('stock', $data); $insertar = array('producto_id' => $producto_id, 'proveedor_id' => $row['proveedor_id'], 'sucursal_id' => $destino_id, 'cant_actual' => $cant_a_mover, 'cant_inicial' => $cant_a_mover, 'costo_uni' => $row['costo_uni']); $db->insert('stock', $insertar); $cant_a_mover = 0; } } } echo json_encode($db->getLastError()); }
function saveNoticia($noticia) { $db = new MysqliDb(); $decoded = json_decode($noticia); $data = array("titulo" => $decoded->titulo, "detalles" => $decoded->detalle, "creador_id" => $decoded->creador_id, "vistas" => 0, "tipo" => $decoded->tipo); $results = $db->insert('noticias', $data); if ($results < 0) { echo json_encode($db->getLastError()); return; } foreach ($decoded->fotos as $row) { $data = array("noticia_id" => $row["noticia_id"], "foto" => $row["foto"], "main" => $row["main"]); $results = $db->insert('noticias_fotos', $data); if ($results < 0) { echo json_encode($db->getLastError()); return; } } echo json_encode(1); }
* v.erdemci@gmail.com * veysel123 */ $a = 5; $b = 3; require_once '../Database/MysqliDb.php'; //$host="mysql.hostinger.web.tr"; //$username="******"; //$password="******"; //$database="u995979635_test"; //$host="37.152.74.51"; //$username="******"; //$password="******"; //$database="mhalilog_hoi"; // phpinfo(); $host = "localhost"; $username = "******"; $password = ""; $database = "hoi_db"; $db = new MysqliDb($host, $username, $password, $database); $postdata = file_get_contents("php://input"); $request = json_decode($postdata); $name = $request->FullName; $email = $request->Email; //echo $email; //this will go back under "data" of angular call. $data = array('FullName' => "Veysel", 'Email' => "*****@*****.**", 'Message' => "test test test test", 'Subject' => "test test test test", 'Phone' => "555555555", 'CreatedDate' => date('Y-m-d H:i:s'), 'IsActive' => true); $id = $db->insert('hoi_contact', $data); // $id will have the auto-increment echo var_dump($data); echo "Data inserted. ID:" . $id;
<?php require_once 'MysqliDb.php'; //Extracts question from forms and stores into database $question_username = "******"; //$_POST['question_username']; $question = "college canteen needs to be improved"; //$_POST['question']; $description = "details"; //$_POST['description']; $type = "general"; //$_POST['branch']; //branch or general $timestamp = date('Y-m-d H:i:s'); $db = new MysqliDb('localhost', 'root', 'hack123', 'colgpolls'); $data = array("question" => $question, "description" => $description, "question_username" => $question_username, "timestamp" => $timestamp); $id = $db->insert('polls', $data); $db->where("timestamp", $timestamp); $user = $db->getOne("polls"); $data = array("pid" => $user['pid']); /* There are two types of question category : general or branch based Store values according catogery in database */ if ($type == 'general') { $db->insert('CSE', $data); $db->insert('MECH', $data); $db->insert('TCE', $data); $db->insert('ECE', $data); } else { if ($type == 'CSE') { $db->insert('CSE', $data); } else { if ($type == 'TCE') {
//read input data $data = json_decode(file_get_contents('php://input'), true); if ($data == null || $data == "" || !isset($data['message'])) { die; } $db = new MysqliDb(HOST, DB_USER, DB_PASSWORD, DATABASE); $db->setPrefix('soft_'); $text = ''; $chatid = ''; try { //catch user info $chatid = $data['message']['chat']['id']; $first_name = isset($data['message']['chat']['first_name']) ? $data['message']['chat']['first_name'] : ''; $last_name = isset($data['message']['chat']['last_name']) ? $data['message']['chat']['last_name'] : ''; $username = isset($data['message']['chat']['username']) ? $data['message']['chat']['username'] : ''; $db->insert('users', array('ID' => $chatid, 'first_name' => $first_name, 'last_name' => $last_name, 'username' => $username)); //catch message data $text = $data['message']['text']; $messageid = $data['message']['message_id']; $updateid = $data['update_id']; $senderid = $data['message']['from']['id']; $date = $data['message']['date']; $messageid = $data['message']['message_id']; $db->insert('received', array('ID' => $username, 'Message_id' => $messageid, 'User_id' => $senderid, 'Date' => $date, 'Text' => $text)); } catch (Exception $e) { error_log("خطا در دریافت اطلاعات\n\n" . $e->getMessage()); } $text = strtolower($text); $bot = new TelegramBot\Api\BotApi(TOKEN); try { switch ($text) {
public function login($email, $password) { $db = new MysqliDb(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DATABASE); $db->where("email", $email); $user = $db->getOne("users"); //Salt and hash password for checking $password = $user['user_salt'] . $password; $password = $this->hashData($password); //Check email and password hash match database row //Convert to boolean $is_active = (bool) $user['is_active']; $verified = (bool) $user['is_verified']; if ($password == $user['password']) { if ($is_active == true) { if ($verified == true) { //Email/Password combination exists, set sessions //First, generate a random string. $random = $this->randomString(); //Build the token $token = $_SERVER['HTTP_USER_AGENT'] . $random; $token = $this->hashData($token); //Setup sessions vars $_SESSION['token'] = $token; $_SESSION['user_id'] = $user['id']; $_SESSION['data'] = json_decode($user['data'], true); $_SESSION['fname'] = $user['fname']; $_SESSION['lname'] = $user['lname']; $_SESSION['email'] = $user['email']; $_SESSION['is_admin'] = $user['is_admin']; $_SESSION['is_super'] = $user['is_super']; $_SESSION['is_provider'] = $user['is_provider']; $db->where('user_id', $user['id']); $db->delete('logged_in_member'); //Insert new logged_in_member record for user $data = array('user_id' => $user['id'], 'session_id' => session_id(), 'token' => $token, 'is_provider' => $user['is_provider'], 'is_admin' => $user['is_admin'], 'is_super' => $user['is_super'], 'createdAt' => $db->now()); $id = $db->insert('logged_in_member', $data); if ($id) { return 10; } else { return 5; } } else { //Not verified //Email/Password combination exists, set sessions //First, generate a random string. $random = $this->randomString(); //Build the token $token = $_SERVER['HTTP_USER_AGENT'] . $random; $token = $this->hashData($token); //Setup sessions vars session_start(); $_SESSION['token'] = $token; $_SESSION['user_id'] = $user['id']; $_SESSION['data'] = json_decode($user['data'], true); $_SESSION['fname'] = $user['fname']; $_SESSION['lname'] = $user['lname']; $_SESSION['email'] = $user['email']; $_SESSION['is_admin'] = $user['is_admin']; $_SESSION['is_super'] = $user['is_super']; $_SESSION['is_provider'] = $user['is_provider']; //Delete old logged_in_member records for user //Insert new logged_in_member record for user $db->where('user_id', $user['id']); $db->delete('logged_in_member'); //Insert new logged_in_member record for user $data = array('user_id' => $user['id'], 'session_id' => session_id(), 'token' => $token, 'is_provider' => $user['is_provider'], 'is_admin' => $user['is_admin'], 'is_super' => $user['is_super'], 'createdAt' => $db->now()); $id = $db->insert('logged_in_member', $data); if ($id) { return 1; } else { return 5; } } } else { //Not active return 2; } } //No match, reject return 4; }
$done = false; if (isset($_REQUEST["done"]) && !empty($_REQUEST["done"])) { $done = true; } $db = new MysqliDb('localhost', 'root', '', 'golf-cards'); $time = time(); $name = $time . "names"; $scores = $time . "scores"; $q = "CREATE TABLE {$name} (id INT(9) UNSIGNED PRIMARY KEY AUTO_INCREMENT, name VARCHAR(30) NOT NULL)"; $w = "CREATE TABLE {$scores} (id INT(9) UNSIGNED PRIMARY KEY AUTO_INCREMENT, player_id int(30) NOT NULL, round int(30) NOT NULL, score int(30) NOT NULL)"; if ($done) { //!empty($num_players) && count($player_names) == $num_players $tmp = $db->rawQuery($q); $tmp = $db->rawQuery($w); $data = array("game_id" => $time, "friendly_name" => $game_name); $id = $db->insert("game_names", $data); for ($i = 0; $i < $num_players; $i++) { $data = array("name" => $player_names[$i]); $id = $db->insert($name, $data); } for ($i = 0; $i < $num_players; $i++) { $data = array("player_id" => strval($i + 1), "round" => 0, "score" => 0); $id = $db->insert($scores, $data); } $int = 43200; setcookie("game", $time, time() + $int); setcookie("mod", "true", time() + $int); $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); $extra = 'current.php'; header("Location: http://{$host}{$uri}/{$extra}");
/** * @description Crea un donacion y su detalle * @param $donacion */ function createDonacion($donacion) { $db = new MysqliDb(); $db->startTransaction(); $donacion_decoded = checkDonacion(json_decode($donacion)); $data = array('proyecto_id' => $donacion_decoded->proyecto_id, 'donador_id' => $donacion_decoded->donador_id, 'fecha' => $donacion_decoded->fecha, 'costo_inicial' => $donacion_decoded->costo_inicial, 'status' => $donacion_decoded->status, 'comprobante' => $donacion_decoded->comprobante); $result = $db->insert('donaciones', $data); if ($result > -1) { $db->commit(); echo json_encode($result); } else { $db->rollback(); echo json_encode(-1); } }
$surface = $_POST['surface']; $parking = $_POST['parking']; $facilities = $_POST['facilities']; $hours = $_POST['hours']; $loopcount = $_POST['loopcount']; $satImgURL = $_POST['satImgURL']; $largeImgURL = $_POST['largeImgURL']; $thumbURL = $_POST['thumbURL']; $attrArray = explode(',', $_POST['attrArray']); $loopcount = $_POST['loopcount']; $published = $_POST['publish']; $attractions = array(); foreach ($attrArray as $index => $attractionID) { array_push($attractions, rawurlencode($_POST['attraction' . $attractionID])); } $loops = array(); $i = 1; while ($i <= $loopcount) { $loops[$i]["name"] = $_POST['loop' . $i . 'name']; $loops[$i]["distance"] = $_POST["loop" . $i . "distance"]; $loops[$i]["steps"] = intval($_POST["loop" . $i . "steps"]); $i++; } $googlemaps = "https://maps.google.com/maps?q=" . urlencode($address . ", " . $city . ", NM" . $zip) . "&output=embed"; $data = array('name' => $name, 'city' => $city, 'zip' => $zip, 'crossstreets' => $crossstreets, 'address' => $address, 'transit' => $transit, 'lat' => $lat, 'lng' => $lng, 'desc' => $desc, 'lighting' => $lighting, 'difficulty' => $difficulty, 'surface' => $surface, 'parking' => $parking, 'facilities' => $facilities, 'hours' => $hours, 'loopcount' => $loopcount, 'satImgURL' => $satImgURL, 'largeImgURL' => $largeImgURL, 'thumbURL' => $thumbURL, 'attractions' => addslashes(json_encode($attractions)), 'loops' => addslashes(json_encode($loops)), 'published' => $published); $id = $db->insert('trails', $data); if ($id) { header("Location: " . $baseurl . "admin/new/done.php?id=" . $id); } else { echo 'insert failed: ' . $db->getLastError(); }
function create_log_action($user_id, $action_msg) { $db = new MysqliDb(DBHOST, DBUSER, DBPASS, DBNAME); $insert_log = array('user_id' => $user_id, 'action' => $action_msg, "date_time" => date("Y-m-d H:i:s")); $log = $db->insert('log_activity', $insert_log); }
<?php require_once 'mysql/MysqliDb.php'; $db = new MysqliDb('localhost', 'c32goldenweek', 'MRSuht1d9Lr2p', 'c32goldenweek'); $data = array("user_name" => $_POST['user_name'], "mobile_number" => $_POST['mobile_number'], "wechat_name" => $_POST['wechat_name'], 'score' => $_POST['score'], 'play_time' => $_POST['play_time'], 'city_num' => $_POST['city_num'], 'created' => date('Y-m-d H:i:s')); $id = $db->insert('game_info', $data); if ($id) { die('SUCCESS'); }
echo ' <link rel="stylesheet" type="text/css" href="css/login_form.css">' . "\n"; echo ' </head>' . "\n"; echo ' <body>' . "\n"; if (isset($_POST['submitted']) && $_POST['pass'] === $_POST['repass']) { $submited = $_POST['submitted']; $name = explode(" ", $_POST['name']); $fName = $name[0]; $lName = $name[1]; $email = $_POST['email']; $phone = $_POST['phone']; $intro = $_POST['intro']; $pass = $_POST['pass']; $options = ['cost' => 17]; $pass = password_hash($pass, PASSWORD_BCRYPT, $options) . "\n"; $data = array('password' => $pass, 'active' => true, 'fName' => $fName, 'lName' => $lName, 'email' => $email, 'phone' => $phone, 'intro' => $intro, 'createdAt' => $db->now(), 'expires' => $db->now('+1Y')); $id = $db->insert('Users', $data); if ($id) { echo 'user was created. Id=' . $id; } else { echo 'insert failed: ' . $db->getLastError(); } } else { echo ' <form name="signup" action="" method="post" autocomplete="on">' . "\n"; echo ' <ul>' . "\n"; echo ' <li>' . "\n"; echo ' <h2>Contact Us</h2>' . "\n"; echo ' <span class="required_notification">* Denotes Required Field</span>' . "\n"; echo ' </li>' . "\n"; echo ' <li>' . "\n"; echo ' <label for="name"><font color="black">Name:</font></label>' . "\n"; echo ' <input id="name" name="name" type="text" autofocus required pattern="[A-Za-z0-9]+\\s[A-Za-z0-9]+" />' . "\n";
$jsondata = file_get_contents('php://input'); //Create Bot $client = new Zelenin\Telegram\Bot\Api($token); //Parse Recived Data $chatid = $data['message']['chat']['id']; $text = $data['message']['text']; $messageid = $data['message']['message_id']; $updateid = $data['update_id']; $senderid = $data['message']['from']['id']; $zaman = $data['message']['date']; $messageid = $data['message']['message_id']; // Initialize Database $db = new \MysqliDb($dbconf); // Insert Recived Data To Database $dbdata = array('ID' => '', 'Uid' => $updateid, 'Mid' => $messageid, 'Fid' => $senderid, 'Cid' => $chatid, 'Date' => $zaman, 'Text' => $text, 'Json' => $jsondata); $id = $db->insert('jadi_recived', $dbdata); $mp3 = "http://jadi.net/radiogeek.mp3"; switch ($text) { case '/podcast': case '/podcast@jadibot': case '/podcast@JadiBot': try { $url = "http://jadi.net/tag/podcast/feed/"; $rss = Feed::loadRss($url); $items = $rss->item; $lastitem = $items[0]; $lastlink = $lastitem->link; $lasttitle = $lastitem->title; $message = $lasttitle . "\n" . $lastlink; $params = array('chat_id' => $chatid, 'action' => 'typing'); $response = $client->sendChatAction($params);
/** * @description Crea un carrito y su detalle * @param $carrito */ function createCarrito($carrito) { $db = new MysqliDb(); $db->startTransaction(); $carrito_decoded = checkCarrito(json_decode($carrito)); $data = array('status' => $carrito_decoded->status, 'total' => $carrito_decoded->total, 'fecha' => $carrito_decoded->fecha, 'usuario_id' => $carrito_decoded->usuario_id, 'origen' => $carrito_decoded->origen, 'destino' => $carrito_decoded->destino); $result = $db->insert('carritos', $data); if ($result > -1) { // foreach ($carrito_decoded->detalles as $detalle) { // $data = array( // 'carrito_id' => $result, // 'producto_id' => $detalle->producto_id, // 'cantidad' => $detalle->cantidad, // 'en_oferta' => $detalle->en_oferta, // 'precio_unitario' => $detalle->precio_unitario // ); // // $pre = $db->insert('carrito_detalles', $data); // if ($pre > -1) { // $db->rollback(); // echo json_encode(-1); // return; // } // } $db->commit(); //echo json_encode($result); $data['carrito_id'] = $result; echo json_encode($data); } else { $db->rollback(); echo json_encode(-1); } }
public function newLog($uid, $type, $distance, $steps, $time, $date, $trail_id = null, $trail_name = null) { $db = new MysqliDb(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DATABASE); $data = array("uid" => $uid, "type" => $type, "trail_id" => $trail_id, "distance" => $distance, "steps" => $steps, "time" => $time, "trail_name" => $trail_name, "date" => $date); $id = $db->insert('activities', $data); if ($id) { $return = array("status" => "done", "id" => $id); } else { $return = array("status" => "error", "message" => "A MySQLi error has occurred.", "tech" => $db->getLastError()); } return $return; }
$attractioncount = $_POST['attractioncount']; $postaction = $_POST['postaction']; $trans_id = $_POST['trans_id']; $attractions = array(); $i = 0; while ($i <= $attractioncount) { array_push($attractions, rawurlencode($_POST['attraction' . $i])); $i++; } $loops = array(); $i = 1; while ($i <= $loopcount) { $loops[$i]["name"] = $_POST['loop' . $i]; $i++; } $data = array('trail_id' => $id, 'lang' => $lang, 'desc' => $desc, 'lighting' => $lighting, 'surface' => $surface, 'parking' => $parking, 'facilities' => $facilities, 'hours' => $hours, 'attractions' => addslashes(json_encode($attractions)), 'loops' => addslashes(json_encode($loops))); if ($postaction == "update") { $db->where('id', $trans_id); if ($db->update('translations', $data)) { header("Location: " . $baseurl . "admin/translate/done.php?status=update&id=" . $id . "&lang=" . $lang); } else { echo 'update failed: ' . $db->getLastError(); } } else { $id = $db->insert('translations', $data); if ($id) { header("Location: " . $baseurl . "admin/translate/done.php?id=" . $id . "&lang=" . $lang); } else { echo 'insert failed: ' . $db->getLastError(); } }
case PARAMETRO_ID: $bd->where(COLUMNA_ID, (int) $val); break; } } } $query = $bd->getOne(TABLA_CATEGORIA); $arr = array(RESPUESTA_DATA => $query, RESPUESTA_MENSAJE => MENSAJE_OK, RESPUESTA_ERROR => ERROR_NINGUNO); } else { if ($accion_form == ACCION_AGREGAR) { $data_post = $postdata->form_data; if (!isset($data_post->FOTO)) { $data_post->FOTO = NULL; } $datos = array(COLUMNA_NOMBRE => $data_post->NOMBRE, COLUMNA_DESCRIPCION => $data_post->DESCRIPCION, COLUMNA_ESTADO => $data_post->ESTADO, COLUMNA_FOTO => $data_post->FOTO); $id_nuevo = $bd->insert(TABLA_CATEGORIA, $datos); if (!$id_nuevo) { $arr = array(RESPUESTA_ERROR => $bd->getLastError()); } else { $datos[COLUMNA_ID] = $id_nuevo; $arr = array(RESPUESTA_DATA => $datos, RESPUESTA_MENSAJE => MENSAJE_OK, RESPUESTA_ERROR => ERROR_NINGUNO); } } else { if ($accion_form == ACCION_EDITAR) { $data_post = $postdata->form_data; if (!isset($data_post->FOTO)) { $data_post->FOTO = NULL; } $datos = array(COLUMNA_NOMBRE => $data_post->NOMBRE, COLUMNA_DESCRIPCION => $data_post->DESCRIPCION, COLUMNA_ESTADO => $data_post->ESTADO, COLUMNA_FOTO => $data_post->FOTO); $bd->where(COLUMNA_ID, $data_post->ID); $respuesta = $bd->update(TABLA_CATEGORIA, $datos);
require 'conf.php'; require 'sql.php'; $c = new Conf(); $o = new MysqliDb($c->host, $c->username, $c->password, $c->db); $insArr = array(); foreach ($_POST as $key => $value) { if ($key == "valuation" || $key == "currentfunding") { $insArr[$key] = str_replace(",", "", $o->escape($value)); } else { $insArr[$key] = $o->escape($value); } } $insArr['timeadded'] = time(); $insArr['imageurl'] = 'data:image/png;base64,' . base64_encode(file_get_contents($_FILES['imageurl']['tmp_name'])); unset($insArr['submit']); $o->insert("startups", $insArr); // header("Location: index.php"); } require 'header.php'; ?> <script src="http://clouddelivery.textbox.io/1/getEditor?apiKey=838eacr76gusx262p3cs4fwkjk104wsqun1nyelzulvy6okw"></script> <style type="text/css"> textarea { margin:10px 0; height:500px; width: 60%; } </style> <center> <h3>Add your startup</h3> <form method="POST" enctype="multipart/form-data">
<?php // Тестовое наполнение каталога require_once 'MysqliDb.php'; require_once 'config.php'; $db = new MysqliDb(DB_SERVER, DB_USER, DB_PASS, DB_NAME); $data = array("name" => "Турецкий гамбит", "genre" => "детектив", "author" => "Акунин Б.", "year" => "2002"); $id = $db->insert('books', $data); if ($id) { echo 'book\'s sign was created. Id=' . $id . '<br>'; } $data = array("name" => "Дюна", "genre" => "фантастика", "author" => "Герберт Ф.", "year" => "1965"); $id = $db->insert('books', $data); if ($id) { echo 'book\'s sign was created. Id=' . $id . '<br>'; } $data = array("name" => "Гамлет", "genre" => "драма", "author" => "Шекспир В.", "year" => "1601"); $id = $db->insert('books', $data); if ($id) { echo 'book\'s sign was created. Id=' . $id . '<br>'; } $data = array("name" => "Война и мир", "genre" => "драма", "author" => "Толстой Л.", "year" => "1869"); $id = $db->insert('books', $data); if ($id) { echo 'book\'s sign was created. Id=' . $id . '<br>'; } $data = array("name" => "Мертвые души", "genre" => "драма", "author" => "Гоголь Н.", "year" => "1847"); $id = $db->insert('books', $data); if ($id) { echo 'book\'s sign was created. Id=' . $id . '<br>'; }
foreach ($query as $parametro_key => $parametro_valor) { // AGREGOS LAS CATEGORIAS A LA QUE PERTENECE CADA PRODUCTO $bd->where(COLUMNA_ID_PRODUCTO, $parametro_valor[COLUMNA_ID_M]); $referencias = $bd->get(TABLA_REL_PRODUCTO_CATEGORIA); $parametro_valor[VALOR_CATEGORIAS] = $referencias; $query[$parametro_key] = $parametro_valor; } $arr = array(RESPUESTA_DATA => $query, RESPUESTA_MENSAJE => MENSAJE_OK, RESPUESTA_ERROR => ERROR_NINGUNO); } else { if ($accion_form == ACCION_AGREGAR) { $data_post = $postdata->form_data; if (!isset($data_post->FOTO)) { $data_post->FOTO = NULL; } $datos = array(COLUMNA_NOMBRE => $data_post->NOMBRE, COLUMNA_DESCRIPCION => $data_post->DESCRIPCION, COLUMNA_ESTADO => $data_post->ESTADO, COLUMNA_FOTO => $data_post->FOTO, COLUMNA_MUESTRA_FULLSCREEN => $data_post->MUESTRA_FULLSCREEN, COLUMNA_MUESTRA_PRECIO => $data_post->MUESTRA_PRECIO); $id_nuevo = $bd->insert(TABLA_PRODUCTO, $datos); foreach ($data_post->CATEGORIAS as $parametro_key => $parametro_valor) { $datos = array(COLUMNA_ID_PRODUCTO => $id_nuevo, COLUMNA_ID_CATEGORIA => $parametro_valor->ID); $bd->insert(TABLA_REL_PRODUCTO_CATEGORIA, $datos); } if (!$id_nuevo) { $arr = array(RESPUESTA_ERROR => $bd->getLastError()); } else { $datos[COLUMNA_ID] = $id_nuevo; $arr = array(RESPUESTA_DATA => $datos, RESPUESTA_MENSAJE => MENSAJE_OK, RESPUESTA_ERROR => ERROR_NINGUNO); } } else { if ($accion_form == ACCION_EDITAR) { $data_post = $postdata->form_data; if (!isset($data_post->FOTO)) { $data_post->FOTO = NULL;
/** * @description Crea un proyecto y sus fotos * @param $proyecto_cambio */ function createTema($tema) { validateRol(0); $db = new MysqliDb(); $db->startTransaction(); $item_decoded = checkTemas(json_decode($tema)); $data = array('nombre' => $item_decoded->nombre, 'parent_id' => $item_decoded->parent_id, 'status' => $item_decoded->status); $result = $db->insert('temas', $data); if ($result > -1) { $db->commit(); echo json_encode($result); } else { $db->rollback(); echo json_encode(-1); } }
echo json_encode($contracts); break; case 'getContractByClient': $encrypt = new Encryption(); $id = $encrypt->decode($_GET['id']); $db = new MysqliDb(); $db->where('id', $id); $cols = array("id", "ignitor_name", "ignitor_title", "client", "ignitor_email", "client_name", "client_title", "client_company", "client_name is not null as registed"); $contracts = $db->get('contracts', null, $cols); echo json_encode($contracts); break; case 'saveToHistory': $db = new MysqliDb(); //$db->where('id',$_GET['id']); $data = array('doc_id' => $_POST['index'], 'contract_id' => $_POST['id'], 'content' => $_POST['content'], 'date' => date('Y-m-d H:i:s')); $id = $db->insert('history', $data); break; case 'getContractContent': $db = new MysqliDb(); $db->where('id', $_GET['id']); $contracts = $db->getOne('contracts'); echo json_encode($contracts); break; case 'getHistory': $db = new MysqliDb(); $history = $db->rawQuery("SELECT * FROM history WHERE contract_id = ? AND doc_id = ? order by date desc", array($_POST['id'], $_POST['index'])); echo json_encode($history); break; case 'getHistoryId': $db = new MysqliDb(); $history = $db->rawQuery("SELECT id,create_date FROM vwhistory WHERE contract_id = ? AND doc_id = ? order by id desc", array($_POST['id'], $_POST['index']));
<?php session_start(); setcookie('Login_cookie', '', time() - 3600); session_destroy(); require_once 'classes/class.mysqli.php'; require_once 'includes/required.inc.php'; $db = new MysqliDb(DBHOST, DBUSER, DBPASS, DBNAME); $insert_log = array('user_id' => $_SESSION['user_id'], 'action' => 'User Logged out!', "date_time" => date("Y-m-d H:i:s")); $log = $db->insert('log_activity', $insert_log); echo "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">";