Welcome Guest, Not a member yet? Register   Sign In
Help to record session in the database.
#1

[eluser]Unknown[/eluser]
Hello! How to pitch more than one parameter in the class at the time of the recording session in a database? Example: I want to save the log of the session along with the identifier of the current user. Thanks! Sory for translation Sad
#2

[eluser]apodner[/eluser]
I am interpreting question this two ways (both of which may be incorrect)

1) you want to pass multiple parameters into the class constructor:
Answer: I accomplish this by overriding the CI_Loader class with a MY_Loader class that overrides the model() method. In that overridden method, I copied the original model() method exactly and made 2 changes: First, I inserted a new parameter in the declaration after the first one called $arrParam. It is an associative array. The method declaration looks like:

Code:
public function model($model, $arrParam = null, $name = '', $db_conn = FALSE)

From there I modify a single line inside the method to accept the constructor parameter

Code:
$CI->$name = new $model($arrParam);

The line above is pretty close to the bottom of the method. Then, I can just pass in an array of whatever I want into the constructor.

2) You are trying to move 2 pieces of data into of a controller and into a view at the same time.
Again an array is probably the way to go, and once it is in the class, you can do whatever you want to with it.

Controller Code:
Code:
function index()
{
$data['log'] = 'Session log information';
$data['user_id'] = 'myId';

$this->load->view('myView', $data);
}

View:
Code:
<?=$log?> // Echoes "Session log information"
<?=$user_id?> //Echoes "myId"


Hope one of these is what you are trying to accomplish




Theme © iAndrew 2016 - Forum software by © MyBB