sanitizeInt() public method

Sanitizes an integer value for use in a query
Deprecation: Use query parameters where possible
public sanitizeInt ( integer $value, boolean $signed = true ) : integer
$value integer Value to sanitize
$signed boolean Whether negative values are allowed (default: true)
return integer
Example #1
0
 /**
  * Get subscription records from the database
  *
  * Records are an object with two vars: guid and methods with the latter
  * being a comma-separated list of subscription relationship names.
  *
  * @param int $container_guid The GUID of the subscription target
  * @return array
  */
 protected function getSubscriptionRecords($container_guid)
 {
     $container_guid = $this->db->sanitizeInt($container_guid);
     // create IN clause
     $rels = $this->getMethodRelationships();
     if (!$rels) {
         return array();
     }
     array_walk($rels, array($this->db, 'sanitizeString'));
     $methods_string = "'" . implode("','", $rels) . "'";
     $db_prefix = $this->db->prefix;
     $query = "SELECT guid_one AS guid, GROUP_CONCAT(relationship SEPARATOR ',') AS methods\n\t\t\tFROM {$db_prefix}entity_relationships\n\t\t\tWHERE guid_two = {$container_guid} AND\n\t\t\t\t\trelationship IN ({$methods_string}) GROUP BY guid_one";
     return $this->db->getData($query);
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function sanitizeInt($value, $signed = true)
 {
     return $this->db->sanitizeInt($value, $signed);
 }