I am new to joomla and I want to create a table in joomla database manually with the data and get those details to an article in joomla. Before that as my knowledge we need to get the database connection to a connection variable. I searched in the locally installed Joomla directory to find a file containing the database connection code base. I want to know is there a way to get the connection into a separate variable as follows
To get started with querying the Joomla way, you'll need a database connection object. All the heavy lifting is already done for you.
$db = JFactory::getDbo();
Using this object, there is a sea of methods that can be chained to it.
Normally, the next step will be to declare a new query object. This object also has many methods which allow you build a valid mysql query.
$query = $db->getQuery(true);
After this, you'll need to see the documentation about how to convert raw mysql syntax to Joomla's query building syntax.
To give you a pool of working snippets with explanation and error reporting, search this site for my answers to mysql questions. All of my answers are tested to be correct, unless I express in the post that my snippet is untested
I am confident that my answers will help you to find clarity.
To achieve what you want in Joomla! way, you need to develop/create a Joomla! content plugin, Joomla! documentation is excellent guide to complete this step: https://docs.joomla.org/J3.x:Creating_a_content_plugin
Then, you need to know how to select data from database tables, also Joomla! documentation has a good tutorial to read in this context: https://docs.joomla.org/Selecting_data_using_JDatabase