Mysqli Get Single Value Of Coulmn Operation

Description

Get single value for the coulmn passed as variable .


Function Reference :
 
       			string dbGetVariable($tablename,$variable[, array $select_where_condition=array()])
             

Parameters

Name Type Required Parameter Info Example
table_name string Yes The name of the table to select records. any table name like employee_table,user_table
variable array Optional The Name of the coulmn of the table "username" or "gender"
select_where_condition associative array Optional Associative array with key as column name and values as column value for where clause. array("gender"=>"male")

Examples

  
          <?php 
         // Example 1 of getting single value of variable as string
			$sdb = new SimplifiedDB();
			$sdb->dbConnect("localhost", "root", "", "simplifieddb");
			$sdb->parameter_types="s";			
			$role_id = $sdb->dbGetVariable("users","role_id",array("userId"=>1));
            if($role_id=="1")
				echo "You can access this page";
			else
				echo "You are not allowed access this page";
		 ?> 
         

Result

Returns single value of the variable
For the above example, it shows "You can access this page" if roleId=1.

Debuging

Debug Operation Result/Output
$sdb->query SELECT `role_id` FROM `users` WHERE `userId`=?
$sdb->last_insert_id
$sdb->rows_affected
$sdb->message_info Connected to database
$sdb->error_info