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


PHP JDatabase::quote方法代码示例

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


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

示例1: where

 /**
  * Filter by field.
  *
  * @param  string        $field       Field name.
  * @param  string        $operation   Operation (>|>=|<|<=|=|IN|NOT IN)
  * @param  string|array  $value       Value.
  *
  * @return $this
  */
 public function where($field, $operation, $value)
 {
     $operation = strtoupper($operation);
     switch ($operation) {
         case '>':
         case '>=':
         case '<':
         case '<=':
         case '=':
             $this->query->where("{$this->db->quoteName($field)} {$operation} {$this->db->quote($value)}");
             break;
         case 'BETWEEN':
             list($a, $b) = (array) $value;
             $this->query->where("{$this->db->quoteName($field)} BETWEEN {$this->db->quote($a)} AND {$this->db->quote($b)}");
             break;
         case 'IN':
         case 'NOT IN':
             $value = (array) $value;
             if (empty($value)) {
                 // WHERE field IN (nothing).
                 $this->query->where('0');
             } else {
                 $list = implode(',', $value);
                 $this->query->where("{$this->db->quoteName($field)} {$operation} ({$list})");
             }
             break;
     }
     return $this;
 }
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:38,代码来源:finder.php

示例2: Former_AddChange

 private function Former_AddChange(&$data)
 {
     $existing = $this->getExistingRecords(array(), "_former");
     foreach ($data["Former_AddChange"] as $inn => $item) {
         if (isset($existing[$inn])) {
             if ($this->obsolete($item, $existing)) {
                 continue;
             }
             $id = $existing[$inn]->id;
         } else {
             $id = 0;
         }
         $inserts[] = "(" . $id . "," . $this->_db->quote($item["name"]) . "," . $this->_db->quote($item["inn"]) . "," . $this->_db->quote($item["adding_date"]) . "," . $item["cause"] . ")";
         if ($this->met > 0 && microtime(true) - $this->started > $this->met) {
             $this->setError("COM_SRO_RUNTIME_LIMIT");
             break;
         }
     }
     if (count($inserts)) {
         $sql = "REPLACE INTO {$this->tbl_former} (id,name,inn,adding_date,cause) " . " VALUES " . implode(",", $inserts);
         $this->_db->setQuery($sql);
         if (!$this->_db->query()) {
             $this->setError("Ошибка при обновлении:" . $this->_db->getErrorMsg());
         }
     }
     unset($data["Former_AddChange"]);
 }
开发者ID:salatproduction,项目名称:SRO-Registry-Joomla,代码行数:27,代码来源:update.php

示例3: quote

 /**
  * Method to quote and optionally escape a string to database requirements for insertion into the database.
  * @param   string $text   The string to quote.
  * @param   bool   $escape True to escape the string, false to leave it unchanged.
  * @return  string  The quoted input string.
  */
 public function quote($text, $escape = true)
 {
     if (version_compare(JVERSION, '1.5.0', '>')) {
         $escape = false;
     } else {
         $escape = true;
     }
     return $this->db->quote($escape ? $this->db->escape($text) : $text);
 }
开发者ID:alexmixaylov,项目名称:real,代码行数:15,代码来源:JBDatabaseQuery.php

示例4: jotcache_upgrade

function jotcache_upgrade(JDatabase $db)
{
    $message = '';
    $query = $db->getQuery(true);
    $query->select('COUNT(*)')->from('#__jotcache_exclude')->where('type=1');
    $tplex_count = $db->setQuery($query)->loadResult();
    if ($tplex_count == 0) {
        return false;
    }
    $query->clear('where');
    $query->where('type=4');
    $count = $db->setQuery($query)->loadResult();
    if ($count == 0) {
        $query->clear('select')->clear('where');
        $query->select($db->quoteName('value'))->from($db->quoteName('#__template_styles', 's'))->where('name=s.id')->where('type=1')->order('s.home');
        $defs = $db->setQuery($query)->loadResultArray();
        $positions = array();
        foreach ($defs as $def) {
            $def_array = unserialize($def);
            $positions = array_merge($positions, $def_array);
        }
        $query->clear();
        $query->select('position')->from('#__modules')->where('client_id = 0')->where('published = 1')->where('position <>' . $db->quote(''))->group('position')->order('position');
        $db->setQuery($query);
        $items = $db->loadResultArray();
        $cleaned_positions = array();
        foreach ($items as $item) {
            if (array_key_exists($item, $positions)) {
                $cleaned_positions[$item] = $positions[$item];
            }
        }
        $defs = serialize($cleaned_positions);
        $query->clear();
        $query->insert('#__jotcache_exclude')->columns('name,value,type')->values('1,' . $db->quote($defs) . ',4');
        if ($db->setQuery($query)->query()) {
            $message = "TABLE #__jotcache_exclude has been upgraded. Check JotCache TPL exclude definitions for correct values.";
        } else {
            JError::raiseNotice(100, $db->getErrorMsg());
        }
        return $message;
    }
}
开发者ID:alesconti,项目名称:FF_2015,代码行数:42,代码来源:install.php

