Advertisement
Guest User

Code

a guest
Dec 1st, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1. // @todo move this to after pre-save preparations
  2.         // Verify unique fields
  3.         if ( 1 == pods_var( 'unique', $options[ 'options' ], 0 ) && '' !== $value && null !== $value && array() !== $value && 0 !== $value && '0' !== $value ) {
  4.             if ( empty( $pod ) )
  5.                 return false;
  6.  
  7.             if ( !in_array( $type, $tableless_field_types ) ) {
  8.                 $exclude = '';
  9.  
  10.                 if ( !empty( $id ) )
  11.                     $exclude = "AND `id` != {$id}";
  12.  
  13.                 $check = false;
  14.  
  15.                 $check_value = pods_sanitize( $value );
  16.  
  17.                 // @todo handle meta-based fields
  18.                 // Trigger an error if not unique
  19.                 if ( 'table' == $pod[ 'storage' ] )
  20.                     $check = pods_query( "SELECT `id` FROM `@wp_pods_" . $pod[ 'name' ] . "` WHERE `{$field}` = '{$check_value}' {$exclude} LIMIT 1", $this );
  21.  
  22.                 if ( !empty( $check ) )
  23.                     return pods_error( sprintf( __( '%s needs to be unique', 'pods' ), $label ), $this );
  24.             }
  25.             else {
  26.                 // @todo handle tableless check
  27.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement