473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Queries from inside classes

Hi,

I've got a class that builds a calendar for the current month. I have
an extending class that adds links to all days in the calendar via
browser querystring.

My goal is to create links not to every single day, but only to days
that satisfy a certain condition - very similar to blog calendars with
posting dates highlighted. No post on that day - the date is not
highlighted.

I have to run a query from the extending class, which is totally new to
me. Any pointers?

May 17 '06 #1
2 988
NC
TristaSD wrote:

I've got a class that builds a calendar for the current month.
I have an extending class that adds links to all days in the
calendar via browser querystring.

My goal is to create links not to every single day, but only
to days that satisfy a certain condition - very similar to blog
calendars with posting dates highlighted. No post on that
day - the date is not highlighted.

I have to run a query from the extending class, which is
totally new to me. Any pointers?


Let's say that right now you have a class defined as follows:

class Calendar {
var $month;
var $year;
... other class members...
function render() {
}
}

When you call Calendar::render(), it renders the calendar for the month
defined by $year and $month. To achieve what you want, you need to
modify Calendar::render() and pass it, let's say, an array of integers,
each signifying the day of the month that should be specially marked
(e.g., days on which posts were added to a blog). So you would have
something like this:

class Calendar {
var $month;
var $year;
... other class members...
function render($special = array()) {
$days = date('t', strtotime("{$this->year}-{$this->month}-01"));
// output the table heading...
// output blank cells before the first of the month, if any...
for ($i = 1; $i <= $days) {
if (in_array($i, $special)) {
// output a specially formatted cell
} else {
// output a "normal" cell
}
}
// output blank cells after the last of the month, if any...
}
}

Cheers,
NC

May 17 '06 #2
> I've got a class that builds a calendar for the current month. I have
an extending class that adds links to all days in the calendar via
browser querystring.

My goal is to create links not to every single day, but only to days
that satisfy a certain condition - very similar to blog calendars with
posting dates highlighted. No post on that day - the date is not
highlighted.

I have to run a query from the extending class, which is totally new to
me. Any pointers?

You don't have to run a query from the extending class at all. In fact,
I can't see it as the responsibility of a calender class to dig in a
database.

I think your extending class needs to be passed a links collection (or
array) in either the constructor or a setter.

It is the responsibility of the code that _calls_ the calendar to
provide the links list. This list may then come from memory, a database,
or wherever.

Best regards
May 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Phil Powell | last post by:
http://www.php.net/array_filter I went there at first for my information on filtering mySQL query results using PHP, to no avail. This is more of a Vignette construct (my native environment)...
0
by: SimonC | last post by:
I'm looking to do something similar to a feature found on Ticketmaster.com, where you select your seats at a venue, and then you have two minutes in which to take or leave them. QUESTION 1a....
6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
8
by: Ian Davies | last post by:
Hello I am trying to run a few INSERT queries only if the user clicks 'continue' in a <a href> The queries takes variables created from SELECT queries. I have tried to acheive this by putting The...
2
by: Bryan Field-Elliot | last post by:
We have a running server (v7.3) which, over time, seems to accumulate a bunch of "stuck" PostgreSQL instances which appear to be dead inside of a transaction. For example, "ps" reveals many of...
7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
0
by: Edward Diener | last post by:
Why is there a prohibition of instantiating __value type enums and classes within __nogc classes ? After all __value types are not managed by the GC and built-in __value types, such as 'int', are...
4
by: A.M | last post by:
Hi, Using ADO.NET, How can i execute action queries already saved inside an MDB file ? I already know that i can run sql commands like UPDATE and INSERT, but how can i run those ones already...
6
by: Rob Williamson | last post by:
Does anyone know whether there is a way to create folders inside the right payne when you click on Tables or Queries or Forms or Reports in the the Objects side. I have alot of queries and forms...
1
by: JosAH | last post by:
Greetings, Introduction This week we start building Query objects. A query can retrieve portions of text from a Library. I don't want users to build queries by themselves, because users make...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.