Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'with' count 1, not 0 #1369

Open
only4r opened this issue Sep 20, 2023 · 0 comments
Open

'with' count 1, not 0 #1369

only4r opened this issue Sep 20, 2023 · 0 comments

Comments

@only4r
Copy link

only4r commented Sep 20, 2023

Hey,

I think my Lithium version: v0.10.0

My problem:

models:
models/BlogPostsAttachment.php
models/BlogPost.php

controller:

$posts = BlogPost::all( array( 'with' => array( 'BlogPostsAttachment' ) ) );
$posts = $posts -> to( 'array' );

view:
var_dump( $posts['blog_posts_attachments'] ); // array( 0 => array( 'id' => NULL, 'title' => NULL ) )

Why generate this NULL item/row? The count( $posts['blog_posts_attachments'] ) is 1, but the real is 0.

If attachments is 1. The count is 1. This is okay. The problem only if empty the attachments. If empty, generate NULL array item.

Please help me. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant