Query helper function | insertID | affectedRows | getLastQuery | countAll - deesoft service

Query helper function | insertID | affectedRows | getLastQuery | countAll

Deepak Tailor Image
Deepak Tailor - Oct 20 2020
Query helper function | insertID | affectedRows | getLastQuery | countAll

The functions that are performed to check the response of this query are the query helper function when the query of the database is executed. Such as insertId, affectedrows, countall, getlastquery, getplatform, getversion and many more.

insertID() function

We use insertid function to fetch insert id.

$this->seller // database connection set
public function insert_rec()
{
	$this->seller->table('users')
	 ->insert([
	 	'name'	=>	'deepak Tailor'
	 ]);
	echo $this->seller->insertID();
}
affectedRows() function

Displays the number of affected rows, when doing “write” type queries (insert, update, etc.).

public function insert_rec()
{
	$this->seller->table('users')
	 ->insert([
	 	'name'	=>	'deepak Tailor'
	 ]);

	echo $this->seller->affectedRows();
}
getLastQuery() function

The getlastQuery function is used to print the query by which type the query is being generated.

public function insert_rec()
{
	$this->seller->table('users')
	 ->insert([
	 	'name'	=>	'deepak Tailor'
	 ]);
	
	echo $this->seller->getLastQuery();
}


public function check_result()
{
	$query_str = "SELECT * FROM users WHERE id = ?";
	$this->seller->query($query_str,'20');
	
	echo $this->seller->getLastQuery();
}
countAll() function

To count how many rows are in a table, we use the countAll function.

public function check_result()
{
	echo $this->seller->table('users')->countAll();
}
getPlatform() function

The database platform uses the getPlatform function to check.

public function check_result()
{
	echo $this->seller->getPlatform();
}
getVersion() function

The database version uses the getVersion function to check

public function check_result()
{
	echo $this->seller->getVersion();
}
Deepak Tailor Image
Deepak Tailor

My name is Deepak tailor as a fullstack developer. I have been in the IT industry (PHP, Nodejs, flutter) for the last 5 years. For professional and customize web development & app development, you can send inquiry on our email.
----
You can contact him at deepaktailor10@yahoo.in