Welcome Guest, Not a member yet? Register   Sign In
Call functions in to model..
#11

[eluser]Yorick Peterse[/eluser]
[quote author="tnathos" date="1241390895"]same error....

Fatal error: Call to undefined method ClientModel::resta() in[/quote]

Take a look at the error, you probably misspelled the function.
#12

[eluser]tnathos[/eluser]
Not the code works fine in the same rotuine but when put in the other function show this error..

in the controller i need load the two functions or only the function what at the second function??
#13

[eluser]tnathos[/eluser]
any can help me?
#14

[eluser]n0xie[/eluser]
[quote author="tnathos" date="1241381608"]
I THINK WHAT CAN BE....

<?php

MODEL

FUNCTION A {
CALL FUNCTION C
delete * table b
}

FUNCTION B {
CALL FUNCTION C
delete * table a
}

FUNCTION C {
insert into table a field a, b. parametres -> post xxxxx
}

?>[/quote]
I'm guessing that you're trying to polymorphing. I hope this is what you're looking for:

Code:
<?php
/**
* Test Model
*/
class Test_model extends Model {

  function Test_model()
  {
    parent::Model();
  }

  function A($params)
  {
    $table = 'sometable';
    $this->C($params);
    $this->db->delete($table);
  }

  function B($params)
  {
    $table = 'someothertable';
    $this->C($params);
    $this->db->delete($table);
  }

  function C($params)
  {
    $table = 'yetanothertable';
    $this->db->insert($table, $params);
  }
}

/**
* Controller
*/

class Test extends Controller {

function Test(){
  parent::Controller();
  $this->load->model('test_model','test');
}

function doA()
{
  $someparams = array();
  $this->test->A($someparams);
}


function doB()
{
  $someparams = array();
  $this->test->B($someparams);
}
}

This might have typo's in it since I'm writing it from the top of my head.
#15

[eluser]tnathos[/eluser]
The problem is the

function B($params)
{
$table = 'someothertable';
$this->C($params);
$this->db->delete($table);
}

generete the error....Fatal error: Call to undefined method testModel:: C() in
#16

[eluser]tnathos[/eluser]
this is the funtion.. what do bad?

function resta(){
$restTransa = array ('quota'=> $this->session->userdata('valPlatOr') - $this->input->post('valTrans'),
'dateChange'=>mdate("%Y-%m-%d %h:%i:%a", time()));
$this->db->where('idBalance',$this->session->userdata('idBalance'));
$this->db->update('table',$restTransa);
}




Theme © iAndrew 2016 - Forum software by © MyBB