function _sqlite_init_functions(&$sqlite) { if (!$sqlite) { return false; } $fonctions = array('CONCAT' => array('_sqlite_func_concat', -1), 'CEIL' => array('_sqlite_func_ceil', 1), 'DATE_FORMAT' => array('_sqlite_func_strftime', 2), 'DAYOFMONTH' => array('_sqlite_func_dayofmonth', 1), 'EXTRAIRE_MULTI' => array('_sqlite_func_extraire_multi', 2), 'EXP' => array('exp', 1), 'FIND_IN_SET' => array('_sqlite_func_find_in_set', 2), 'FLOOR' => array('_sqlite_func_floor', 1), 'IF' => array('_sqlite_func_if', 3), 'INSERT' => array('_sqlite_func_insert', 4), 'INSTR' => array('_sqlite_func_instr', 2), 'LEAST' => array('_sqlite_func_least', 3), '_LEFT' => array('_sqlite_func_left', 2), 'NOW' => array('_sqlite_func_now', 0), 'MD5' => array('md5', 1), 'MONTH' => array('_sqlite_func_month', 1), 'PREG_REPLACE' => array('_sqlite_func_preg_replace', 3), 'RAND' => array('_sqlite_func_rand', 0), 'REGEXP' => array('_sqlite_func_regexp_match', 2), 'RIGHT' => array('_sqlite_func_right', 2), 'SETTYPE' => array('settype', 2), 'SQRT' => array('sqrt', 1), 'SUBSTRING' => array('_sqlite_func_substring'), 'TO_DAYS' => array('_sqlite_func_to_days', 1), 'TIMESTAMPDIFF' => array('_sqlite_timestampdiff'), 'UNIX_TIMESTAMP' => array('_sqlite_func_unix_timestamp', 1), 'VIDE' => array('_sqlite_func_vide', 0), 'YEAR' => array('_sqlite_func_year', 1)); foreach ($fonctions as $f => $r) { _sqlite_add_function($sqlite, $f, $r); } #spip_log('functions sqlite chargees ','sqlite.'._LOG_DEBUG); }
function _sqlite_init_functions(&$sqlite){ if (!$sqlite) return false; $fonctions = array( 'CONCAT' => array( '_sqlite_func_concat' ,2), 'CEIL' => array( '_sqlite_func_ceil', 1), // absent de sqlite2 'DATE_FORMAT' => array( '_sqlite_func_strftime' ,2), 'DAYOFMONTH' => array( '_sqlite_func_dayofmonth' ,1), 'EXP' => array( 'exp' ,1),//exponentielle 'FIND_IN_SET' => array( '_sqlite_func_find_in_set' ,2), 'FLOOR' => array( '_sqlite_func_floor', 1), // absent de sqlite2 'IF' => array( '_sqlite_func_if' ,3), 'INSERT' => array( '_sqlite_func_insert' ,4), 'INSTR' => array( '_sqlite_func_instr' ,2), 'LEAST' => array( '_sqlite_func_least' ,3), 'LEFT' => array( '_sqlite_func_left' ,2), # 'LENGTH' => array( 'strlen' ,1), // present v1.0.4 # 'LOWER' => array( 'strtolower' ,1), // present v2.4 # 'LTRIM' => array( 'ltrim' ,1), // present en theorie 'NOW' => array( '_sqlite_func_now' ,0), 'MD5' => array( 'md5' ,1), 'MONTH' => array( '_sqlite_func_month' ,1), 'PREG_REPLACE' => array( '_sqlite_func_preg_replace' ,3), 'RAND' => array( '_sqlite_func_rand' ,0), // sinon random() v2.4 'REGEXP' => array( '_sqlite_func_regexp_match' ,2), // critere REGEXP supporte a partir de v3.3.2 //'REGEXP_MATCH' => array( '_sqlite_func_regexp_match' ,2), // critere REGEXP supporte a partir de v3.3.2 'RIGHT' => array( '_sqlite_func_right' ,2), # 'RTRIM' => array( 'rtrim' ,1), // present en theorie 'SETTYPE' => array( 'settype' ,2), // CAST present en v3.2.3 'SQRT' => array( 'sqrt' ,1), 'SUBSTRING' => array( 'substr' ,3), 'TO_DAYS' => array( '_sqlite_func_to_days' ,1), # 'TRIM' => array( 'trim' ,1), // present en theorie 'UNIX_TIMESTAMP'=> array( '_sqlite_func_unix_timestamp' ,1), # 'UPPER' => array( 'strtoupper' ,1), // present v2.4 'VIDE' => array( '_sqlite_func_vide' ,0), // du vide pour SELECT 0 as x ... ORDER BY x -> ORDER BY vide() 'YEAR' => array( '_sqlite_func_year' ,1) ); foreach ($fonctions as $f=>$r){ _sqlite_add_function($sqlite, $f, $r); } #spip_log('functions sqlite chargees '); }