Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ah i think i see, well looks to me from your update statements that you want to update 3 different tables which all depend on 'tycodashboard'. </p> <p>In that case i advise you use transactions to retain a bit of data integrity, otherwise say if one fails? you'll have lost some data. As a general rule, if you need to do more than 1 update simultaneously use transactions. </p> <p>Heres a great article on the subject: <a href="http://dev.mysql.com/doc/refman/5.0/en/commit.html" rel="nofollow noreferrer">http://dev.mysql.com/doc/refman/5.0/en/commit.html</a></p> <p>Its quite easy to do, just make you sure your tables are using the INNODB, then all you have to do is append START TRANSACTION to the top of your sql script and then COMMIT at the end.</p> <p>You might be trying to combine too much into a single function, whenever i'm updating multiple tables, it's easier to just handle each one in turn, rather than trying to stuff them all into one return. So try making a function that saves it, returning success or failure, then call it from your main function for each one of your sql scripts passing in the values.</p> <pre><code>//This is the function that gets called from your page. public function my_called_function() { //your sql script (using "" means you can put variables in without having to remove the quotes) $sql = "UPDATE....SET 'col' = $_POST['myvalue']"; //Run your script and get result $result = $this-&gt;save_my_stuff($sql); //if not null means success! if($result) { echo 'success!'; // your success message } else { echo 'something bad happened'; //your failure message } } //this is the function that does the saving! private function save_my_stuff($sql_script) { //Make connection $conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); //Check connection if(!$conn) { //connection failed die('Could not connect: '.mysql_error()); } //Select your database using your connection object mysql_select_db(DB_NAME, $conn); //try and save try { //run the query $result = mysql_query($sql_script, $conn); //return the result return mysql_result($result); } catch (Exception $e) { //deal with exception return null; } //close connection mysql_close(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload