ActionScheduler_DBStore::build_insert_sql()
Helper function to build insert query.
Метод класса: ActionScheduler_DBStore{}
Хуков нет.
Возвращает
Строку
. Insert query.
Использование
// private - только в коде основоного (родительского) класса $result = $this->build_insert_sql( $data, $unique );
- $data(массив) (обязательный)
- Row data for action.
- $unique(true|false) (обязательный)
- Whether the action should be unique.
Код ActionScheduler_DBStore::build_insert_sql() ActionScheduler DBStore::build insert sql WC 9.2.3
private function build_insert_sql( array $data, $unique ) { global $wpdb; $columns = array_keys( $data ); $values = array_values( $data ); $placeholders = array_map( array( $this, 'get_placeholder_for_column' ), $columns ); $table_name = ! empty( $wpdb->actionscheduler_actions ) ? $wpdb->actionscheduler_actions : $wpdb->prefix . 'actionscheduler_actions'; $column_sql = '`' . implode( '`, `', $columns ) . '`'; $placeholder_sql = implode( ', ', $placeholders ); $where_clause = $this->build_where_clause_for_insert( $data, $table_name, $unique ); // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- $column_sql and $where_clause are already prepared. $placeholder_sql is hardcoded. $insert_query = $wpdb->prepare( " INSERT INTO $table_name ( $column_sql ) SELECT $placeholder_sql FROM DUAL WHERE ( $where_clause ) IS NULL", $values ); // phpcs:enable return $insert_query; }