Welcome Guest, Not a member yet? Register   Sign In
insert data didn't work
#1

[eluser]yudahebat[/eluser]
I have a function like this
Code:
$data1 = array
                (
                    'id'             => $this->input->post('id'),
                    'id_user'         => $this->input->post('id_user'),
                    'nama'             => $this->input->post('nama'),
                    'tgl_pesan'        => $this->input->post('tgl_pesan'),
                    'biaya_total'     =>     $this->db->select_sum('subtotal');
                                        $query = $this->db->get('reservasi_dtl');
                );
                
        $this->db->insert('reservasi',$data1);
the error said on
Code:
'biaya_total'     =>     $this->db->select_sum('subtotal');
                                        $query = $this->db->get('reservasi_dtl');
                );
#2

[eluser]Dam1an[/eluser]
a) What does the error say?
b) You seem to have a semi colon on the last 2 lines in the array, that can't help
c) Do you really want the query object in the array? And if so, you might want to specify a key for it
#3

[eluser]yudahebat[/eluser]
a) the error said
Code:
Parse error: syntax error, unexpected ';', expecting ')' in C:\xampp\htdocs\CI2\system\application\models\crud.php on line 368
b) ohh, maybe that the problem
c) yes i want,how to make it?
#4

[eluser]Thorpe Obazee[/eluser]
[quote author="yudahebat" date="1245767939"]a) the error said
Code:
Parse error: syntax error, unexpected ';', expecting ')' in C:\xampp\htdocs\CI2\system\application\models\crud.php on line 368
b) ohh, maybe that the problem
c) yes i want,how to make it?[/quote]

b. Wasn't what obvious from the error?

yudahebat, you could start by reading the user guide and php.net.

Honestly, almost all posts made by yudahebat have been, "How would you do this? How would you do that?", when most of these things can be understood from the user_guide. The others are just plain basic PHP.Another thing I've noticed is that he/she copies and pastes code without understanding what it actually does. 2 cents. don't mind me.
#5

[eluser]Phil Sturgeon[/eluser]
Although I can't really see why you would want to send the query object in there, if you DID want to the syntax would be done like this.

Code:
$data1 = array
                (
                    'id'             => $this->input->post('id'),
                    'id_user'         => $this->input->post('id_user'),
                    'nama'             => $this->input->post('nama'),
                    'tgl_pesan'        => $this->input->post('tgl_pesan'),
                    'biaya_total'     =>  $this->db->select_sum('subtotal'),
                    'query'           => $this->db->get('reservasi_dtl')
                );
                
        $this->db->insert('reservasi',$data1);

What are you trying to achieve with this? The query will not be stored correctly at all...
#6

[eluser]Thorpe Obazee[/eluser]
[quote author="yudahebat" date="1245763722"]I have a function like this
Code:
$data1 = array
                (
                    'id'             => $this->input->post('id'),
                    'id_user'         => $this->input->post('id_user'),
                    'nama'             => $this->input->post('nama'),
                    'tgl_pesan'        => $this->input->post('tgl_pesan'),
                    'biaya_total'     =>     $this->db->select_sum('subtotal');
                                        $query = $this->db->get('reservasi_dtl');
                );
                
        $this->db->insert('reservasi',$data1);
the error said on
Code:
$this->db->select_sum('subtotal');
$query = $this->db->get('reservasi_dtl');
);
[/quote]

Someone probably copied and pasted
Code:
$this->db->select_sum('subtotal');
$query = $this->db->get('reservasi_dtl');

And thought it would work correctly.
#7

[eluser]yudahebat[/eluser]
what do u mean someone? I dont understand...

I just want to get the value of
Code:
$this->db->select_sum('subtotal');
$query = $this->db->get('reservasi_dtl');
to be the value of biaya_total

how to make it?
#8

[eluser]Phil Sturgeon[/eluser]
Code:
$this->db->select_sum('subtotal');
$query = $this->db->get('reservasi_dtl');

// PHP 4 syntax
$row = $query->row();
echo $row->subtotal;

// PHP 5 syntax
$query->row()->subtotal;

It is all in here dude.




Theme © iAndrew 2016 - Forum software by © MyBB