本文整理汇总了PHP中JDatabase::insertid方法的典型用法代码示例。如果您正苦于以下问题:PHP JDatabase::insertid方法的具体用法?PHP JDatabase::insertid怎么用?PHP JDatabase::insertid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JDatabase
的用法示例。
在下文中一共展示了JDatabase::insertid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveRule
public function saveRule()
{
$refTab = JRequest::getVar('reference_table', '');
$pfx = $this->db->getPrefix();
$tab = $this->str_replace_first($refTab, $pfx, '');
$this->db->setQuery("\n\t\t\n\t\t\tInsert \n\t\t\tInto \n\t\t\t\t#__facileforms_integrator_rules\n\t\t\t(\n\t\t\t\tname,\n\t\t\t\tform_id,\n\t\t\t\treference_table,\n\t\t\t\ttype\n\t\t\t) \n\t\t\tValues\n\t\t\t(\n\t\t\t\t" . $this->db->Quote(JRequest::getVar('rule_name')) . ",\n\t\t\t\t" . $this->db->Quote(JRequest::getVar('form_id')) . ",\n\t\t\t\t" . $this->db->Quote($tab) . ",\n\t\t\t\t" . $this->db->Quote(JRequest::getVar('type')) . "\n\t\t\t)\n\t\t\n\t\t");
$this->db->query();
$ruleId = $this->db->insertid();
return $ruleId;
}
示例2: queryInsert
/**
* Funzione per eseguire un inserimento nel database
* FUNZIONE CHIAMATA DAL MODULO DEVE ESSERE SEMPRE IMPLEMENTATA QUI
* @param string Nome della tabella
* @param array Valori da inserire
* @param boolean Decide se tornare l'id autoincrementale dell'ultima riga inserita
* @return mixed Se $returnInsertId=false torna l'esito della query (TRUE o FALSE)
*/
public function queryInsert($table, $values, $returnInsertId = false)
{
$q = $this->buildQueryInsert($table, $values);
$this->db->setQuery($q);
$result = $this->db->query();
if ($result === FALSE) {
return false;
} else {
if ($returnInsertId) {
return $this->db->insertid();
} else {
return true;
}
}
}
示例3: saveRule
public function saveRule(){
$refTab = JRequest::getVar('reference_table', '');
$pfx = $this->db->getPrefix();
$tab = $this->str_replace_first($refTab, $pfx, '');
$this->db->setQuery("
Insert
Into
#__facileforms_integrator_rules
(
name,
form_id,
reference_table,
type
)
Values
(
".$this->db->Quote(JRequest::getVar('rule_name')).",
".$this->db->Quote(JRequest::getVar('form_id')).",
".$this->db->Quote($tab).",
".$this->db->Quote(JRequest::getVar('type'))."
)
");
$this->db->query();
$ruleId = $this->db->insertid();
return $ruleId;
}
示例4: insertid
/**
* Returns the insert_id() from Mysql
*
* @return int
*/
public function insertid()
{
return $this->_db->insertid();
}
示例5: sortearEliminatoria
function sortearEliminatoria(array $equipos, $numRows_eq, JDatabase $db_ins_part, $id_grupo, JDatabase $db_ins_jor)
{
$cantidad_equipos = $numRows_eq;
$cantidad_partidos = $cantidad_equipos - 1;
$cantidad_jornadas = ceil(log($cantidad_equipos, 2));
$preliminares = $cantidad_equipos - pow(2, floor(log($cantidad_equipos, 2)));
$standby = $cantidad_equipos - $preliminares * 2;
$partidos_potencia2 = $cantidad_equipos / 2;
$partidos_ronda2 = ($standby + $preliminares) / 2;
// echo "Equipos:".$cantidad_equipos."<br>";
// echo "Partidos:".$cantidad_partidos."<br>";
// echo "Jornadas:".$cantidad_jornadas."<br>";
// echo "Preliminares:".$preliminares."<br>";
// echo "Espera:".$standby."<br>";
// echo "Partidos potencia 2: ".$partidos_potencia2."<br>";
// echo "Partidos ronda 2: ".$partidos_ronda2."<br>";
$partidos = array();
$equipos_partido = array();
$nombre_jornadas = array('Final', 'Semifinal', 'Cuartos de Final', 'Octavos de Final', 'Primera Ronda', 'Preliminares');
$x = 0;
// $y=0;
// $y=$cantidad_equipos-1;
$y = $preliminares * 2 - 1;
//Insertar primer jornada
for ($i = 0; $i < $cantidad_jornadas; $i++) {
if ($preliminares == 0) {
switch ($i) {
case 0:
$descr_jor = $nombre_jornadas[$i];
case 1:
$descr_jor = $nombre_jornadas[$i];
case 2:
$descr_jor = $nombre_jornadas[$i];
case 3:
$descr_jor = $nombre_jornadas[$i];
case 4:
$descr_jor = $nombre_jornadas[$i];
case 5:
$descr_jor = $nombre_jornadas[$i];
}
} else {
switch ($i) {
case 0:
$descr_jor = $nombre_jornadas[$i];
case 1:
$descr_jor = $nombre_jornadas[$i];
case 2:
$descr_jor = $nombre_jornadas[$i];
case 3:
$descr_jor = $nombre_jornadas[$i];
case 4:
$descr_jor = $nombre_jornadas[$i];
case 5:
$descr_jor = $nombre_jornadas[$i];
}
}
try {
$query_ins_jor = $db_ins_jor->getQuery(true);
$columns = array('descripcion', 'id_grupo', 'numero');
$values = array($db_ins_jor->quote($descr_jor), $id_grupo, $i + 1);
$query_ins_jor->insert($db_ins_jor->quoteName('jornada'))->columns($db_ins_jor->quoteName($columns))->values(implode(',', $values));
$db_ins_jor->setQuery($query_ins_jor);
$db_ins_jor->execute();
$id_jornada = $db_ins_jor->insertid();
} catch (Exception $e) {
echo $e;
}
if ($preliminares != 0) {
$partidos_ronda = pow(2, $i);
if ($i == $cantidad_jornadas - 1) {
$partidos_ronda = $preliminares;
}
for ($j = 0; $j < $partidos_ronda; $j++) {
if ($i == $cantidad_jornadas - 1) {
$equipos_partido[0] = $equipos[$x];
$equipos_partido[1] = $equipos[$x + 1];
$partidos[$j] = $equipos_partido;
try {
$query_ins_part = $db_ins_part->getQuery(true);
// Insert columns.
$columns = array('id_torneo', 'id_jornada');
// Insert values.
$values = array($_SESSION['id_torneo'], $id_jornada);
// Prepare the insert query.
$query_ins_part->insert($db_ins_part->quoteName('partido'))->columns($db_ins_part->quoteName($columns))->values(implode(',', $values));
// Set the query using our newly populated query object and execute it.
$db_ins_part->setQuery($query_ins_part);
$db_ins_part->execute();
$id_partido = $db_ins_part->insertid();
$equipos_p = $partidos[$j];
$query_ins_part = $db_ins_part->getQuery(true);
// Insert columns.
$columns = array('id_equipo1', 'id_equipo2', 'id_partido');
// Insert values.
$values = array($equipos_p[0]->id_eq, $equipos_p[1]->id_eq, $id_partido);
// Prepare the insert query.
$query_ins_part->insert($db_ins_part->quoteName('partido_equipos'))->columns($db_ins_part->quoteName($columns))->values(implode(',', $values));
// Set the query using our newly populated query object and execute it.
$db_ins_part->setQuery($query_ins_part);
$db_ins_part->execute();
//.........这里部分代码省略.........
示例6: save
public function save($form, $formName, $formTitle, array $formOptions, $templateCode, array $areas, $pages = 1)
{
$templateCodeProcessed = $templateCode;
$this->db->setQuery("Select id From #__facileforms_forms Where id = " . $this->db->Quote($form) . "");
if (count($this->db->loadObjectList()) == 0) {
$this->db->setQuery("Insert Into #__facileforms_forms \n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tpackage,\n\t\t\t\t\t\t\ttemplate_code,\n\t\t\t\t\t\t\ttemplate_areas,\n\t\t\t\t\t\t\tpublished,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\tclass1,\n\t\t\t\t\t\t\twidth,\n\t\t\t\t\t\t\theight,\n\t\t\t\t\t\t\tpages\n\t\t\t\t\t\t) \n\t\t\t\t\t\tValues \n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t'EasyModeForms',\n\t\t\t\t\t\t\t" . trim($this->db->Quote($templateCode), "\t, ,\n,\r") . ",\n\t\t\t\t\t\t\t" . $this->db->Quote(Zend_Json::encode($areas)) . ",\n\t\t\t\t\t\t\t'1',\n\t\t\t\t\t\t\t" . trim($this->db->Quote($formName), "\t, ,\n,\r") . ",\n\t\t\t\t\t\t\t" . trim($this->db->Quote($formTitle), "\t, ,\n,\r") . ",\n\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t'400',\n\t\t\t\t\t\t\t'500',\n\t\t\t\t\t\t\t" . $this->db->Quote($pages) . "\n\t\t\t\t\t\t)");
$this->db->query();
$form = $this->db->insertid();
} else {
$this->db->setQuery("Update \n\t\t\t\t\t\t\t#__facileforms_forms\n\t\t\t\t\t\t Set \n\t\t\t\t\t\t\ttemplate_code = " . $this->db->Quote(trim($templateCode), "\t, ,\n,\r") . ",\n\t\t\t\t\t\t\ttemplate_areas = " . $this->db->Quote(Zend_Json::encode($areas)) . ",\n\t\t\t\t\t\t\tname = " . trim($this->db->Quote($formName), "\t, ,\n,\r") . ",\n\t\t\t\t\t\t\ttitle = " . trim($this->db->Quote($formTitle), "\t, ,\n,\r") . ",\n\t\t\t\t\t\t\tpages = " . $this->db->Quote($pages) . "\n\t\t\t\t\t\t Where\n\t\t\t\t\t\t\tid = " . $this->db->Quote($form) . "\n\t\t\t\t\t\t");
$this->db->query();
}
$notRemoveIds = '';
$i = 0;
foreach ($areas as $area) {
$elementCount = 0;
foreach ($area['elements'] as $element) {
$elementId = -1;
if ($element['dbId'] == 0) {
$this->db->setQuery("Insert Into #__facileforms_elements\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tmailback,\n\t\t\t\t\t\t\t\tmailbackfile,\n\t\t\t\t\t\t\t\tform,\n\t\t\t\t\t\t\t\tpage,\n\t\t\t\t\t\t\t\tpublished,\n\t\t\t\t\t\t\t\tordering,\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\tclass1,\n\t\t\t\t\t\t\t\tclass2,\n\t\t\t\t\t\t\t\tlogging,\n\t\t\t\t\t\t\t\tposx,\n\t\t\t\t\t\t\t\tposxmode,\n\t\t\t\t\t\t\t\tposy,\n\t\t\t\t\t\t\t\tposymode,\n\t\t\t\t\t\t\t\twidth,\n\t\t\t\t\t\t\t\twidthmode,\n\t\t\t\t\t\t\t\theight,\n\t\t\t\t\t\t\t\theightmode,\n\t\t\t\t\t\t\t\tflag1,\n\t\t\t\t\t\t\t\tflag2,\n\t\t\t\t\t\t\t\tdata1,\n\t\t\t\t\t\t\t\tdata2,\n\t\t\t\t\t\t\t\tdata3,\n\t\t\t\t\t\t\t\tscript1cond,\n\t\t\t\t\t\t\t\tscript1id,\n\t\t\t\t\t\t\t\tscript1code,\n\t\t\t\t\t\t\t\tscript1flag1,\n\t\t\t\t\t\t\t\tscript1flag2,\n\t\t\t\t\t\t\t\tscript2cond,\n\t\t\t\t\t\t\t\tscript2id,\n\t\t\t\t\t\t\t\tscript2code,\n\t\t\t\t\t\t\t\tscript2flag1,\n\t\t\t\t\t\t\t\tscript2flag2,\n\t\t\t\t\t\t\t\tscript2flag3,\n\t\t\t\t\t\t\t\tscript2flag4,\n\t\t\t\t\t\t\t\tscript2flag5,\n\t\t\t\t\t\t\t\tscript3cond,\n\t\t\t\t\t\t\t\tscript3id,\n\t\t\t\t\t\t\t\tscript3code,\n\t\t\t\t\t\t\t\tscript3msg\n\t\t\t\t\t\t\t) \n\t\t\t\t\t\t\tValues \n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['mailback']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['mailbackfile']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($form) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote(isset($element['page']) ? $element['page'] : 1) . ",\n\t\t\t\t\t\t\t\t'1',\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['orderNumber'] > -1 ? $element['orderNumber'] : $element['appElementOrderId']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['name']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['title']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['bfType']) . ",\n\t\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t\t'1',\n\t\t\t\t\t\t\t\t'0',\n\t\t\t\t\t\t\t\t'0',\n\t\t\t\t\t\t\t\t'" . 40 * $elementCount . "',\n\t\t\t\t\t\t\t\t'0',\n\t\t\t\t\t\t\t\t'20',\n\t\t\t\t\t\t\t\t'0',\n\t\t\t\t\t\t\t\t'20',\n\t\t\t\t\t\t\t\t'0',\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['flag1']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['flag2']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['data1']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['data2']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['data3']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script1cond']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script1id']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script1code']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script1flag1']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script1flag2']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script2cond']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script2id']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script2code']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script2flag1']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script2flag2']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script2flag3']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script2flag4']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script2flag5']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script3cond']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script3id']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script3code']) . ",\n\t\t\t\t\t\t\t\t" . $this->db->Quote($element['script3msg']) . "\n\t\t\t\t\t\t\t)");
$this->db->query();
$elementId = $this->db->insertid();
$areas[$i]['elements'][$elementCount]['dbId'] = $elementId;
} else {
// fix ids of copied elements
$this->db->setQuery("Select id From #__facileforms_elements Where name = " . $this->db->Quote($element['name']) . " And form = " . $this->db->Quote($form) . " ");
$elementCheck = $this->db->loadObjectList();
foreach ($elementCheck as $check) {
if ($check->id != intval($element['dbId'])) {
$element['dbId'] = $check->id;
$areas[$i]['elements'][$elementCount]['dbId'] = $check->id;
}
break;
}
$this->db->setQuery("Update #__facileforms_elements Set\n\t\t\t\t\t\t\t\tmailback=" . $this->db->Quote($element['mailback']) . ",\n\t\t\t\t\t\t\t\tmailbackfile=" . $this->db->Quote($element['mailbackfile']) . ",\n\t\t\t\t\t\t\t\tform=" . $this->db->Quote($form) . ",\n\t\t\t\t\t\t\t\tpage=" . $this->db->Quote(isset($element['page']) ? $element['page'] : 1) . ",\n\t\t\t\t\t\t\t\tpublished='1',\n\t\t\t\t\t\t\t\tordering=" . $this->db->Quote($element['orderNumber'] > -1 ? $element['orderNumber'] : $element['appElementOrderId']) . ",\n\t\t\t\t\t\t\t\tname=" . $this->db->Quote($element['name']) . ",\n\t\t\t\t\t\t\t\ttitle=" . $this->db->Quote($element['title']) . ",\n\t\t\t\t\t\t\t\ttype=" . $this->db->Quote($element['bfType']) . ",\n\t\t\t\t\t\t\t\tclass1='',\n\t\t\t\t\t\t\t\tclass2='',\n\t\t\t\t\t\t\t\tlogging='1',\n\t\t\t\t\t\t\t\tposx='0',\n\t\t\t\t\t\t\t\tposxmode='0',\n\t\t\t\t\t\t\t\tposy='" . 40 * $elementCount . "',\n\t\t\t\t\t\t\t\tposymode='0',\n\t\t\t\t\t\t\t\twidth='20',\n\t\t\t\t\t\t\t\twidthmode='0',\n\t\t\t\t\t\t\t\theight='20',\n\t\t\t\t\t\t\t\theightmode='0',\n\t\t\t\t\t\t\t\tflag1=" . $this->db->Quote($element['flag1']) . ",\n\t\t\t\t\t\t\t\tflag2=" . $this->db->Quote($element['flag2']) . ",\n\t\t\t\t\t\t\t\tdata1=" . $this->db->Quote($element['data1']) . ",\n\t\t\t\t\t\t\t\tdata2=" . $this->db->Quote($element['data2']) . ",\n\t\t\t\t\t\t\t\tdata3=" . $this->db->Quote($element['data3']) . ",\n\t\t\t\t\t\t\t\tscript1cond=" . $this->db->Quote($element['script1cond']) . ",\n\t\t\t\t\t\t\t\tscript1id=" . $this->db->Quote($element['script1id']) . ",\n\t\t\t\t\t\t\t\tscript1code=" . $this->db->Quote($element['script1code']) . ",\n\t\t\t\t\t\t\t\tscript1flag1=" . $this->db->Quote($element['script1flag1']) . ",\n\t\t\t\t\t\t\t\tscript1flag2=" . $this->db->Quote($element['script1flag2']) . ",\n\t\t\t\t\t\t\t\tscript2cond=" . $this->db->Quote($element['script2cond']) . ",\n\t\t\t\t\t\t\t\tscript2id=" . $this->db->Quote($element['script2id']) . ",\n\t\t\t\t\t\t\t\tscript2code=" . $this->db->Quote($element['script2code']) . ",\n\t\t\t\t\t\t\t\tscript2flag1=" . $this->db->Quote($element['script2flag1']) . ",\n\t\t\t\t\t\t\t\tscript2flag2=" . $this->db->Quote($element['script2flag2']) . ",\n\t\t\t\t\t\t\t\tscript2flag3=" . $this->db->Quote($element['script2flag3']) . ",\n\t\t\t\t\t\t\t\tscript2flag4=" . $this->db->Quote($element['script2flag4']) . ",\n\t\t\t\t\t\t\t\tscript2flag5=" . $this->db->Quote($element['script2flag5']) . ",\n\t\t\t\t\t\t\t\tscript3cond=" . $this->db->Quote($element['script3cond']) . ",\n\t\t\t\t\t\t\t\tscript3id=" . $this->db->Quote($element['script3id']) . ",\n\t\t\t\t\t\t\t\tscript3code=" . $this->db->Quote($element['script3code']) . ",\n\t\t\t\t\t\t\t\tscript3msg=" . $this->db->Quote($element['script3msg']) . "\n\t\t\t\t\t\t\tWhere\n\t\t\t\t\t\t\t\tid = " . $this->db->Quote($element['dbId']) . "\n\t\t\t\t\t\t\t");
$this->db->query();
$elementId = $element['dbId'];
}
$notRemoveIds .= ' id<>' . $this->db->Quote($elementId) . ' And ';
$templateCodeProcessed = str_replace('ff_listItem' . $element['rndId'], 'ff_listItem' . $elementId, $templateCodeProcessed);
$templateCodeProcessed = str_replace('ff_iconCaption' . $element['rndId'], 'ff_iconCaption' . $elementId, $templateCodeProcessed);
$templateCodeProcessed = str_replace('ff_dragBox' . $element['rndId'], 'ff_dragBox' . $elementId, $templateCodeProcessed);
$templateCodeProcessed = str_replace('ff_label' . $element['rndId'], 'ff_label' . $elementId, $templateCodeProcessed);
$templateCodeProcessed = str_replace('ff_elem' . $element['rndId'], 'ff_elem' . $elementId, $templateCodeProcessed);
$templateCodeProcessed = str_replace('ff_nm_' . $element['rndId'] . '[]', 'ff_nm_' . $element['name'] . '[]', $templateCodeProcessed);
$templateCodeProcessed = str_replace('ff_static' . $element['rndId'], 'ff_static' . $elementId, $templateCodeProcessed);
$templateCodeProcessed = str_replace('ff_div' . $element['rndId'], 'ff_div' . $elementId, $templateCodeProcessed);
$templateCodeProcessed = str_replace('ff_captcha' . $element['rndId'], 'ff_captcha' . $elementId, $templateCodeProcessed);
$templateCodeProcessed = str_replace('ff_capimg' . $element['rndId'], 'ff_capimg' . $elementId, $templateCodeProcessed);
$templateCodeProcessed = str_replace('ff_break' . $element['rndId'], 'ff_break' . $elementId, $templateCodeProcessed);
$templateCodeProcessed = str_replace('readonly="readonly"', 'disabled="disabled"', $templateCodeProcessed);
$elementCount++;
}
$i++;
}
if (strlen($notRemoveIds) != 0) {
$this->db->setQuery("Delete From #__facileforms_elements Where " . $notRemoveIds . " form = " . $this->db->Quote($form) . " ");
$this->db->query();
} else {
$this->db->setQuery("Delete From #__facileforms_elements Where form = " . $this->db->Quote($form) . " ");
$this->db->query();
}
$this->db->setQuery("Update \n\t\t\t\t\t\t\t#__facileforms_forms\n\t\t\t\t\t\t Set \n\t\t\t\t\t\t\ttemplate_code_processed = " . $this->db->Quote(trim($templateCodeProcessed)) . ",\n\t\t\t\t\t\t\ttemplate_areas = " . $this->db->Quote(Zend_Json::encode($areas)) . "\n\t\t\t\t\t\t Where\n\t\t\t\t\t\t\tid = " . $this->db->Quote($form) . "\n\t\t\t\t\t\t");
$this->db->query();
return $form;
}