/** * Test for the clear method (clearing each query type). * * @return void * * @covers \Joomla\Database\DatabaseQuery::clear * @since 1.0 */ public function testClear_type() { $types = array('select', 'delete', 'update', 'insert', 'union'); $clauses = array('from', 'join', 'set', 'where', 'group', 'having', 'order', 'columns', 'values'); // Set the clauses. foreach ($clauses as $clause) { TestHelper::setValue($this->instance, $clause, $clause); } // Check that all properties have been cleared foreach ($types as $type) { // Set the type. TestHelper::setValue($this->instance, $type, $type); // Clear the type. $this->instance->clear($type); // Check the type has been cleared. $this->assertThat(TestHelper::getValue($this->instance, 'type'), $this->equalTo(null)); $this->assertThat(TestHelper::getValue($this->instance, $type), $this->equalTo(null)); // Now check the claues have not been affected. foreach ($clauses as $clause) { $this->assertThat(TestHelper::getValue($this->instance, $clause), $this->equalTo($clause)); } } }
/** * Clear data from the query or a specific clause of the query. * * @param string $clause Optionally, the name of the clause to clear, or nothing to clear the whole query. * * @return PostgresqlQuery Returns this object to allow chaining. * * @since 1.0 */ public function clear($clause = null) { switch ($clause) { case 'limit': $this->limit = null; break; case 'offset': $this->offset = null; break; case 'forUpdate': $this->forUpdate = null; break; case 'forShare': $this->forShare = null; break; case 'noWait': $this->noWait = null; break; case 'returning': $this->returning = null; break; case 'select': case 'update': case 'delete': case 'insert': case 'from': case 'join': case 'set': case 'where': case 'group': case 'having': case 'order': case 'columns': case 'values': parent::clear($clause); break; default: $this->type = null; $this->limit = null; $this->offset = null; $this->forUpdate = null; $this->forShare = null; $this->noWait = null; $this->returning = null; parent::clear($clause); break; } return $this; }
/** * Clear data from the query or a specific clause of the query. * * @param string $clause Optionally, the name of the clause to clear, or nothing to clear the whole query. * * @return MysqliQuery Returns this object to allow chaining. * * @since __DEPLOY_VERSION__ */ public function clear($clause = null) { switch ($clause) { case null: $this->bounded = array(); break; } return parent::clear($clause); }