Note that there are some explanatory texts on larger screens.

plurals
  1. POString comparison fails because of value passed by datatable, codeigniter
    primarykey
    data
    text
    <p>I am facing a really strange problem which i am debugging from past 2 hours but unable to find the solution. Before explaining the problem, let me show the code</p> <p>My Controller Function is </p> <pre><code> $this-&gt;load-&gt;library('datatables'); $actionLinkBar = $this-&gt;load-&gt;view("content/updates/dt_files/action_bar", array(), TRUE); $this-&gt;datatables -&gt;select("id, name, status") -&gt;where('id', $this-&gt;session_data['user_id']) -&gt;from("t_user") -&gt;add_column("action", $actionLinkBar, 'id, name, status'); echo $this-&gt;datatables-&gt;generate(); </code></pre> <p>And the code in my action_bar view is</p> <pre><code> &lt;?php $status_rec = '$3'; var_dump($status_rec); // STRANGE OUTPUT - string(2) "1" ?&gt; &lt;div class="action_bar" data-update-id="&lt;?php echo '$1'; ?&gt;"&gt; &lt;?php if ($status_rec == '1') { ?&gt; // HENCE COMPARISON ALWAYS FAILS &lt;span&gt;Present&lt;/span&gt; &lt;?php }else { ?&gt; &lt;span&gt;Absent&lt;/span&gt; &lt;?php } ?&gt; &lt;/div&gt; </code></pre> <p>Now explaining the problem.. I am using Datatables with Codeigniter. I have a view template <code>action_bar</code> which will be displayed in one of the columns of datable in front end. The view has if/else condition based on value of <code>status</code> field from DB. If <code>status</code> feild value = 1 = Present. Else it is Absent. But though the <code>$status_rec</code> has value as '1' it still fails in comparison. Strange thing is on var_dumping <code>$status_rec</code>, i found that though it has proper value, the length is weird(2) though its single int. I even tried trimming etc but still no effect. Maybe that's why the comparison is failing. Your help is really needed :/</p> <p>P.S - The DB feild that holds this value is int with length 1</p>
    singulars
    1. This table or related slice is empty.
    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. 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