本文整理汇总了PHP中JDatabase::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP JDatabase::execute方法的具体用法?PHP JDatabase::execute怎么用?PHP JDatabase::execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JDatabase
的用法示例。
在下文中一共展示了JDatabase::execute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cleanBeforeMigrate
public function cleanBeforeMigrate()
{
$db = $this->dbo;
$query = $this->dbo->getQuery(true);
$query->delete($db->quoteName('#__akrecipes_recipe'));
$this->dbo->setQuery($query);
$this->dbo->execute();
// now content items
$query = $this->dbo->getQuery(true);
$conditions = array($db->quoteName('id') . ' <> 1');
$query->delete($db->quoteName('#__content'));
$query->where($conditions);
$this->dbo->setQuery($query);
$this->dbo->execute();
// now categories
$query = $this->dbo->getQuery(true);
$conditions = array($db->quoteName('extension') . ' = ' . $db->quote('com_akrecipes'));
$query->delete($db->quoteName('#__categories'));
$query->where($conditions);
$this->dbo->setQuery($query);
$this->dbo->execute();
// now categories
$query = $this->dbo->getQuery(true);
$conditions = array($db->quoteName('extension') . ' = ' . $db->quote('com_content'), '!(' . $db->quoteName('id') . ' = 2 OR ' . $db->quoteName('id') . ' = 26)');
$query->delete($db->quoteName('#__categories'));
$query->where($conditions);
$this->dbo->setQuery($query);
//$this->dbo->execute();
}
示例2: query
/**
* Execute the query
*
* @param string $sql The query (optional, it will use the setQuery one otherwise)
* @return \mysqli_result|\resource|boolean A database resource if successful, FALSE if not.
*
* @throws \RuntimeException
*/
public function query($sql = null)
{
if ($sql !== null) {
$this->setQuery($sql);
}
return $this->_db->execute();
}
示例3: publish
/**
* Method to set the publishing state for a row or list of rows in the database
* table. The method respects checked out rows by other users and will attempt
* to checkin rows that it can after adjustments are made.
*
* @param mixed $pks An optional array of primary key values to update. If not set the instance property value is used.
* @param integer $state The publishing state. eg. [0 = unpublished, 1 = published]
* @param integer $userId The user id of the user performing the operation.
*
* @return boolean True on success.
*
* @link http://docs.joomla.org/JTable/publish
* @since 11.1
*/
public function publish($pks = null, $state = 1, $userId = 0)
{
// Initialise variables.
$k = $this->_tbl_key;
// Sanitize input.
JArrayHelper::toInteger($pks);
$userId = (int) $userId;
$state = (int) $state;
// If there are no primary keys set check to see if the instance key is set.
if (empty($pks)) {
if ($this->{$k}) {
$pks = array($this->{$k});
} else {
$e = new JException(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
$this->setError($e);
return false;
}
}
// Update the publishing state for rows with the given primary keys.
$query = $this->_db->getQuery(true);
$query->update($this->_tbl);
$query->set('published = ' . (int) $state);
// Determine if there is checkin support for the table.
if (property_exists($this, 'checked_out') || property_exists($this, 'checked_out_time')) {
$query->where('(checked_out = 0 OR checked_out = ' . (int) $userId . ')');
$checkin = true;
} else {
$checkin = false;
}
// Build the WHERE clause for the primary keys.
$query->where($k . ' = ' . implode(' OR ' . $k . ' = ', $pks));
$this->_db->setQuery($query);
// Check for a database error.
if (!$this->_db->execute()) {
$e = new JException(JText::sprintf('JLIB_DATABASE_ERROR_PUBLISH_FAILED', get_class($this), $this->_db->getErrorMsg()));
$this->setError($e);
return false;
}
// If checkin is supported and all rows were adjusted, check them in.
if ($checkin && count($pks) == $this->_db->getAffectedRows()) {
// Checkin the rows.
foreach ($pks as $pk) {
$this->checkin($pk);
}
}
// If the JTable instance value is in the list of primary keys that were set, set the instance.
if (in_array($this->{$k}, $pks)) {
$this->published = $state;
}
$this->setError('');
return true;
}
示例4: createItemToRecipeMap
public function createItemToRecipeMap()
{
$query = '
DROP TABLE IF EXISTS `#__k2_recipe_map`;';
$query_set = $this->dbo->setQuery($query);
$this->dbo->execute();
$query = 'CREATE table `#__k2_recipe_map` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`k2_item_id` INT NOT NULL ,
`new_item_id` INT NOT NULL ,
`item_type` INT NOT NULL ,
PRIMARY KEY (`id`)
) ; ';
$query_set = $this->dbo->setQuery($query);
$this->dbo->execute();
}
示例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: query
/**
* Execute a query
*
* The result returned by this method is the same of the JDatabase::execute() method
* Basically, it returns if the operation was successful or not. Generally used
* by DELETE and UPDATE operations
*
* @param string $query The query to execute
*
* @return mixed The result of the query
*
* @throws RuntimeException
*
* @since 1.0.0
*/
public function query($query)
{
// query database table
$this->_database->setQuery($query);
return $this->_database->execute();
}