本文整理汇总了PHP中mysql::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP mysql::insert方法的具体用法?PHP mysql::insert怎么用?PHP mysql::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysql
的用法示例。
在下文中一共展示了mysql::insert方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insert
/**
* Добавить строку в таблицу
* @param array $data
* @return int
*/
public function insert(array $data)
{
$id = $this->_db->insert($this->table, $data, $this->pkey);
// if( $id == false ) {
// throw new DB_Exeption("Error insert value");
// }
return $id;
}
示例2: testCreate_edit_form_fields
/**
* @covers ITE\mysql->create_edit_form_fields
*/
public function testCreate_edit_form_fields()
{
$table = 'log';
$fields = array('log');
$values = array('dummy text');
$result_id = $this->object->insert($table, $fields, $values);
$expected_result = '<div class="form-group"><label for="usuarios_id">Usuarios</label><select name="usuarios_id" id="usuarios_id" disabled="disabled" size="1" ><option value="0">Sin datos, deben crearse antes de este paso.</option></select></div><div class="form-group"><label for="tabla">Tabla</label><input type="text" name="tabla" id="tabla" maxlength="250" value="" placeholder="" /></div><div class="form-group"><label for="id">Id</label><input type="number" name="id" id="id" maxlength="10" value="0" placeholder="" /></div><div class="form-group"><label for="accion">Accion</label><input type="text" name="accion" id="accion" maxlength="100" value="" placeholder="" /></div><div class="form-group"><label for="log">Log</label><textarea name="log" id="log" placeholder="">dummy text</textarea></div><div class="form-group"><label for="fecha">Fecha</label><input type="datetime-local" class="datetimepicker " name="fecha" id="fecha" value="0000-00-00 00:00:00" placeholder="" /></div><input type="hidden" name="id" id="id" value="' . $result_id . '" /><input type="hidden" name="t" id="t" value="log" />';
$this->assertEquals($expected_result, $this->object->create_edit_form_fields($table, $result_id));
return $result_id;
}
示例3: intodb
function intodb($uid, $username, $result, $message)
{
$db = new mysql(HOST, USERNAME, PASSWORD, DBNAME, 'lottery_action');
$arr = array();
$arr['uid'] = $uid;
$arr['username'] = $username;
$arr['result'] = $result;
$arr['message'] = $message;
$arr['time'] = time();
$data = $db->insert($arr);
}
示例4: mysql
<?php
require_once 'classes/classe_bancodados.inc';
$bd = new mysql('localhost', 'root', '', 'cake');
$bd->insert('articles', array('title', 'body'), array('aluno 06', 'fanfarrao', '123123123'));
示例5: insert
function insert($values)
{
return parent::insert($this->getTable(), $values);
}
示例6: mysql
<?php
require_once 'classes/classe_bancodados.inc';
$bd = new mysql('localhost', 'root', '', 'cake');
$insert = $bd->insert('articles', array('title', 'body'), array('aluno 06', 'fanfarrão'));
if ($insert) {
echo "inserido com sucesso";
} else {
echo "no,no,no";
}
示例7: addNew
private function addNew($id_article)
{
if (!is_array($values = $this->getSubmitImages())) {
return;
}
$mysql = new mysql();
foreach ($values['new'] as $img) {
if ($mysql->insert($this->getTable(), array('field_name' => '"' . $this->ff->getName() . '"', 'id_article' => $id_article, 'title' => $img['title'] ? '"' . addslashes($img['title']) . '"' : 'null', 'sort' => $img['sort']))) {
$img_id = $mysql->getInsertId();
$name = $this->fieldName($img_id);
$this->values[$name] = $img['src'];
foreach ($this->formats as $param) {
$e = $this->ff->getRootElement()->appendChild($param->cloneNode(true));
$e->setAttribute('name', $name);
$e->setAttribute('uri', str_replace('%IMG_ID%', $img_id, $e->getAttribute('uri')));
}
}
}
}
示例8: trim
if ($if_already_voted) {
echo '<div class="alert alert-error" style="margin:40px;">Tu šodien jau esi balsojis šeit. Mēģini atkal rīt.</div>';
} else {
/* Ja lietotājs ir uzspiedis uz zaļās pogas */
if (isset($_POST['target_site']) and !empty($_POST['target_site'])) {
$if_ip_changed = false;
$response['state'] = 'error';
$username = trim(str_replace(' ', '', $_POST['username']));
$credits = $config['links'][$target]['credits'];
/* Pārbaudīsim vai lietotājs nav mainījis savu IP adresi */
if (!empty($username)) {
$if_ip_changed = mysql::get_all("SELECT * FROM `" . $config['mysql.table'] . "` WHERE `username` = %s AND `site_key` = %s", array($username, $target));
}
if (!$if_ip_changed) {
if (!empty($username)) {
mysql::insert($config['mysql.table'], array('site_key' => $target, 'username' => $username, 'ip' => $_SERVER['REMOTE_ADDR'], 'time_added' => time()));
mysql::q('INSERT INTO `' . $config['mysql.table'] . '_top`' . '(username,vote_count) VALUES(%s,1)' . 'ON DUPLICATE KEY UPDATE' . '`vote_count` = `vote_count` + 1', array($username));
/* Bonusu pievienošana -------------- */
//pievieno bonusus uzreiz tikai ja nav wos.lv vai 8d.lv
if (!in_array($target, array('wos', '8d'))) {
include ROOT . '/includes/bonus.php';
}
/* EOF Bonusu pievienošana -------------- */
}
$response['state'] = 'success';
$response['text'] = 'Paldies, ka mūs atbalsti. Tagad tik vēl jānobalso';
echo '<script type="text/javascript">' . "\n";
if (!empty($username)) {
echo "voter.setCookie('voter_username','" . $username . "',30);\n";
$_POST['target_site'] = str_replace('&user=NoName', '&user=' . $username, $_POST['target_site']);
}
示例9: mysql
<?php
require_once 'classes/classe_bancodados.inc';
$bd = new mysql('localhost', 'root', '', 'cake');
$insert = $bd->insert('articles', array('title', 'body'), array('aluno 120', 'novo nome'), array('aluno 220', 'novo nome'), array('aluno 320', 'novo nome'), array('aluno 420', 'novo nome'));
if ($insert) {
echo "inserido com sucesso";
} else {
echo "no no no no";
}
示例10: step5
function step5($data)
{
if ($_POST['meta_name'] == "" || $_POST['alli_tag'] == "" || $_POST['alli_name'] == "" || $_POST['user_name'] == "" || $_POST['user_password'] == "" || $_POST['user_coords1'] == "" || $_POST['user_coords2'] == "") {
return "Du musst alle Felder ausfüllen.";
}
echo "<div style=\"border:1px #000000 solid;width:400px;padding:3px;\"><b>Schritt 5: Abschluß der Installation</b><div style=\"text-align:left\">";
$t =& $_SESSION['install']['mysql'];
$file = @fopen("../accdata.php", "w");
if (!$file) {
echo "<div style=\"color:#800000\">Die Datei accdata.php konnte nicht zum schreiben öffnen. Trage die Mysqldaten bitte nachträglich ein.</div>";
} else {
fwrite($file, "<?php\n // Account Daten\n \$db_info['host'] = '" . $t['host'] . "';\n \$db_info['user'] = '" . $t['username'] . "';\n \$db_info['password'] = '" . $t['password'] . "';\n \$db_info['dbname'] = '" . $t['database'] . "';\n \$pfadzumtick = '" . $_SESSION['install']['tic_adress'] . "'; // Der Schrägstrich am Ende ist wichtig!\n\n \$tic_status = array('" . implode("', '", $GLOBALS['status']) . "');\n \$tic_version = array(" . implode(", ", $GLOBALS['version']) . ");\n ?>");
fclose($file);
@chmod("../accdata.php", 0777);
}
$mysql = new mysql(array('host' => $t['host'], 'user' => $t['username'], 'password' => $t['password'], 'dbname' => $t['database']));
unset($t);
if (isset($_SESSION['install']['tables'])) {
include "sql.php";
foreach ($_SESSION['install']['tables'] as $table) {
$mysql->multiquery($sqlquery[$table]) or die($mysql->error(__FILE__, __LINE__));
}
}
$mysql->insert("gn4meta", "name, sysmsg", "'" . $_POST['meta_name'] . "', 'Wenn dieser Text zu lesen ist dann ist leuft der TIC diese Nachricht kann unter Managment geändert werden.'") or die($mysql->error(__FILE__, __LINE__));
$ticid = $mysql->insert_id();
$mysql->insert("gn4vars", "name, value, ticid", "'lastscanclean', '" . date("H:n d.m.Y.") . "', '" . $ticid . "'") or die($mysql->error(__FILE__, __LINE__));
$mysql->insert("gn4vars", "name, value, ticid", "'forumpriority', '0', '" . $ticid . "'") or die($mysql->error(__FILE__, __LINE__));
$mysql->insert("gn4vars", "name, value, ticid", "'lasttick', '" . date("H:n:s") . "', '" . $ticid . "'") or die($mysql->error(__FILE__, __LINE__));
$mysql->insert("gn4vars", "name, value, ticid", "'style', '../gnstyle', '" . $ticid . "'") or die($mysql->error(__FILE__, __LINE__));
$mysql->insert("gn4vars", "name, value, ticid", "'attplaner', 'aktiv', '" . $ticid . "'") or die($mysql->error(__FILE__, __LINE__));
$mysql->insert("gn4vars", "name, value, ticid", "'botpw', '', '" . $ticid . "'") or die($mysql->error(__FILE__, __LINE__));
$mysql->insert("gn4vars", "name, value, ticid", "'tickdauer', '15', '" . $ticid . "'") or die(mysql_error(__FILE__, __LINE__));
$mysql->insert("gn4allianzen", "ticid, name , tag", "'" . $ticid . "', '" . $_POST['alli_name'] . "', '" . $_POST['alli_tag'] . "'") or die($mysql->error(__FILE__, __LINE__));
$alli_id = $mysql->insert_id();
$mysql->insert("gn4accounts", "ticid, name, passwort, galaxie, planet, rang, allianz", "'" . $ticid . "', '" . $_POST['user_name'] . "', '" . md5($_POST['user_password']) . "', '" . $_POST['user_coords1'] . "', '" . $_POST['user_coords2'] . "', '5', '" . $alli_id . "'") or die($mysql->error(__FILE__, __LINE__));
echo "Die Installation wurde erfolgreich abgeschlossen.<br />Bitte lösche den Ordner installer vom Server.<br />Danach kannst du dich <a href=\"../index.php\">hier</a> mit deinen Accountdaten einloggen.</div>";
return "";
}