Using the API and functions to search by name and return array+nesting
-
So, Dealing with 250k files with sm,md,lg (1M+ files total)
spread out over about 25,000 folders (users)
all based on usernames.Of which there are ~7500 users/folders that need to be deleted
and the remaining users need to be preservedWhile reviewing the documentation here
https://ninjateam.gitbook.io/filebird/developer-zone/functionsI see this great function
$folder = FolderModel::findById( $folder_id, 'id, name, parent' );
I need a way to do the following:
– “Find ID by Folder Name”
since all the folder names are based on the usernamesI therefore need to query the database.
I am guessing
Some SQL like
"GET ID FROM wp_fbv WHERE name='some name'"
would workBut I would have thought there would be time saving functions that do this already?
Also need a way to do this
– “Get all subfolders based on parent ID”
for example, lets say user “joe_smith” has a folder “joe_smith”
and there are eh, maybe 200 subfolders within like so
/users/
/users/joe_smith/
/users/joe_smith/gallery_001
/users/joe_smith/gallery_001/sunsets
/users/joe_smith/gallery_001/dogs
/users/joe_smith/gallery_001/cats
/users/joe_smith/gallery_002/
/users/joe_smith/gallery_002/this
/users/joe_smith/gallery_003/thatIs there a function like this?
$subfolder_arr = FolderModel::findChildren( $folder_name = 'joe_smith', $level = 1);
<strong>That returns an array like this:</strong> $subfolder_arr = array( 1 => 'gallery_001', 2 => 'gallery_002', 3 => 'gallery_003', )
Is there a function like this?
$subfolder_arr = FolderModel::findChildren( $folder_name = 'joe_smith', $level = 2);
That returns an array like this:
$subfolder_arr = array( 1 => array(4=>'sunsets', 5=>'dogs', 6=>'cats'), 2 => array(7=>'this', 8=>'that'), )
- The topic ‘Using the API and functions to search by name and return array+nesting’ is closed to new replies.