PDA

View Full Version : نمایش تعداد کل row ها در جوملا از mysql



miscreant_ghost
جمعه 01 مرداد 1395, 21:32 عصر
سلام دوستان؛
من یک مشکل دارم که هرچی جستجو کردم نتونستم حلش کنم، گویا ساختار اتصال به پایگاه داده در جوملا کمی متفاوت هستش؛ من می خوام با استفاده از php بتونم تعداد کل row ها در یک table خاص بگیرم و نمایش بدم (البته row هایی که مقدار ستون published در اونها برابر با 1 باشه)؛ هرکار می کنم نمیشه؛ خیلی ممنون میشم کمکم کنید.

masato
دوشنبه 04 مرداد 1395, 09:03 صبح
// Get a db connection.
$db = JFactory::getDbo();

// Create a new query object.
$query = $db->getQuery(true);

// Select all records from the user profile table where key begins with "custom.".
// Order it by the ordering field.
$query->select($db->quoteName(array('user_id', 'profile_key', 'profile_value', 'ordering')));
$query->from($db->quoteName('#__user_profiles'));
$query->where($db->quoteName('profile_key') . ' LIKE '. $db->quote('\'custom.%\''));
$query->order('ordering ASC');

// Reset the query using our newly populated query object.
$db->setQuery($query);

// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$results = $db->loadObjectList();


https://docs.joomla.org/Selecting_data_using_JDatabase


موفق باشید