Note that there are some explanatory texts on larger screens.

plurals
  1. POPDO and PostgreSQL Function
    primarykey
    data
    text
    <p>I have function in my PostgreSQL Server</p> <pre><code>CREATE OR REPLACE FUNCTION edit_senti_meta_translation(_senti_id bigint, _meta_id bigint, _lang_code character, _meta_title character varying, _meta_note text) RETURNS boolean AS $BODY$ BEGIN PERFORM senti.is_draft FROM senti, senti_meta WHERE senti.senti_id=_senti_id AND senti_meta.senti_id=senti.senti_id AND senti_meta.senti_id=_senti_id AND senti_meta.meta_id=_meta_id; IF FALSE THEN RETURN FALSE; END IF; BEGIN UPDATE senti_meta_translation SET meta_title=_meta_title, meta_note=_meta_note WHERE meta_id=_meta_id AND lang_code=_lang_code; IF FOUND THEN UPDATE senti_meta SET last_update=now() WHERE senti_id=_senti_id AND meta_id=_meta_id; RETURN TRUE; ELSE RETURN FALSE; END IF; END; END; $BODY$ LANGUAGE plpgsql VOLATILE; </code></pre> <p>Well, It's working if i try in pgadmin3, and My record was updated(Work 100% as i expected) if i call this function</p> <pre><code>SELECT edit_senti_meta_translation(1, 41, 'eng', 'a', 'a'); </code></pre> <p>But When i try to call the function using PHP(PDO Driver) It give me the result true or false, but The UPDATE is not running, My record is not updated.</p> <pre><code>$stmt = Database::getInstance()-&gt;prepare('SELECT * FROM edit_senti_meta_translation(:senti_id, :meta_id, :lang_code, :meta_title, :meta_note);'); $stmt-&gt;bindParam(':senti_id', $senti_id, PDO::PARAM_INT); $stmt-&gt;bindParam(':meta_id', $meta_id, PDO::PARAM_INT); $stmt-&gt;bindParam(':lang_code', $lang_code, PDO::PARAM_STR); $stmt-&gt;bindParam(':meta_title', $meta_title, PDO::PARAM_STR); $stmt-&gt;bindParam(':meta_note', $meta_note, PDO::PARAM_STR); $stmt-&gt;setFetchMode(PDO::FETCH_ASSOC); $stmt-&gt;execute(); return $stmt-&gt;fetchColumn(0); </code></pre> <p>Even when i change the first line in my php code</p> <pre><code>$stmt = Database::getInstance()-&gt;prepare("SELECT edit_senti_meta_translation(1, 41, 'eng', 'a', 'a');"); </code></pre> <p>It give me the result(true/false) but the record is not updated. This make me so confused</p> <p>For info, i'm using PostgreSQL 8.4</p> <p><em>One thing that makes me confused is when i call the function directly in pgadmin3, it give me the correct return with record updated, but when call it from PHP(PDO), it only give me return, but the record is not updated.</em></p>
    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.
 

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