Jump to content

Featured Replies

Posted

Hello,

is there a way to load a Node by column_name instead of by id like it is by default?

Solved by szalik.dev

Go to solution
  • Author
  • Solution

Update: yes it's possible by doing this:

#1: Add this to your Node class:

	/**
	 * @brief	[ActiveRecord] Database ID Fields
	 * @note	If using this, declare a static $multitonMap = array(); in the child class to prevent duplicate loading queries
	 */
	protected static $databaseIdFields = array('column_name');

#2: then load node row by custom column like so

\IPS\yourapp\class\class::load($id, 'column_name');

 

Edited by CodePixel

You shouldn’t replace the ID by the “name”. You should allow both:

array( ‘id’, 'column_name');

and call the node using the name, like;

……load( ‘bla bla bla’, ‘column_name’ );

That’s the same case when you load a member by name or email. 

  • Author
Just now, Adriano Faria said:

You shouldn’t replace the ID by the “name”. You should allow both:

array( ‘id’, 'column_name');

and call the node using the name, like;

……load( ‘bla bla bla’, ‘column_name’ );

That’s the same case when you load a member by name or email. 

That's good to know, not needed in my case but still, thank you!

Edited by CodePixel

Recently Browsing 0

  • No registered users viewing this page.