Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>check the object has data. you can use a combination of following</p> <pre><code>isset- Determine if a variable is set and is not NULL is_null - Finds whether a variable is NULL empty — Determine whether a variable is empty is_array — Finds whether a variable is an array is_object — Finds whether a variable is an object </code></pre> <p>You can use something like(if the number of rows are 0, set the object to null).</p> <pre><code>If(!is_null($this-&gt;gallery)) { //show data } else { //show a msg } </code></pre> <p>You can just check if the <code>$this-&gt;gallery</code> is an object.</p> <pre><code>If(is_object($this-&gt;gallery)) { //show data } else { //show a msg } </code></pre> <p>Depending on the result set choose the above wisely. If you can post a <code>print_r</code> I can tell you exactly what you have to use.</p> <p><em><strong>UPDATE WITH RESPECT TO THE QUESTION</em></strong></p> <blockquote> <p>Warning: array_splice() expects parameter 1 to be array, object given in</p> </blockquote> <p>The reason it may not work is because <code>$this-&gt;_gallery</code> may not be an array.</p> <blockquote> <p>stdClass Object ( [id] => 0 ) &lt;-- this is an object not an array. if you are to call array_slice() function, 1st parameter should be an array. </p> </blockquote> <p>To check if something is an array, you can do:</p> <pre><code>is_array($this-&gt;_gallery); // returns true or false </code></pre> <p>If it is an array, you can then call <code>array_slice()</code>.</p> <p>Hope this helps. If you have any problems ask here.</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.
    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