示例5: Quote

 /**
  * Get a quoted database escaped string (or array of strings)
  *
  * @param  string|array  $text
  * @param  boolean       $escape
  * @return string
  */
 public function Quote($text, $escape = true)
 {
     if (is_array($text)) {
         // CMS 2.5 doesn't support arrays:
         foreach ($text as $k => $v) {
             $text[$k] = $this->Quote($v, $escape);
         }
         return $text;
     }
     return $this->_db->quote($text, $escape);
 }
开发者ID:bobozhangshao,项目名称:HeartCare,代码行数:18,代码来源:CmsDatabaseDriver.php

示例6: stringMatch

 /**
  * @param $field
  * @param $data
  */
 protected function stringMatch($field, $data)
 {
     $wheres = array();
     foreach ($data as $match) {
         $match = trim($match);
         if (!empty($match)) {
             $wheres[] = $field . ' LIKE ' . $this->db->quote('%' . $this->db->escape($match, true) . '%');
         }
     }
     if (!empty($wheres)) {
         $this->filter_where[] = '(' . implode(' OR ', $wheres) . ')';
     }
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:17,代码来源:AbstractJoomlaPlatformFilter.php

示例7: canDelete

 /**
  * Generic check for whether dependencies exist for this object in the database schema
  *
  * Can be overloaded/supplemented by the child class
  *
  * @param   mixed  $pk     An optional primary key value check the row for.  If not
  * set the instance property value is used.
  * @param   array  $joins  An optional array to compiles standard joins formatted like:
  * [label => 'Label', name => 'table name' , idfield => 'field', joinfield => 'field']
  *
  * @return  boolean  True on success.
  *
  * @deprecated    12.1
  * @link    http://docs.joomla.org/JTable/canDelete
  * @since   11.1
  */
 public function canDelete($pk = null, $joins = null)
 {
     // Deprecation warning.
     JLog::add('JTable::canDelete() is deprecated.', JLog::WARNING, 'deprecated');
     // Initialise variables.
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     // If no primary key is given, return false.
     if ($pk === null) {
         return false;
     }
     if (is_array($joins)) {
         // Get a query object.
         $query = $this->_db->getQuery(true);
         // Setup the basic query.
         $query->select($this->_db->quoteName($this->_tbl_key));
         $query->from($this->_db->quoteName($this->_tbl));
         $query->where($this->_db->quoteName($this->_tbl_key) . ' = ' . $this->_db->quote($this->{$k}));
         $query->group($this->_db->quoteName($this->_tbl_key));
         // For each join add the select and join clauses to the query object.
         foreach ($joins as $table) {
             $query->select('COUNT(DISTINCT ' . $table['idfield'] . ') AS ' . $table['idfield']);
             $query->join('LEFT', $table['name'] . ' ON ' . $table['joinfield'] . ' = ' . $k);
         }
         // Get the row object from the query.
         $this->_db->setQuery((string) $query, 0, 1);
         $row = $this->_db->loadObject();
         // Check for a database error.
         if ($this->_db->getErrorNum()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         $msg = array();
         $i = 0;
         foreach ($joins as $table) {
             $k = $table['idfield'] . $i;
             if ($row->{$k}) {
                 $msg[] = JText::_($table['label']);
             }
             $i++;
         }
         if (count($msg)) {
             $this->setError("noDeleteRecord" . ": " . implode(', ', $msg));
             return false;
         } else {
             return true;
         }
     }
     return true;
 }
开发者ID:NavaINT1876,项目名称:ccustoms,代码行数:66,代码来源:table.php

示例8: testQuote

	/**
	 * Tests the JDatabase::quote method.
	 *
	 * @return  void
	 *
	 * @since   11.4
	 */
	public function testQuote()
	{
		$this->assertThat(
			$this->db->quote('test', false),
			$this->equalTo("'test'"),
			'Tests the without escaping.'
		);

		$this->assertThat(
			$this->db->quote('test'),
			$this->equalTo("'-test-'"),
			'Tests the with escaping (default).'
		);
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:21,代码来源:JDatabaseTest.php

示例9: doExecute

 /**
  * Custom doExecute method.
  *
  * This method loads a list of the published plugins from the 'cron' group,
  * then loads the plugins and registers them against the 'doCron' event.
  * The event is then triggered and results logged.
  *
  * Any configuration for the cron plugins is done via the Joomla CMS
  * administrator interface and plugin parameters.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function doExecute()
 {
     //
     // Check we have some critical information.
     //
     if (!defined('JPATH_PLUGINS') || !is_dir(JPATH_PLUGINS)) {
         throw new Exception('JPATH_PLUGINS not defined');
     }
     // Add a start message.
     JLog::add('Starting cron run.');
     //
     // Prepare the plugins
     //
     // Get the quey builder class from the database.
     $query = $this->dbo->getQuery(true);
     // Get a list of the plugins from the database.
     $query->select('p.*')->from('#__extensions AS p')->where('p.enabled = 1')->where('p.type = ' . $this->dbo->quote('plugin'))->where('p.folder = ' . $this->dbo->quote('cron'))->order('p.ordering');
     // Push the query builder object into the database connector.
     $this->dbo->setQuery($query);
     // Get all the returned rows from the query as an array of objects.
     $plugins = $this->dbo->loadObjectList();
     // Log how many plugins were loaded from the database.
     JLog::add(sprintf('.loaded %d plugin(s).', count($plugins)));
     // Loop through each of the results from the database query.
     foreach ($plugins as $plugin) {
         // Build the class name of the plugin.
         $className = 'plg' . ucfirst($plugin->folder) . ucfirst($plugin->element);
         $element = preg_replace('#[^A-Z0-9-~_]#i', '', $plugin->element);
         // If the class doesn't already exist, try to load it.
         if (!class_exists($className)) {
             // Compute the path to the plugin file.
             $path = sprintf(rtrim(JPATH_PLUGINS, '\\/') . '/cron/%s/%s.php', $element, $element);
             // Check if the file exists.
             if (is_file($path)) {
                 // Include the file.
                 include $path;
                 // Double check if we have a valid class.
                 if (!class_exists($className)) {
                     // Log a warning and contine to the next record.
                     JLog::add(sprintf('..plugin class for `%s` not found in file.', $element), JLog::WARNING);
                     continue;
                 }
             } else {
                 // Log a warning and contine to the next record.
                 JLog::add(sprintf('..plugin file for `%s` not found.', $element), JLog::WARNING);
                 continue;
             }
         }
         JLog::add(sprintf('..registering `%s` plugin.', $element));
         // Register the event.
         $this->registerEvent('doCron', new $className($this->dispatcher, array('params' => new JRegistry($plugin->params))));
     }
     //
     // Run the cron plugins.
     //
     // Each plugin should have been installed in the Joomla CMS site
     // and must include a 'doCron' method. Configuration of the plugin
     // is done via plugin parameters.
     //
     JLog::add('.triggering `doCron` event.');
     // Trigger the event and let the Joomla plugins do all the work.
     $results = $this->triggerEvent('doCron');
     // Log the results.
     foreach ($this->triggerEvent('doCron') as $result) {
         JLog::add(sprintf('..plugin returned `%s`.', var_export($result, true)));
     }
     JLog::add('Finished cron run.');
 }
开发者ID:robschley,项目名称:joomla-platform-examples,代码行数:82,代码来源:run.php

示例10: 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();
//.........这里部分代码省略.........
开发者ID:kiritoxcii,项目名称:joomla-torneos,代码行数:101,代码来源:v_calendario.php

示例11: testQuote

 /**
  * Tests the JDatabase::quote method.
  *
  * @return  void
  *
  * @covers  JDatabaseDriver::quote
  * @since   11.4
  */
 public function testQuote()
 {
     $this->assertThat($this->db->quote('test', false), $this->equalTo("'test'"), 'Tests the without escaping.');
     $this->assertThat($this->db->quote('test'), $this->equalTo("'-test-'"), 'Tests the with escaping (default).');
     $this->assertEquals(array("'-test1-'", "'-test2-'"), $this->db->quote(array('test1', 'test2')), 'Check that the array is quoted.');
 }
开发者ID:rdiaztushman,项目名称:joomla-platform,代码行数:14,代码来源:JDatabaseTest.php


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