Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a PHP library that performs MySQL Data Validation and Sanitization According to Column Type?
    primarykey
    data
    text
    <p>Do you know of any open source library or framework that can perform some basic validation and escaping functionality for a MySQL Db.</p> <p>i envisage something along the lines of:</p> <pre><code>//give it something to perform the quote() quoteInto() methods $lib-&gt;setSanitizor($MyZend_DBAdaptor); //tell it structure of the table - colnames/coltypes/ etc $lib-&gt;setTableDescription($tableDescArray); //use it to validate and escape according to coltype foreach ($prospectiveData as $colName =&gt; $rawValue) if ( $lib-&gt;isValid($colName, $rawValue)) { //add it to the set clause $setValuesArray[$lib-&gt;escapeIdentifier($colName)] = $lib-&gt;getEscapedValue($colName,$rawValue); } else { throw new Exception($lib-&gt;getErrorMessage()); } </code></pre> <p>etc...</p> <p>I have looked into - Zend_Db_Table (which knows about a table's description), and - Zend_Db_Adaptor (which knows how to escape/sanitize values depending on TYPE)</p> <p>but although they can sanitize, they do not automatically do any clever validation stuff before updates/inserts</p> <p>Anyone know of a good PHP library to preform this kind of validation that I could use rather than writing my own?</p> <p>i envisage alot of this kind of stuff:</p> <pre><code> ... elseif (eregi('^INT|^INTEGER',$dataset_element_arr[col_type])) { $datatype='int'; if (eregi('unsigned',$dataset_element_arr[col_type])) { $int_max_val=4294967296; $int_min_val=0; } else { $int_max_val=2147483647; $int_min_val=-2147483648; } } </code></pre> <p>(p.s I know eregi is deprecated - its just an example of laborious code) </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload