function get_last_insert_id($conex) { global $conf_db_type; switch ($conf_db_type) { case 'mysql': $res = my_query('SELECT LAST_INSERT_ID() as Last_ID;', $conex); break; case 'mssql': $res = my_query('SELECT @@identity as Last_ID;', $conex); break; } return my_result($res, 0, 'Last_ID'); }
private function exist_translated_view($lan) { global $conex; $view_name = $this->table_name . '_' . $lan; $sql = 'SELECT table_name FROM information_schema.tables WHERE table_schema = \'' . $this->database . '\' AND table_name = \'' . $view_name . '\''; $sel = my_query($sql, $conex); return my_result($sel, 0, 'table_name') == $view_name; }
function simple_select($table, $field, $value, $field_return, $extra_condition = '') { # returns an array with the results of a row in the database like: array(field_name => field_value, field2_name => field2_value ... //use to get ONE SINGLE ROW with one or many fields from a table with one condition, //in case there are more conditions, use $extra_conditions like ' AND extra_field = \'ex_field_value\'' //$field_return can be a string or an array of strings. global $conex; if (!is_array($field_return)) { $field_return = array($field_return); } $sql = 'SELECT ' . implode(',', $field_return) . ' FROM ' . $table . ' WHERE ' . $field . '=\'' . $value . '\'' . $extra_condition; // print($sql); $my_query = my_query($sql, $conex); $arr_results = array(); if ($my_query) { foreach ($field_return as $field_name) { $arr_results[$field_name] = @my_result($my_query, 0, $field_name); } my_free_result($my_query); return $arr_results; } else { return false; } }