Check if a stdClass object has "entries" in PHP
<p>I have a model that checks for entries en a database. Like this:</p>

<pre><code>public function getByID($id)
{
    if(false == is_numeric($id))
        return false;

    $images = array();

    $query = $this-&gt;db-&gt;where("id_album", $id)-&gt;order_by("order", "ASC")-&gt;get("images");

    foreach($query-&gt;result() as $row)
        $images[] = $row;

    return (object) $images;
}
</code></pre>

<p>In my view I want to know if I have a rows or not, to show the images or not. I do this:</p>

<pre><code>&lt;?php if(false != isset($content-&gt;images)): ?&gt;
    &lt;pre&gt;&lt;?php print_r($content-&gt;images); ?&gt;&lt;/pre&gt;
&lt;?php endif; ?&gt;
</code></pre>

<p>But every time I try to skip when I've no results (i get a stdClass() empty) I fail. I tried <code>isset</code>, <code>$content-&gt;images != NULL</code>, <code>!$content-&gt;images</code>... I don't know how to do it to skip the "Severity: Notice Message: Undefined variable".</p>

<p>Thank you in advance.</p>

<p>UPDATE:</p>

<p><code>$content</code> has more sets than images, like <code>$content-&gt;_data</code> or <code>$content-&gt;title</code>.</p>

<p>When I've NO images on database and i've no return from MySQL, doing this:</p>

<pre><code>&lt;?php echo count($content-&gt;images); ?&gt;
&lt;pre&gt;&lt;?php print_r($content-&gt;images); ?&gt;&lt;/pre&gt;
</code></pre>

<p>The output is:</p>

<pre><code>1
stdClass ( )
</code></pre>
