« first day (662 days earlier)      last day (4272 days later) » 

12:12 AM
@dyelawn have you heard about such thing as "dependency injection" ?
 
yes
how would i implement a solution to this problem utilizing dependency injection?
 
@dyelawn Don't ask. Do it. You won't notice the why in the beginning (when not many classes extend from it), but over time especially as things start to change over time.
@CharlesSprayberry +1 I love demos
@dyelawn By using "the don't look for things"-attitude.
 
so set the database variables in the parent class constructor, and override if necessary in child class constructors?
 
12:29 AM
@dyelawn depends on the class. if it has no parent, there is nothing to override. if it does not need a database it does not have to ask for it.
 
correct, i understand that part
i'm just trying to limit the amount of times that i have to type the values for the database variables, because there are 6 namespaces each with between 35-50 classes that are interfacing with the database
 
@dyelawn That might show a problem that your code is too dependent on the database. Try to find out why and develop a way to prevent that.
To prevent code-repetition there are some useful patterns as well that help with that.
 
code-repetition is precisely what i'm trying to avoid. i can't alter the database architecture and the relational structure is not very good
 
@dyelawn I was not talking about altering database structure. I was only pointing out, that this can be sign that your code is too highly coupled with the database structure.
Some patterns that might be useful: Prototype; Template method pattern - Also consider to read through the P of EAA book chapter about database abstraction.
 
@tereško can you take a look at a user system class I made to make sure it doesn't violate any SRP. i'm not positive that I've completely grasped the concept
 
12:38 AM
k
 
pastebin.com/3hwYBsdK (tim cooper helped me at first with the concept)
 
@hakre thanks, this is all very useful
 
@Nile it's not the SRP which is the problem
 
okay
 
its the whole Actions class and the leaking encapsulation in User class
 
12:41 AM
should I move everything in there to the Auth class?
without the extension
 
when you write class Actions extends User , it means that all the Actions'es are special kind of User
 
@Nile Solve it via "naming". The word "Actions" is so general telling that it is not clear for what that class was written for specifically. That's often a smell. That helps to find out about areas that are worth to be thought twice about.
 
it's kinda insulting
 
okay, so should I move it up the the Auth class?
 
and the Auth stands for what ? Authentication ? Authorization ?
why would creating a new user be a part of either one ?
 
12:45 AM
@Nile What do you say are those actions for and where do you think they belong to?
 
the actions are for inserting or updating fields/values in the user table of the database.
so should I create a whole new class for UserActions
 
