Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] update query with multiple tables
#11

[eluser]flaky[/eluser]
Code:
switch($postConfig['action']){
            
            case $crudConfig['update']:
                $updateArray = array();
                /*$this->db->where('si_id', $this->input->post('id'));
                $this->db->update($crudTableName);*/
                $sql = 'update '.$crudTableName.' set ';
                //foreach($crudColumns as $key => $value){ $updateArray[$key] = $value.'='.$crudColumnValues[$key]; };
                foreach($crudTableName as $key => $value){ $updateArray[$key] = $value.'='.$crudColumnValues[$key]; };
                $sql .= implode(',',$updateArray);
                $sql .= ' where role_id = '.$crudColumnValues['id'];
                mysql_query( $sql );
                break;
                    }
#12

[eluser]maria clara[/eluser]
[quote author="flaky" date="1263398934"]where are you taking
Code:
$updateArray

from?

EDIT

basically you need to declare it before using it[/quote]

im having an error with that variable.
Code:
<p>Severity: Notice</p>
<p>Message:  Undefined variable: updateArray</p>
<p>Filename: controllers/ar_salesinvoice.php</p>
<p>Line Number: 249</p>
but when im taking that off. the program is running ok but it doesn't update the row i edited.when i refresh the page, the row that i edit would become the same as it is. in short, nothing happens..there's no changes.
#13

[eluser]flaky[/eluser]
look at my last post
and not to forget
Code:
$crudTableName = "'erp_ar_sales','erp_b','erp_c','erp_d','erp_e','k'";

change it to
Code:
$crudTableName = array('erp_ar_sales','erp_b','erp_c','erp_d','erp_e','k');
#14

[eluser]maria clara[/eluser]
where could i declare the $updateArray??
#15

[eluser]maria clara[/eluser]
i have tried your script and it doesn't have an error now. but still the row that i edited is still don't update.
#16

[eluser]flaky[/eluser]
declare it just under the case
eg
Code:
case $crudConfig['update']:
                $updateArray = array();

do an echo of the $sql, to see what query is being built
Code:
echo $sql;
#17

[eluser]maria clara[/eluser]
[quote author="flaky" date="1263400050"]declare it just under the case
eg
Code:
case $crudConfig['update']:
                $updateArray = array();

do an echo of the $sql, to see what query is being built
Code:
echo $sql;
[/quote]

i have tried it and it shows this in my console:
Code:
update 'erp_ar_sales','erp_b','erp_c','erp_d','erp_e','k' set  where role_id = "133"

and still nothing happens in it. huhu Sad
#18

[eluser]flaky[/eluser]
this a bogus query
it should be
Code:
update 'erp_ar_sales','erp_b','erp_c','erp_d','erp_e','k' set role_id = "133" where role_id = "133"
#19

[eluser]maria clara[/eluser]
[quote author="flaky" date="1263401291"]this a bogus query
it should be
Code:
update 'erp_ar_sales','erp_b','erp_c','erp_d','erp_e','k' set role_id = "133" where role_id = "133"
[/quote]

im thinking what could be the error? the set is null
#20

[eluser]flaky[/eluser]
it is null because $updateArray doesn't contain ','

EDIT
very bad answer from me, don't listen to it




Theme © iAndrew 2016 - Forum software by © MyBB