Check if a Pod exists

$params['id'] int Pod ID
$params['name'] string Pod name

@param array $params An associative array of parameters

@return bool True if exists

@since 1.12
977086
public function pod_exists( $params, $type = null ) {

		if ( is_string( $params ) ) {
			$params = array( 'name' => $params );
		}

		$params = (object) pods_sanitize( $params );

		if ( ! empty( $params->id ) || ! empty( $params->name ) ) {
			if ( ! isset( $params->name ) ) {
				$dummy = (int) $params->id;
				$pod   = get_post( $dummy );
			} else {
				$pod = get_posts( array(
					'name'           => $params->name,
					'post_type'      => '_pods_pod',
					'posts_per_page' => 1
				) );

				if ( is_array( $pod ) && ! empty( $pod[0] ) ) {
					$pod = $pod[0];
				}
			}

			if ( ! empty( $pod ) && ( empty( $type ) || $type == get_post_meta( $pod->ID, 'type', true ) ) ) {
				return true;
			}
		}

		return false;
	}
1146087
public function update($params)
    {
        $query = $this->query->update($params);
        $this->db->exec($this->query->useQuery($params['db_name']));
        $prepare = $this->db->prepare($query);
        if ($prepare->execute()) {
            $prepare->closeCursor();

            return true;
        } else {
            return false;
        }
    }
1371409
public function __isset(string $param): bool
    {
        return isset(self::$data[self::$method][$param]);
    }
498530
public function load_template( $params ) {

		if ( ! class_exists( 'Pods_Templates' ) ) {
			return false;
		}

		$params       = (object) $params;
		$params->type = 'template';

		return $this->load_object( $params );
	}
644823
public boolean hasNamedPolicy(String ptype, String... params) {
        return hasNamedPolicy(ptype, Arrays.asList(params));
    }
665982
public function has($param)
        {
            if ($param instanceof Container) {
                $id = (int) $param->id;
            } elseif (is_integer($param)) {
                $id = $param;
            }

            if (isset($id) && isset($this->_items[$id])) {
                return true;
            }

            return false;
        }
1333799
public function query(string $query, array $params = []): bool
	{
		return $this->execute($this->prepare($query, $params));
	}
787210
public static function exists() : bool
    {
        // Start session if needed
        if (! session_id()) {
            Session::start();
        }

        // Loop all arguments
        foreach (func_get_args() as $argument) {

            // Array element
            if (is_array($argument)) {

                // Loop the keys
                foreach ($argument as $key) {

                    // Does NOT exist
                    if (! isset($_SESSION[(string) $key])) {
                        return false;
                    }
                }
            } else {

                // Does NOT exist
                if (! isset($_SESSION[(string) $argument])) {
                    return false;
                }
            }
        }

        return true;
    }
419274
public function hasParam($paramName) {
    if (isset($this->paramFields[$paramName])) {
      return true;
    }
    elseif ('sourceId' === $paramName) {
      return true;
    } //default field due to support issues
    elseif ('userAgent' === $paramName) {
      return true;
    } //default field due to support issues
    elseif ('orderId' === $paramName) {
      return true;
    } //default field due to support issues
    elseif ('customerId' === $paramName) {
      return true;
    } //default field due to support issues
    return false;
  }
589479
final public static function exists($keys): bool {
		
		// initialize some vars
		$db			= Database::getInstance();
		$tableKey	= (array)static::TABLE_KEY;
		$conds		= array();

		foreach ($tableKey as $field) {
			$conds[] = $field . ' = ?';
		}
		
		$query = 'SELECT COUNT(1) FROM `' . static::TABLE_NAME . '` WHERE ' . implode(' AND ', $conds);
		
		// execute and return value
		return (bool)Database::load($query, (array)$keys, PAIR_DB_COUNT);
		
	}
97106
public function exists(array $data)
    {
        if (empty($data['product_id'])) {
            return false;
        }

        $product_id = $data['product_id'];
        unset($data['product_id']);
        $items = (array) $this->getList($data);

        foreach ($items as $item) {
            if ($item['product_id'] == $product_id) {
                return true;
            }
        }

        return false;
    }