also , public Boolean createUser(User user); why does `createUser() method require already existing user instance ?
 
@Nile Wrong, that is what a database layer is for. It updates columns in a database.
 
honestly, i am stumped .. i have no idea where to being
 
@tereško, I'd first create an instance of user, then I'd take that instance and register it through createUser(). the user class doesn't interact with the database, it's just a way to organize the data from the database for one user
 
12:49 AM
every instance of Actions is also an instance of User
 
Why not create a UserPassword class that has a reset method for example?
 
what about the createUser function, though? should that be in UserActions?
 
@Nile What does that function do? A user object is normally created in a program by instantiating it.
 
@hakre , that sounds bad
but i will put the lapse of judgment down as "it's late"
 
is that to me?
oh - i see. nevermind
 
12:53 AM
@tereško I'm not happy with it either and would suggest the PasswordResetTransaction instead.
 
so, aside from the leaking encapsulation (which I need methods to get information from, not variables, correct?), is my idea of the User class valid/okay?
 
no , it is not okey
 
okay. why :?
 
0
A: Convert UTC offset to timezone or date

webartodate_default_timezone_set('UTC'); $timezones = array(); foreach (DateTimeZone::listAbbreviations() as $key => $array) { $timezones = array_merge($timezones, $array); } $utc = new DateTimeZone('UTC'); $timezone_offset = '+02:00'; # 2H $sign = substr($timezo...

 
so what in my User class does the LSP apply to?
 
12:56 AM
while typing code I forgot what was the question, have I nailed it?
 
1:09 AM
0
Q: PHP force download and refresh SOLUTION not working

user187680End goal: Click link on page 1, end up with file downloaded and refresh page 1. Using PHP to serve downloads that are not in public html. Approach: Page 1. Link transfers to page 2 with get variable reference of which file I am working with. Page 2. Updates relevant SQL databases with inform...

:pokerface:
 
halp
i need a word
 
a word
 
word, that describes status of authentication, when no user has been authenticated
 
unauthenticated?
 
it will be used with "on" infront of it as in "on" . $authentication->getStatus()
 
user895378
1:27 AM
on verification
 
that is not status
it is an action or process
 
user895378
on authorization
 
user895378
I'm just throwing out words :)
 
...
 
@tereško so what does it say if the user is logged in
 
1:29 AM
"verified" or "known" or "found" or "authenticated"
 
sup guys
 
on verified doesn't seem to make sense
 
i haven't got to that part yet
"missing" ? "absent" ?
 
why does on need to go in front of it?
 
"anonymous"?
or is this after you've tried and failed to log in?
 
1:32 AM
maybe i should use onAbsent() and onPresent()
@Lusitanian , it's for the view class
 
OH now I know why
hm
onAbsence
 
"absence" is not so much a status as a state of being
then again , this is not my native language
 
no, you're right, it just sounds more normal
 
Well, even the thesaurus doesn't have an antonym for authenticed thesaurus.com/browse/authenticated?s=t
 
naah .. i will just use onSuccess() , onFailure() and onError()
because "user" is absent, but "authentication" has failed
 
1:38 AM
anyone in a teaching mood?
 
perhaps
 
i'm kinda hungry
 
i'm trying to learn a few things by answering these php questions
 
"these" = ?
I know, I'm wondering which questions he's referring to
 
1:42 AM
that looks like homework
 
i was about to say
 
i wish i had php homework
 
where's that from
 
and which part of this confuses you
 
my cousin found it.
i just care about number 4. the oop stuff.
 
1:44 AM
well .. do you know how to extend classes ?
 
1) can you give me a link -- just curious, seems like a kinda crappy php site
and 2)
start with a base phone class
 
@tereško yeah
 
well .. then where is the problem ?
 
showing how overloading works
@Lusitanian let me see if he has a link
 
user895378
@hakre I gave a little more thought to the idea of the final Response returned from a redirected request providing URI access. I don't really think it's necessary because you can do something like this ...
 
1:45 AM
@hanleyhansen it means that the child class method is replacing the parent's method
 
it hardly requires overloading...then again, idk what the functionality should be
 
user895378
$responseArr = $client->requestRedirectTrace($request);
$count = count($responseArr);
if ($count > 1) {
    $lastRedirect = $responseArr[$count-1];
    $finalUri = $lastRedirect->getHeader('Location');
} else {
    // no redirects happened because there's only one response in the array
    $finalUri = $request->getUri();
}
 
user895378
Then again, that may be more work than it's worth if you could just have Response::getUri :)
 
@tereško can you give me a syntax example
 
@hanleyhansen are you sure this isn't homework, a test, or a job application?
then i'll show you how lol
 
1:48 AM
@hanleyhansen , for example , answering call on both ordinary phone and cordless phone , will require you to pick up receiver
but for mobile phone , answering call will require you to press "answer" button
 
@Lusitanian if it was a job application it would be dumb for me to bite of more than i can chew. and i'm not in school.
 
ah, okay, winner
 
@tereško then the question is kinda vague
 
this means that you have to overload the answer() method
 
yes it is very vauge
 
1:49 AM
found it on google. it is for a job application.
anyone ever heard of RustyBrick?
i'm going to try all these answers. this should be fun.
 
user895378
@hakre woops, in that example code above it should be $responseArr[$count-2];
 
if that's there job app i wouldn't buy their products :P
 
lol ditto.
it looks like they make a bunch of jewish apps.
 
@Lusitanian , that test is there to filter out people whose IQ is lower then room temperature
 
i hope you're right and that's all its for
 
1:52 AM
lol
 
if you cannot pass it , people would be wasting time by interviewing someone, who has never written single line of code before
 
fair enough
i need to see how codereview.se works
oh god i go there and the first question i see is about cakephp
 
so for overloading i just use the same function name and that overwrites the mother function?
 
yes, which you can call like so from the child
parent::functionname($arguments);
why does rails make you extend a base controller class
 
so in theory i should call the parent and then do anything else that i might want to do?
 
1:58 AM
no
 
@hanleyhansen no
 
you said that you know how to extend classes
i assumed that you have read and understood uk.php.net/manual/en/language.oop5.php
 
@tereško i don't think i've ever read the php oop manual
the majority of my OOP knowledge comes from C++, that'd actually probably be a good read O:
 
where can i get oop knowledge? what's a good oop book?
 
i punt on that question
 
2:04 AM
@tereško ^^
 
i just read that whole conversation with dyelawn and his namespaces
i don't understand how you have the patience for that
@hanleyhansen you oughta read the php manual he linked you to first
 
@Lusitanian i will. wouldn't it be good to read something that is language agnostic though?
 
and never read the comments on php manual entries, 90% is misguided people or flat-out sub-80 iqers
@hanleyhansen the concepts are pretty similar across any language
 
you have to begin with understanding how syntax works
 
You should be able to get to the point where learning a new language is almost trivial, however; because concepts are the same across like-paradigmed programming languages.
 
2:06 AM
language-agnostic books are for people who study advanced concepts and patterns
 
makes sense
 
If you know Ruby, you should be able to understand Python and JavaScript, and program in them after a shorter period of time than it'd take to learn a programming language of a different paradigm --- if that makes sense.
That demonstrates understanding of concept vs. language-specific implementation.
 
yeah it does.
 
When people come in here and say "I didn't know php had return statements, I thought only java did" it makes me want to sacrifice something to cthulu.
 
ok. so to rephrase my question. what's a good way to get a solid understanding of concepts?
lol
 
2:08 AM
reading and practice and reading and practice and repetition
 
of course. reading what though? what's a good book?
 
start with the manual --- and you can read through some of the patterns present here, a resource i recently discovered
at some point you'll need to learn about SOLID
The "S" in solid is the single responsibility principle which is one of the most important things you'd want to learn -- it's also incredibly simple.
 
ok great thanks! i'll start with that.
 
trust me when i say there's no shortage of quality info, you just need to weed through the shit
but i'm out, exhausted
night
 
thanks. night
 
2:14 AM
@Lusitanian no need to pile on someone who you don't think is reading
i forgot that all good coders were just born with all of the knowledge they have.
 
2:38 AM
Hello
I need some PHP help, can I get it here without asking a question?
 
How would you get help without asking a question?
 
I mean a question through the site
 
you can definitely try...
"Discussion for all things PHP - Don't ask whether someone is here or can help. Just tell us your problem. If anybody can and wants to help, they will."
 
Ah, sorry, just read that!
 
go on then...
 
2:44 AM
I have a MySQL database with a "studennts" table that contains the columns: id, username, password, and email.
I also have another table called "enrollments" which is aimed towards assigning the students to a class. It has the columns id, student_id, and course_id.
Lastly, I have a "courses" table that simple has two columns: id and name.
I'd like help as to how to assign the users to classes.
I have a form set up, but not exactly sure how I can fill out this database.
 
@alex-castro just submit the info into your enrollments table...? unless I'm misunderstanding your question
 
@AlexCastro Are you using PDO, mysqli or mysql_* functions to talk with your database?
 
mysql_
 
but you are just starting?
 
2:48 AM
mysql_query and such
 
@AlexCastro stop now.
 
What's wrong with that?
 
go to an entry on php.net and look at the red box
 
at the very least, read up on mysqli. mysql_ is deprecated
 
Lovely how every single guide online uses mysql_ :(
 
2:49 AM
PDO will be easier
 
Chances are if you have to ask if they're using mysql, mysqli or PDO...they're using mysql
 
yeah...they're all idiots
 
@AlexCastro don't worry, its just something you should change, here are some good links
 
@AlexCastro Nearly every single guide regarding PHP and MySQL is horribly out of date
 
Jun 30 at 13:28, by tereško
Please, don't use mysql_* functions to write new code. They are no longer maintained and the community has begun deprecation process. See the red box? Instead you should learn about prepared statements and use either PDO or MySQLi. If you can't decide which, this article will help you. If you pick PDO, here is good tutorial.
 
2:50 AM
mysql_query hasn't been a worthwhile solution since mysqli and pdo appeared
 
off topic, @Paul: how do you do the quote thing?
 
How hard will it be to convert to PDO or MySQLi?
 
i just paste the permalink to the message, you can find it hovering to the left of the message
 
okay. @AlexCastro, it'll be easy if you know what you're doing.
 
for mysqli, if you really really insisted on doing as little work as possible, it has a procedural interface that's quite nearly identical to mysql's
but it doesn't get you any of the benefits that come with mysqli or pdo
 
2:52 AM
> this is probably also a qoute, but i used > at the beggining to make it look like one @Nile
 
> okay, thanks @Paul
 
you'll really want to learn to use the object-based interface though
and particularly learn about prepared statements...they're the best thing to happen to mysql code in...well...pretty much ever
 
Can someone still help me regarding the course_id?
 
my SO profile has an example of prepared statements for pdo
erm
lemme see
 
is there a slight possibility there is someone in here that knows C#?
i could use some help.
 
2:57 AM
you'd add a row to the enrollments table, with the appropriate student id and course id, to enroll that student in that course
 
anyone?
 
as for where you decide which student or course...well, that has little-to-nothing to do with the database itself, and more with your ui i imagine
@EliteGamer you do know there's a c# room, right?

C#

General discussions about the c# language, Squirrels | gist.gi...
 
yes, but know one is there
var Room = null;
or
var Room = "";
ha
 
var Room = new Array(17);
 
???
 
3:01 AM
it appears that there are ~17 people in that room
 
The last message was posted 1 hour ago.
No active
 
I'm pretty sure if you ask for help there you'd get it.
 
@cHao yes, which is why my question is about php :)
 
ok, i will try
 
I want to write to the database when someone signs up that they have in fact selected that class
But I'm not sure, with that structure, how I would do it.
 
3:02 AM
@AlexCastro so...umm...i must have missed it. where's the question?
 
"
I have a MySQL database with a "studennts" table that contains the columns: id, username, password, and email.
I also have another table called "enrollments" which is aimed towards assigning the students to a class. It has the columns id, student_id, and course_id.
Lastly, I have a "courses" table that simple has two columns: id and name.
I'd like help as to how to assign the users to classes.
I have a form set up, but not exactly sure how I can fill out this database."
 
We saw that already. What's your question? You have to query the database and insert a new row...
 
@AlexCastro i've read that like 3 times now, and still don't see a question other than the one i've already answered.
what, exactly, is the question?
 
I want to assign each user a class in the "enrollments" table. Specifically assign them all the classes they've selected.
 
and, as @cHao said before, if the question is related to the UI and how to process that information, please provide us with all necessary markup
 
3:06 AM
@AlexCastro so...loop through the selections they made, and insert a row for each selection
not seeing the issue.
 
@alexcastro, can we see how you've setup your form?
 
Yeah just a second.
 
brb
 
@AlexCastro read the manual for insert. If you have troubles, ask a more specific question.
 
I have my code for displaying the classes, @cHao.
In the form, that is.
 
3:20 AM
@AlexCastro, can we see?
BTW - Before we look at it, please assure us you know how to use the INSERT function
 
I do know
I'm just a bit confused as to the logic behind these relative tables in the DB and how to store the data
 
okay, show us the form.
pastebin.com will do
 
That's just the part to list the classes
 
Make the name just "class" and the value should be $row[id].
 
Which row's ID exactly?
 
3:27 AM
what have i missed ?
 
@AlexCastro what do you mean? each individual one, hence the while()
 
Ah sorry lost there for a second
So I would then put this course id into the course_id section of the enrollments table?
 
@AlexCastro What don't you understand?
1. Creating a form for the user to interact with?
2. Receiving the output from the form?
3. Inserting the data into the database?
 
3.
I know HOW
 
use an insert statement, your pasted code didn't have any.
 
3:32 AM
from what I got it was 2... your form setup was all wrong.
 
i agree with Nile, except that I'd say it was 1.
 
i know this is not a php related question
but i just really want to know.....this...android chat room have no one...so what i want to figure out is.. Samsung tab 2 or nexus 7?
could anyone please tell me?
 
@AlexCastro assuming it is 3, what data have you received from the user? Can you print it out, var_export($_POST) perhaps?
 
nexus
 
serious?
why?
 
3:35 AM
@AlexCastro, and if it is 3, why did you say
> I know HOW
 
no. i haven't a clue.
you ask for random info in a room totally unrelated, you really expect a knowledgeable answer?
 
sorry
i just want a fair discussion with ppl
 
which carrier are you on?
 
@AlexCastro first off...use checkboxes, not radio buttons. then you can name them all like classes[], and php will bundle all the user's choices into one array for you
with hardly any effort
 
does it matter?
 
3:37 AM
well, each carrier has its own unique customer service number
 
but it is tablet that we are talking about
 
@Chao
Woops, I'm doing that already with radio buttons.
It lets me do it just as well.
 
then...loop over $_POST['classes'], and for each item, INSERT into enrollments (student_id, course_id) values ( (the student's id), (the current item) )
 
Okay, will do and see.
Thanks :)
 
@AlexCastro not "just as well". you have to fart around with input element names. but either way, radio buttons are semantically incorrect
they're for when you can only select one of a bunch of items.
that's precisely why you couldn't name them all the same and have stuff work.
 
3:42 AM
Yes, I realize that now. I used to have them in groups but changed it to make one big list.
Ah, I was naming them in groups like class[math], with the math options, etc.
 
the point is that you're doing it wrong and he's telling you how to do it right...
 
user895378
@LeviMorrison Mother F-ing woot! Streaming request bodies now supported (not pushed) by the Artax HTTP Client
 
user895378
$headers = array();
$body = fopen('/hard/path/to/file.xml', 'r');
$request = new StdRequest('http://localhost:8096/stream-body', 'POST', $headers, $body);
$response = $client->request($request);
 
grats? :)
 
tab 2 or nexus?
 
3:48 AM
tab
 
u change:)
 
@rdlowrey Jolly good.
 
ijust picked the first one cause it sounded cooler.
 
user895378
This also allows streamed entity bodies with the Response and Request implementations in the framework, which is cool.
 
wait, it still does. nexus it is
 
user895378
3:49 AM
@LeviMorrison So you can read the request body as a stream using StdRequest::getStreamableBody
 
@rdlowrey On any Response as well?
 
user895378
yep
 
user895378
Message::getBody will load the full request body into memory.
 
@cHao You mention to use "classes[]". Should I actually do "classes[id]" with ID being the course ID?
 
no.
the id should be in the value
 
3:50 AM
@AlexCastro no. just classes[]. then the array will have each value as an element
 
user895378
@LeviMorrison woops, the actual method name is getBodyStream, not getStreamableBody
 
ah sorry
 
with classes[id], you end up with an array like { 'id1' => 'on', 'id2' => 'on', ... }
whereas with just classes[], you get [ 'id1', 'id2', ... ]
yeah, i'm half-assed mixing php syntax with json with whatever else. hopefully you get the point
 
user895378
But the getBody method in both requests and responses will load the full stream into memory with stream_get_contents to return a string value then rewind the stream. If a string was loaded as the request body, getBodyStream returns null and everything acts like normal.
 
user895378
@LeviMorrison Anyway, not pushed yet, but it's working perfectly on my end.
 
user895378
3:55 AM
And the relevant Response::send methods stream the body as well (if it's a stream resource)
 

« first day (662 days earlier)      last day (4272 days later) »