Friday, January 10, 2020

MySql is just dbAction 1,2,3 & 4


dbAction is simple and portable function for the programmers, You can manage MySql database with 1,2,3 & 4.

dbAction(table_name*, operation*, fields, condition)

Table Name: Here you have to pass name of the table you want to perform action within.

Operation: 1 to 4 (numeric), that is mean MySql action like insert, update etc.
We are targeting mostly used action from MySql.
  1. Insert
  2. Update
  3. Delete
  4. Select
Fields: here we pass values of a of form with help of POST and manual array var. there is mostly 2 cases we used actions
Case a: Send all values with form, no need to do anything just pass operation and let it go initially.
Case b: You can pass array from your side, in this case you have to pass array like- $array= array(“value”=>$value); after that you just need to pass array name ($array) within dbAction.
Condition:  You can pass where clause, limit, and order here 

That’s it....

Usage of dbAction

Required Arguments is table_name & Operation (go flat if you not require where clause, limit and orders)
Optional Arguments is fields & Condition (if you have then you should pass)
Examples of MySql

INSERT Query (Action 1)

INSERT INTO `leads` (`id``first_name``last_name`VALUES (NULL'7'‘jone’,’denial’);

Case a: if you want to post value direct form:- 

dbAction(‘leads’,1);

Case b: if you want to post value manual:- 

$array=array(

“id”=>’12’,

“first_name”=>’jone’,

“last_name”=>’denial’

);

dbAction(‘leads’,1,$array);

UPDATE Query (Action 2)

UPDATE `leads` SET `refer_name` = 'Go_2121' WHERE `leads`.`id` = 16;

We have condition on above query then we will use like this-

Case a: with the help of direct POST  by Form

dbAction(‘leads’,2,’’,’id=16’);

Case b: Manual Post with array.

$array=array(“refer_name”=>’Go_2121’);

dbAction(‘leads’,2,$array,’id=16’);

DELETE Query (Action 3)

dbAction(‘leads’,3,’’ ,’id=16’);

SELECT Query (Action 4)

Simple Example with required arguments 

SELECT * FROM `leads`

dbAction(‘leads’,4);

SELECT * FROM `leads` ORDER BY `earning` DESC

dbAction(‘leads’,4,’’,’ORDER BY id DESC’);

SELECT * FROM `leads` WHERE id=1

dbAction(‘leads’,4,’’,’id=1’);

if You Want to Full Function Code, Do Comment Or Just wait for Publish a new post.

queryRun-

queryRun(query, debug)

query: pass query within it.

Debug: by default it’s 0, if you want to pass any argument within it then you can.

1=print query or you can find error with the help of it.
3=execute query and return true.



Both





No comments:

Post a Comment