984552
public function migrate_pod( $params ) {

		/**
		 * @var $wpdb WPDB
		 */
		global $wpdb;

		if ( ! isset( $params->pod ) ) {
			return pods_error( __( 'Invalid Pod.', 'pods' ) );
		}

		$pod = pods_sanitize( pods_clean_name( $params->pod ) );

		if ( ! in_array( "{$wpdb->prefix}pod_tbl_{$pod}", $this->tables, true ) ) {
			return pods_error( __( 'Table not found, items cannot be migrated', 'pods' ) );
		}

		if ( ! in_array( "{$wpdb->prefix}pods_{$pod}", $this->tables, true ) ) {
			return pods_error( __( 'New table not found, items cannot be migrated', 'pods' ) );
		}

		if ( ! in_array( "{$wpdb->prefix}pod_types", $this->tables, true ) ) {
			return pods_error( __( 'Pod Types table not found, items cannot be migrated', 'pods' ) );
		}

		if ( ! in_array( "{$wpdb->prefix}pod", $this->tables, true ) ) {
			return pods_error( __( 'Pod table not found, items cannot be migrated', 'pods' ) );
		}

		if ( true === $this->check_progress( __FUNCTION__, $pod ) ) {
			return '1';
		}

		$pod_data = $this->api->load_pod( array( 'name' => $pod ), false );

		if ( empty( $pod_data ) ) {
			return pods_error( sprintf( __( 'Pod <strong>%s</strong> not found, items cannot be migrated', 'pods' ), $pod ) );
		}

		$columns     = array();
		$old_columns = array();

		foreach ( $pod_data['fields'] as $field ) {
			if ( ! in_array(
				$field['name'], array(
					'created',
					'modified',
					'author',
				), true
			) && ! in_array( $field['type'], array( 'file', 'pick' ), true ) ) {
				$columns[]     = pods_sanitize( $field['name'] );
				$old_columns[] = pods_v( '_pods_1x_field_name', $field['options'], $field['name'], false );
			}
		}

		$into   = '`id`';
		$select = '`t`.`id`';

		if ( ! empty( $columns ) ) {
			$into   .= ', `' . implode( '`, `', $columns ) . '`';
			$select .= ', `t`.`' . implode( '`, `t`.`', $old_columns ) . '`';
		}

		// Copy content from the old table into the new
		$sql = "
            REPLACE INTO `@wp_pods_{$pod}`
                ( {$into} )
                ( SELECT {$select}
                  FROM `@wp_pod_tbl_{$pod}` AS `t` )
        ";

		pods_query( $sql );

		// Copy index data from the old index table into the new individual table
		$sql = "
            UPDATE `@wp_pods_{$pod}` AS `t`
            LEFT JOIN `@wp_pod_types` AS `x` ON `x`.`name` = '{$pod}'
            LEFT JOIN `@wp_pod` AS `p` ON `p`.`datatype` = `x`.`id` AND `p`.`tbl_row_id` = `t`.`id`
            SET `t`.`created` = `p`.`created`, `t`.`modified` = `p`.`modified`
            WHERE `x`.`id` IS NOT NULL AND `p`.`id` IS NOT NULL
        ";

		pods_query( $sql );

		// Copy name data from the old index table into the new individual table (if name empty in indiv table)
		$sql = "
            UPDATE `@wp_pods_{$pod}` AS `t`
            LEFT JOIN `@wp_pod_types` AS `x` ON `x`.`name` = '{$pod}'
            LEFT JOIN `@wp_pod` AS `p` ON `p`.`datatype` = `x`.`id` AND `p`.`tbl_row_id` = `t`.`id`
            SET `t`.`name` = `p`.`name`
            WHERE ( `t`.`name` IS NULL OR `t`.`name` = '' ) AND `x`.`id` IS NOT NULL AND `p`.`id` IS NOT NULL
        ";

		pods_query( $sql );

		$this->update_progress( __FUNCTION__, true, $pod );

		return '1';
	}
1296630
public function load_helper( $params ) {

		if ( ! class_exists( 'Pods_Helpers' ) ) {
			return false;
		}

		$params       = (object) $params;
		$params->type = 'helper';

		return $this->load_object( $params );
	}
523259
public function isApplicable(array $params)
    {
        $this->setOutputColorVisibility($params);

        return $this->hasParameter($params, '-vvv') || $this->hasParameter($params, '--verbose', 3);
    }
71369
public function exists(array $options = [])
    {
        try {
            $this->connection->getSession($options + [
                'name' => $this->name(),
                'database' => $this->database
            ]);

            return true;
        } catch (NotFoundException $e) {
            return false;
        }
    }
73541
public function update($params)
    {
        $query = $this->query->update($params);
        $prepare = $this->db->exec($query);
        if ($prepare) {
            return true;
        }

        return false;
    }
350359
protected function checkEmptyHook($params)
    {
        $hookName = $this->getParam($params, 'rel');

        if (null == $hookName) {
            throw new \InvalidArgumentException(
                $this->translator->trans("Missing 'rel' parameter in ifhook/elsehook arguments")
            );
        }

        if (!isset($this->hookResults[$hookName])) {
            $exception = new \InvalidArgumentException(
                $this->translator->trans("Related hook name '%name' is not defined.", ['%name' => $hookName])
            );

            Tlog::getInstance()->error($exception->getMessage());

            if ($this->debug) {
                throw $exception;
            }

            return true;
        }

        return (is_string($this->hookResults[$hookName]) && '' === $this->hookResults[$hookName]
            || !is_string($this->hookResults[$hookName]) && $this->hookResults[$hookName]->isEmpty()
        );
    }