public static function get_id_for_name($name) { $rows = Database_FetchingHelper::get_rows_for_query(new Database_SQLSelectQuery(<<<SQL SELECT \tid FROM \thpi_trackit_stock_management_images WHERE \tname = '{$name}' SQL )); if (count($rows) == 0) { /* * Add the image. */ return Database_ModifyingStatementHelper::apply_statement(new Database_SQLInsertStatement(<<<SQL INSERT INTO \thpi_trackit_stock_management_images SET \tname = '{$name}' SQL )); } else { $row = $rows[0]; return $row['id']; } }
/** * Returns all the persistent user entries. * * @return array The user entries. */ public static function get_all_user_entries() { $all_user_entries = array(); $user_rows = Database_FetchingHelper::get_all_rows_in_table('hc_admin_users', 'name', 'ASC'); #print_r($user_rows); foreach ($user_rows as $user_row) { $all_user_entries[] = new Admin_UserEntry($user_row['id'], $user_row['name'], $user_row['email'], $user_row['real_name'], $user_row['email']); } return $all_user_entries; }
public static function get_id_for_product_id($product_id) { $rows = Database_FetchingHelper::get_rows_for_query(new Database_SQLSelectQuery(<<<SQL SELECT \tid FROM \thpi_trackit_stock_management_products WHERE \tproduct_id = '{$product_id}' SQL )); if (count($rows) == 0) { throw new Exception("No product with product ID '{$product_id}'!'"); } else { $row = $rows[0]; return $row['id']; } }
public static function get_unprocessed_image_text_file_names() { $rows = Database_FetchingHelper::get_rows_for_query(new Database_SQLSelectQuery(<<<SQL SELECT \tname FROM \thpi_trackit_stock_management_feed_files WHERE \tfile_type = 'TXT' \tAND \tprocessed is NULL \tAND \tname LIKE 'img_%' SQL )); $cache_directory = TrackitStockManagement_CacheHelper::get_cache_directory(); $unprocessed_image_text_file_names = array(); foreach ($rows as $row) { $unprocessed_image_text_file_names[] = $cache_directory->get_name() . '/' . $row['name']; } return $unprocessed_image_text_file_names; }
private function get_raw_page_sections($page_name) { #$dbh = DB::m(); #$raw_page_sections = array(); #$page_name = mysql_real_escape_string($page_name, $dbh); # $query = <<<SQL #SELECT # hpi_db_pages_pages.name AS name, # hpi_db_pages_edits.submitted AS modified, # hpi_db_pages_sections.name AS section, # hpi_db_pages_texts.text AS text, # hpi_db_pages_filter_functions.name AS filter_function #FROM # hpi_db_pages_pages # INNER JOIN hpi_db_pages_edits ON # hpi_db_pages_pages.id = hpi_db_pages_edits.page_id # INNER JOIN hpi_db_pages_texts ON # hpi_db_pages_edits.text_id = hpi_db_pages_texts.id # INNER JOIN hpi_db_pages_text_section_links ON # hpi_db_pages_texts.id = hpi_db_pages_text_section_links.text_id # INNER JOIN hpi_db_pages_sections ON # hpi_db_pages_text_section_links.section_id = hpi_db_pages_sections.id # LEFT JOIN hpi_db_pages_filter_functions ON # hpi_db_pages_texts.filter_function_id # = # hpi_db_pages_filter_functions.id #WHERE # hpi_db_pages_pages.name = '$page_name' # AND # hpi_db_pages_edits.deleted = 'No' # AND # hpi_db_pages_edits.current = 'Yes' #ORDER BY # section ASC, # modified ASC #SQL; #echo $query; exit; $query = new DBPages_FetchAllSectionsForPageSelectQuery($page_name); #print_r($query); #echo '$query->get_as_string(): ' . "\n"; #echo $query->get_as_string(); #exit; #print_r($query); #exit; #$result = mysql_query($query, $dbh); # #while ($row = mysql_fetch_assoc($result)) { # $raw_page_sections[] = $row; #} $raw_page_sections = Database_FetchingHelper::get_rows_for_query($query); if (count($raw_page_sections) > 0) { return $raw_page_sections; } else { throw new DBPages_PageSectionNotFoundException($page_name); } }