⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

How do I submit a custom MySQL query?



norse2
  • profile picture
  • Member

Posted 26 February 2016 - 07:17 AM

I want to have a function that will execute a query similar to this:

 

"DELETE * FROM 'my_table' WHERE 1"

 

This will allow me to let the user clear a table without going through the trouble of individual deletes.

 

I looked at this post

/topic/1963-simple-guide-to-executing-custom-queries/

 

but I ran into the same error that is described in reply #9

 

Fatal error: Call to a member function result() on a non-object in /public_html/control/application/models/custom_query_model.php on line 18

 

 

Is there a better way to accomplish this and if not, then how do I get around this error?

 

Thank you in advance for your help.


jamun567
  • profile picture
  • Member

Posted 29 February 2016 - 09:47 AM

hello friends,

 
 
Accessing structured data with SQL is quite different from the full text search of documents on the Web. Structured data in the relational model means data that can be represented in tables -- rows and columns. Each row in a table represents a different object, and the columns represent various "attributes" of the object. The columns have names and integrity constraints that specify valid values.
 
Since the column values are named and are represented in a consistent format, you can select rows very precisely, based on their contents. This is especially helpful in dealing with numeric data. You can also join together data from different tables, based on matching column values. You can do useful types of analysis, listing objects that are in one table and missing (or present, or have specific attributes) from a related table. You can extract from a large table precisely those rows of interest, regrouping them and generating simple statistics on them.
 

Amit Shah
  • profile picture
  • Member

Posted 01 March 2016 - 09:43 AM

Well my friend you dont need to have a GC function to make a call you can create a model having such queries ... call it from the controller - make the call to the function in controller .. done - thats it ... all done.

 

Happy GCing :)