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;
 }
	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;
	}
	/**
	 * Tests the JDatabase::getPrefix method.
	 *
	 * @return  void
	 *
	 * @since   11.4
	 */
	public function testGetPrefix()
	{
		$this->assertThat(
			$this->db->getPrefix(),
			$this->equalTo('&')
		);
	}
 /**
  * Sostituisce #__ con il prefisso del database
  * @param string $q
  * @return string
  */
 private function replacePrefix($q)
 {
     return str_replace("#__", $this->db->getPrefix(), $q);
 }
Beispiel #5
0
 /**
  * Quick utility method to replace the mysql prefix used in the joomla tables with the real prefix
  *
  * @param string $sql The sql query
  * @param string $prefix The prefix to search for (default: #__)
  *
  * @return string The query with the real prefix
  *
  * @since 1.0.0
  */
 public function replacePrefix($sql, $prefix = '#__')
 {
     return preg_replace('/' . preg_quote($prefix) . '/', $this->_database->getPrefix(), $sql);
 }
Beispiel #6
0
 /**
  * Magic function to convert the query to a string.
  * @return  string    The completed query.
  */
 public function __toString()
 {
     $query = '';
     switch ($this->type) {
         case 'element':
             $query .= (string) $this->element;
             break;
         case 'select':
             if (is_null($this->select)) {
                 $this->select = '*';
             }
             $query .= (string) $this->select;
             $query .= (string) $this->from;
             if ($this->join) {
                 $this->join = array_unique($this->join);
                 foreach ($this->join as $join) {
                     $query .= (string) $join . PHP_EOL;
                 }
             }
             if ($this->where) {
                 $query .= (string) $this->where;
             }
             if ($this->group) {
                 $query .= (string) $this->group;
             }
             if ($this->having) {
                 $query .= (string) $this->having;
             }
             if ($this->order) {
                 $query .= (string) $this->order;
             }
             break;
         case 'delete':
             $query .= (string) $this->delete;
             $query .= (string) $this->from;
             if ($this->join) {
                 $this->join = array_unique($this->join);
                 foreach ($this->join as $join) {
                     $query .= (string) $join;
                 }
             }
             if ($this->where) {
                 $query .= (string) $this->where;
             }
             break;
         case 'update':
             $query .= (string) $this->update;
             $query .= (string) $this->set;
             if ($this->where) {
                 $query .= (string) $this->where;
             }
             break;
         case 'insert':
             $query .= (string) $this->insert;
             // Set method
             if ($this->set) {
                 $query .= (string) $this->set;
             } elseif ($this->values) {
                 if ($this->columns) {
                     $query .= (string) $this->columns;
                 }
                 $query .= ' VALUES ';
                 $query .= (string) $this->values;
             }
             break;
         case 'replace':
             $query .= (string) $this->replace;
             // Set method
             if ($this->set) {
                 $query .= (string) $this->set;
             } elseif ($this->values) {
                 if ($this->columns) {
                     $query .= (string) $this->columns;
                 }
                 $query .= ' VALUES ';
                 $query .= (string) $this->values;
             }
             break;
     }
     if ($this->limit) {
         $query .= (string) $this->limit;
     }
     $query = str_replace('#__', $this->db->getPrefix(), $query);
     return $query;
 }