Yoast\WP\Lib
ORM::find_one
Tells the ORM that you are expecting a single result back from your query, and execute it. Will return a single instance of the ORM class, or false if no rows were returned. As a shortcut, you may supply an ID as a parameter to this method. This will perform a primary key lookup on the table.
Метод класса: ORM{}
Хуков нет.
Возвращает
true|false|Model.
Использование
$ORM = new ORM(); $ORM->find_one( $id );
- $id(int|null)
- An (optional) ID.
По умолчанию: null
Код ORM::find_one() ORM::find one Yoast 26.3
public function find_one( $id = null ) {
if ( $id !== null ) {
$this->where_id_is( $id );
}
$this->limit( 1 );
$rows = $this->run();
if ( empty( $rows ) ) {
return false;
}
return $this->create_instance_from_row( $rows[0] );
}