« first day (661 days earlier)      last day (4286 days later) » 

8:00 PM
@PeeHaa Sure thing! pastebin.com/iC2YvhXS
 
There is your problem
 
@tereško Thats what I was thinking when he posted his comment on the question.
 
@Prefix it is multidimensional
pass $courses[0] to the function @Prefix
 
@PeeHaa ah crud. Why didn't I know that >_<
 
It happens :)
 
8:01 PM
@Truth sorry i missed that cause you didn't ping me
so you put your phpunit.xml file in the tests dir
 
@cHao , how about you go and read some .. try googling for "what is global state"
 
actually, follow exactly what i do in phpoauthlib and tell me if you need help after that
 
is there a var_dump that works on functions?
 
11 mins ago, by Truth
Where do I write the tests, and what do I put in my phpunit.xml file?
@Lusitanian
 
@Event_Horizon shouldn't var_dump work on functions?
@Truth follow what i id in phpoauthlib
just throw it in your tests dir and define your test suites in it
 
8:02 PM
@webarto Thank you, but I don't have any forms on the page, just items list (<li>) and ids and names of input subelements such as checkboxes that contain user ids who should receive comment notification via email
 
@PeeHaa Thanks again for all the help.. still doesnt seem to be working though, now I'm getting `array(1) {
[24]=>
string(18) "registered:current"
}`
 
@Lusitanian maybe it is and global vars just suck so hard they return null when you var_dump them
 
@tereško that function has a specific purpose that doesn't change. it's insane to require it to accept information it should have supplied itself, imo.
 
put everything in a tests dir
 
@PeeHaa that is with using $courses[0]
 
8:03 PM
Oh, alright, I see, and then I configure that in PhpStorm
@Lusitanian I'll give it a try and check back here, thanks :)
 
@cHao , have you even heard about Law of Demeter ?
 
@Truth okay
 
@Prefix And you are also passing the start and endmarkers?
 
@tereško heard of it, yeah. follow it religiously to the exclusion of anything else that's simpler and makes more sense? hell no.
 
@PeeHaa I believe so, print('<pre>');var_dump(getValuesBetweenMarkers($courses[0], 'registered:current', 'registered:next'));print('<pre>');
 
8:05 PM
@cHao Its so insanely easy to avoid globals though
 
@cHao functions do not hold state
 
@tereško they don't hold mutable state.
 
global variables ARE mutable
 
@Prefix I have know idea what could be wrong. One last thing to try: can you run the follwing code and paste the output on pastebin: echo '$array = array(\'' . implode('\', \'', $courses[0]) . '\'); so I should have the exact same situation
 
8:10 PM
@tereško yeah. but that's what PHP gives you. arrays can't be constant. so either you can overengineer your way around it, or you can say "screw it" and use a global.
 
@rdlowrey sorry I'm too stupid to find, how can I get raw headers output (built raw headers from array), just to compare with what I had... thanks
 
@cHao What does a global have to do with constant?
 
@PeeHaa sure, here you go :) pastebin.com/MHgBLmMF
 
@Prefix Again: works for me: codepad.viper-7.com/CQJanD :P
 
@PeeHaa global mutable state is what people widely consider evil. for good reason, but in this case, php forces mutability.
 
8:12 PM
@PeeHaa , well constants are immutable globals
 
@tereško are*?
 
@PeeHaa ugh this is driving me crazy.. I see no reason why your method shouldn't work for me >_<
 
this is one of the reasons why people advise again use of globals constants for anything else then value aliasing
 
user895378
@webarto you can get an array of headers with $request->getAllHeaders(), or the request line (GET / HTTP/1.1) with $request->getRequestLine() ... the raw message that's sent is compiled using those two methods
 
user895378
It will essentially look like $request->__toString()
 
user895378
8:14 PM
except the Client will add missing Host header and auto-add Content-Length if necessary
 
@tereško yup. however the reason according to use global in this case according to @cHao is because arrays cannot be constants. Which is the other way around :)
oh array cannot be constants let's throw in a global which also isnt a contant
+s
* 2
 
Jul 27 at 18:12, by tereško
i especially love the "Constants have a flaw in php - you cannot change the values. This is why we use static registry" .. i am paraphrasing a bit here
 
@PeeHaa idk if this helps at all but this is exactly what I have in my code, and what the output is: pastebin.com/FabET1CV
 
["HOST"]=>
string(13) "0.0.0.0:31337"
["UPGRADE"]=>
string(9) "websocket"
["CONNECTION"]=>
string(7) "Upgrade"
["COOKIE"]=>
string(20) "_asg_helpdesk=m4st3r"
["SEC-WEBSOCKET-KEY"]=>
string(24) "NTAyMWNjNGVjNDY2MTAuNg=="
["SEC-WEBSOCKET-VERSION"]=>
string(2) "13"
@rdlowrey server was case sensitive (with header parsing), is there a way to not UPPERCASE headers? (just asking)
 
@PeeHaa my point is, the function has constant data. but it can't be a constant, because php forces mutability on it by virtue of its being an array. so, i can either rig up all kinds of crap like passing the function some data it should already have had anyway, or i say "screw it" and let it be global and mutable.
 
8:18 PM
I get your point I just don't agree with it :)
 
user895378
@webarto Maybe/maybe not -- because the server is not correctly implementing HTTP. HTTP headers are by-definition case-insensitive.
 
if there were a worthwhile const in php, i'd be happy to use it :P
 
actually the original quote from Symfony's book as this :
Aug 11 '11 at 20:04, by teresko
> Surprisingly, you will find very few constants in symfony. This is because constants have a major drawback in PHP: you can’t change their value once they are defined.
 
LMAO
 
@rdlowrey I'll just adapt server to follow the rules, if there is definition, right. Also, how does one force disconnecting? (stream_socket_shutdown) etc...
 
8:19 PM
@tereško is that from sf1 or 2
 
1.x
 
@tereško lol...i'll agree, that's some retardedness. but my point is the exact opposite. i'd be happy to have a constant, but php won't let me :P
 
user895378
@webarto The case-normalization is deeply ingrained in the StdRequest implementation ... case-sensitive headers are probably in the "will not fix" category for me, because the HTTP spec says they aren't.
 
from this book :
 
@rdlowrey sure, I totally agree.
 
user895378
 
user895378
> Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive.
 
actually, while reading that book i spent most of the time laughing
 
did you take it out from the library/
 
nope , torrents
 
oh lol
 
8:26 PM
@PeeHaa So no idea? Im grasping at straws here haha
 
user895378
@webarto Asynchronous requests disconnect automatically, but if you want to force the closing of a persistent connection when using Client::request, just specify the 'Connection' => 'close' in your header list for that request.
 
user895378
I'm thinking about making the asynchronous request connections stay open, though. We'll see.
 
user895378
Regardless, you can always specify a Connection: close header and know that will kill the connection after the request/response cycle completes.
 
@Prefix I have absolutely no idea as to what is going on there :P
 
@Prefix do you have a broken array posted on codepad
if you copy and paste your broken code i'll look at itt
 
8:28 PM
@Lusitanian this is the array and this is the function
 
@PeeHaa @Lusitanian yup what Peehaa posted (thanks!)
@Lusitanian the problem is, for him it outputs correctly string(17)"20114-0609-333-90", but for me it outputs string(18) "registered:current".. I have no idea what is the difference
 
@Prefix it's getting the right value?
oh.
where's your actual code
 
dunnowtf.
@Prefix what version of PHP do you have
 
@Lusitanian I am running PHP 5.2.0
 
user895378
8:32 PM
@webarto Also related is the socket timeout (Client::setTimeout($seconds)) ... this defaults to 30 seconds, so if your script doesn't terminate and there's no activity on a given connection for thirty seconds, it will idle out on its own. You don't have to worry about it too much on your end because it doesn't hurt you to hog the remote server's connections and they'll be closed when the php process ends anyway :)
 
@Lusitanian unfortunately it is not in my power to change
 
@Prefix a bit old thur
there's a bug in array_search in php 5.2.0
 
nooooooooooooo
 
i'm kidding ;)
 
:(
hahaha
phew!
pulled a fast one on me :P
 
8:33 PM
indeed. okay, well since there potentially could be some issue with it, i'm going to rewrite the function manually
 
You're a God... haha - in all seriousness that'd be awesome
I have to run around 5PM EST (~30 minutes), so is there any way you could message it to me on here if I'm not still available when you're done?
 
doubtful but it'll be done way before then anyway
 
haha ok great
 
@rdlowrey I got busy at work for a few hours, how's it going?
 
stackoverflow.com/questions/11853130/… - Everyone is saying "yes", but correct me if I am wrong, when the file is compiled, everything outside of tags is basically echoed as a string constant?
 
user895378
8:37 PM
@LeviMorrison problem solved. Actually wasn't a problem at all -- github just wasn't serving up the most recent fixes to @webarto. When he manually downloaded the master branch zip everything worked just fine.
 
@Leigh yes. All T_INLINE_HTML is turned into ZEND_ECHO
 
@Leigh Only one way to find out ;)
 
@Lusitanian Well, let's see, I've set up, and configured my XML file and bootstrap file
I still get a fatal error though
Hold on...
 
@NikiC So it's not really any slower than an echo
 
D:\Websites\php\php.exe C:\Users\Dor\AppData\Local\Temp\ide-phpunit.php --bootstrap D:\Websites\htdocs\lamed\tests\boostrap.php --configuration D:\Websites\htdocs\lamed\tests\phpunit.xml
Testing started at 23:37 ...

Fatal error: Uncaught exception 'PHPUnit_Framework_Exception' with message 'Neither "Lamed Test Suite.php" nor "Lamed Test Suite.php" could be opened.' in D:\Websites\php\pear\PHPUnit\Util\Skeleton\Test.php:100
Stack trace:
#0 D:\Websites\php\pear\PHPUnit\TextUI\Command.php(157): PHPUnit_Util_Skeleton_Test->__construct('Lamed Test Suit...', '')
 
8:38 PM
I'm glad I'm smarter than those idiots who think tags turn the engine off and on :p
 
@Leigh It's exactly as slow/fast as echo ^^ Because it is the same.
 
<testsuites>
    <testsuite name="Lamed Test Suite">
        <directory>Custom/*</directory>
    </testsuite>
</testsuites>
 
posted on August 07, 2012 by Lorenzo Alberton

A journey into optimising Hadoop jobs: the strategies to scan and filter a PetaByte of archived data, schedule new jobs and deliver data fast.

http://www.alberton.info/datasift_and_data_delivery_push.html
Planet PHP
DataSift and Data Delivery: PUSH
Lorenzo Alberton
1344371760
 
Well thanks, now I have had confirmation from the wunderkind, I'm going to make an informed comment
 
(Sorry for bugging you so much XD)
 
8:39 PM
@Feeds wow I just read "optimising hand jobs"
 
user895378
@LeviMorrison About to try to implement streaming request bodies ... other than that, nothing exciting to report.
 
user895378
@Leigh lol
 
@Lusitanian Still alive? :P
 
@Prefix i guess try this codepad.viper-7.com/PNTWqU
@Truth yeah
@Truth o.o that's weird
 
@Lusitanian LOL beautiful function names
 
8:41 PM
My Autoloader is similar to yours
 
@Truth that's nothing to do with it if you read the error msg
 
@Lusitanian I know
 
@Lusitanian ughhhhhhhhh still just outputs "registered:current", not the value >_<
 
@Prefix well unless array_slice is broken idk
that's weird
 
@Lusitanian Why is it even trying to open Lamed Test Suite anyway?
 
8:43 PM
@rdlowrey Yeah, we just got a new director, so I've been busy doing name changes in various places across the website. The most boring part of this job :/ Fortunately I don't do stuff like this very often.
 
not sure if discovered a broken function... or I'm just a bad programmer. haha
 
@Truth yeah that's what I don't know lol
 
It's obviously getting that from the name attribute, but wtf?
 
@Prefix could be a little of both (; no honestly i dunno thats weird
@Truth idk. that's bizarre
 
@Lusitanian yeah.. all I did was copy/paste your code and change the var names
and it outputs: array(1) { [24]=> string(18) "registered:current" }
instead of: array(1) { [26]=> string(17) "20114-0609-333-90" }
 
user895378
8:46 PM
ugh, if only stream_set_chunk_size were available before php5.4 my life would be so easy right now.
 
makes no effing sense
 
:(
need to figure out a workaround to this, been wrestling with it for like 3 days lol
 
@Lusitanian =(
Is it worth opening a question on Stack Overflow?
 
@rdlowrey Well, at least implementing it can check to see if it's available and if so use that :)
 
user895378
@LeviMorrison oh good call, completely forgot I could do that :)
 
8:49 PM
@Truth probably
@Prefix ask on s/o maybe someone smarter than me will recognize the issue
 
user895378
Actually, as I look into it, implementing chunked transfer encoding for request body sends manually looks so trivial I shouldn't have complained in the first place :)
 
@Lusitanian Haha already did, that's how I got @PeeHaa involved. :p but no worries! I appreciate the help. :)
 
hiya @LuizCoura ;)
 
@PeeHaa what hashing does oauth1 use for sigs -- half-asleep and i dont wanttogoooooogleeeeajofdisaj
 
@Lusitanian do you mean what is hashed or what algo or both?
 
8:53 PM
algo, isn't it the entire request body that's hashed
 
0
Q: PhpStorm PHPUnit integration fail

TruthI'm trying (for quite a while, with help from fellas at the PHP chat room) to succesfully integrate PHPUnit with PhpStorm. I've set up the phpunit.xml file as follows: <?xml version="1.0" encoding="UTF-8"?> <phpunit backupGlobals = "false" backupStaticAttr...

@Prefix What's the problem?
 
@Lusitanian it depends :)
And no it is not just the body that gets hashed
What happens is:
 
@rdlowrey Fatal error: Call to undefined method Artax\Http\MutableStdResponse::readResponseHeadersFromStream() in /var/www/helpdesk/library/Site5/WebSocket/Client.php on line 80 :) any clues?
 
@Truth Neither "Lamed Test Suite.php" nor "Lamed Test Suite.php - clever
 
@Leigh Isn't it?
Reading the source code that generates that error:
            throw new PHPUnit_Framework_Exception(
              sprintf(
                'Neither "%s" nor "%s" could be opened.',
                $possibleFilenames[0],
                $possibleFilenames[1]
              )
            );
it gets better
 
user895378
8:55 PM
@webarto Yes -- I should be able to fix that, just need a few minutes.
 
            $possibleFilenames = array(
              $inClassName . '.php',
              PHPUnit_Util_Filesystem::classNameToFilename($inClassName)
            );
 
I don't use Storm mate, sorry, I just looked out of curiosity, and I think it's probably PHPUnits fail
 
@Leigh Don't think so.
 
@rdlowrey no problems, man, just asking to see if it's me :) nice work really ... forgot to mention you, I wrote some s* server in PHP, and it stalls often on bad request, I need to figure it out...
 
1. It's running fine from CLI
 
8:57 PM
@Truth exact same command line?
 
2. When used with default settings (no phpunit.xml file), it also works fine (except it's ugly as hell)
 
get all body params, auth header params and query string params and encode both the keys and the values (rawurlencode) and sort this by key. After this prepend it with the http method and the URI seperated by &. After that encode the whole thing again with rawurlencode(). That is the stuff you want to hash. @Lusitanian
 
If it works with the same command line outside of the IDE, it's most likely an environment issue (paths etc)
 
@PeeHaa sounds annoying
 
@Lusitanian hehe yep :) That's why most people went for oauth2 ;)
But it is easily doable if you just follow the steps in the correct order and don't forget to multi encode :)
 
8:59 PM
yeah but it sounds error prone and i'm half asleep, i'll do it later or you will
 
user895378
@webarto Wait, I don't see anything like that in Client.php line 80 -- can you post what that line looks like in your file?
 
I'm have been trying to get the soundcloud service running for an hour now but it keeps 401'ing on me :P If I get that sorted out soon I'll write up a signature clas
 
ok, i made another push recently and am about to update artax
 
@Leigh CLI with the same config file fails as well
 
@Truth is the config file just overrides on the default? Did you try adding one directive at a time to see which one it fails on?
 
user895378
9:02 PM
MutableStdResponse::readResponseHeadersFromStream() definitely doesn't exist, but I don't see anywhere in any of my code where it's called -- Client::readResponseHeadersFromStream exists, but if you're pulling specific functions out of the client class I can't promise things will work for you.
 
@rdlowrey sorry man I'm little slow today pokit.org/get/img/6d1e7b14dafe1ecb6398b13121fd4b28.png my Client.php ...
object(Artax\Http\MutableStdResponse)#69 (6) { ["statusCode":protected]=> string(3) "101" ["statusDescription":protected]=> string(19) "Switching Protocols" ["wasSent":protected]=> bool(false) ["headers":protected]=> array(3) { ["UPGRADE"]=> string(9) "websocket" ["CONNECTION"]=> string(7) "Upgrade" ["SEC-WEBSOCKET-ACCEPT"]=> string(28) "IgK0if7XIRlfDWHRHlTj4oZ8Q+w=" } ["body":protected]=> NULL ["httpVersion":protected]=> string(3) "1.1" }
@rdlowrey my fault, on line 80, sorry :( (response is good)
 
phpunit -c "D:\Websites\htdocs\lamed\tests\phpunit.xml"
 
@PeeHaa updated Artax so you may wanna pull
 
@Leigh That's the command I ran
And it gave the same error.
 
pulling...
 
user895378
9:03 PM
@webarto yeah, that's not going to work -- Client::readResponseHeadersFromStream exists but it's a protected method. You can't just call it. It works in the context of the client to generate the response :)
 
Even the example XML file from their site gives me the error.
Now I'm confused.
 
i wonder if they even use windows
 
@rdlowrey I have like 50 tabs opened in IDE, all working good :) HTTP/1.1 101 Switching Protocols UPGRADE: websocket CONNECTION: Upgrade SEC-WEBSOCKET-ACCEPT: hen5fujf8s4m5iNk/TAowJyr160= <--- this is what I wanted ;)
 
@Lusitanian I don't see what could make the code vary so much between linux and windows
 
neither do i but @LeviMorrison said he has windows issues too
 
9:05 PM
Yeah...
 
can you pull phpoauthlib and run the test suite and see what happens...i'll put the phpstorm porject there if you want
 
Well, let's wait for an answer, maybe someone knows.
 
afternoon ladies and gentlemen
 
Well, I'm off to bed.
 
ah okay
night
 
9:07 PM
Let's see how this develops tommorow
P.S. if you do find the answer, post it and I promise a 100 minimum bounty if it's correct
 
i don't care about the rep, but i'll look into it more later
 
@Lusitanian I think I found my error on the soundcloud service: "This endpoint accepts POST requests and is used to provision access tokens once a user has authorized your application."
 
yes, they all do right
 
wait wut? they all do?
:P
 
POST yeah
that's all they take
 
9:12 PM
damn :)
 
pastebin your service class and i'll look for anything that might stand out as obviously broekn
 
I've been staring it this for too long. Lemme go out with the dog and when I don't have a bright idea then you may fix it ^^
 
user895378
@webarto @LeviMorrison Would a string Client::whatWillYouSend(Request $request) be helpful to you? It would allow you to retrieve the exact raw HTTP message that will be sent if the specified request is passed to one of the Client request methods?
 
user895378
There's no way to tell exactly what will be sent without handing a request object to the client because it modifies/adds/replaces certain headers to guarantee a valid request.
 
9:17 PM
@rdlowrey it is cool, I only send headers as a response, that would be very helpful when dealing with various server, currently, I know exact output... currently, I'm little stuck here... pokit.org/get/img/5ef62f714299722ab625937d6fc8267e.png I don't know how to write/read, or is there ->close(), or something like that... (I understand connection will be killed, I've set 1s timeout (local))
 
user895378
there is no close fclose to close a connection. the streams work sequentially -- you send a request by fwrite on the socket stream. once it's sent you can then read the response with the various fread type functions.
 
user895378
If you want the socket to not block (like for async) you need to call stream_set_blocking($fh, 0)
 
@rdlowrey Name could use work, but useful function. Can change name later ;)
 
user895378
@LeviMorrison yeah, I just thought of it, don't know what to call it :)
 
what is socket stream here, $client, $request, or $response :) @rdlowrey sorry for stupid questions
 
user895378
9:20 PM
@webarto none of them are. The individual socket connections only live inside the Client black box. You can use the public client interface methods and that's it. It's not designed for you to be able to use individual component methods :)
 
user895378
so you have the option setters, like setTimeout, etc... and you have the public request methods: request(), requestRedirectTrace(), requestAsync()
 
ah, ah, got it, I just need to write data once and that's it, how to accomplish that? :)
$client->writeData($data); bye!
 
user895378
Yeah -- Client::request does everything -- it sends the request and returns the Response object instance so you can check things like $response->getStatusCode()
 
user895378
It does everything
 
user895378
The returned Response object will tell you everything you need to know about what the remote server returned from your request.
 
9:23 PM
@rdlowrey Including Base URL?
 
user895378
@hakre not sure what you mean?
 
user895378
You should already know the URL because you requested it.
 
Hey there
I've been trying to switch from mysql to mysqli
 
user895378
@hakre If you're wondering about a redirect -- Client::request redirects transparently, but you can access an array of every response in the redirect chain with Client::requestRedirectTrace, which returns an array of response objects.
 
But I'm having a few troubles and errors.
I was wondering if any of you would be willing to help out.
 
9:25 PM
@rdlowrey final one would be sweet
I'll take a look
 
It would be better in a serporate chat room
 
@JordanRichards :) I can help.
 
:) Hey
 
@rdlowrey gotcha... actually this Client of yours solved a problem now for managewp.com :P
 
Could we go in a seporate room?
 
9:28 PM
@JordanRichards I sent an invite to another room.
 
user895378
@hakre Thats a good idea. I'll see what I can do about implementing an extended response object ... something like RedirectedResponse that has URI getter methods and return that if a request was redirected ...
 
@Lusitanian I just must be doing something stupid: pastebin.com/GW4YpM7H
It 401's with body {"error":"invalid_client"}
 
9:48 PM
0
Q: PHP - Functions from the controller in view

Michał KrólI'm trying to learn MVC pattern, (but without the models because I don't see for what I can use them when I have the controllers). So I want to display some content in my view. How do I do that? This is my controller that takes care of index: <?php class Index extends Controller { fun...

The first sentence is a kicker
 
user895378
lol
 
Yeah, he clearly didn't grasp the point of the whole separation of concerns thing.
 
@tereško yeah that was fun.
@RoelvanUden I'd say he is concerned about not separating things. But he is to shy to admit which I think is a pity.
@tereško: I would prefer the first short version of your answer. Just telling that this is not MVC in a simple way is great.
 
10:03 PM
ok I'm off to bed. @Lusitanian if you can spot the error at some point it would be great, because it just keeps 401'ing :P
 
good night
 
Love this:
:/ Just tell me what none of the tutorials I read didn't - Why do you need Models when you have Controllers? Models have functions. Controllers too. Controllers call Models. What's the point? — Michał Król 11 mins ago
 
@tereško it's admirable that you continue answering MVC questions when nearly every time you post a well written answer someone comes in, acts like this, and downvotes...
 
@orourkek , that comment actually was quite reasonable. And it was not the cause of downvote.
 
will there be a difference in the update table syntax in a table with user_id set to auto increment and where user_id is used as a foreign key ?
 
10:11 PM
@tereško I assumed he downvoted, which changes the whole tone of the comment; Though I guess you could be right
 
the cause was my picking on the glorious CakePHP in the "discussion" under your answer
 
@tereško quick question please. You are the MVC master. :) Since we all know that a model is not a class, how do you logically collate your model code into an organised unit? (i.e. how a namespace separates code)
 
the "model code" ends up in 3 namespaces : \Service\* , \DomainObject\* and \Persistence\*
 
So you use namespaces at a very fine-grained level
 
namespaces kinda map to the directory
 
is it \Service\*\Model ... or \*\Model\Service
 
I feel puny and pathetic after reading that
 
i no not have a Model namespace
at least not now
but i might end up with one
 
@tereško When I put "model", I meant the "name of the model"
sorry
 
$userMapper = new \Appication\Model\Persistence\User;
 
10:18 PM
Ok, thanks, that explains it. You do use very limited scope namespaces.
 
what is the mistake here
$query="UPDATE user_profile SET being='$being', ethnicity='$ethnicity' ,'language='$language',".
"game_online='$onlngame',music_genre='$muzicgnr',movie_genre='$muvignr',".
"sports='$sports',travel_to='$travel',music_band='$music_band',movie='$movie',".
"book='$book',colour='$colour',hobby='$hobby',quote='$quote' WHERE user_id='$live_id'";
$result=mysqli_query($dbc,$query);
 
yes , i do
 
what's the best way to store database connection info for multiple namespaces? I'm trying to declare database constants for different namespaces in a single config file, so that when classes in those namespaces make db calls those constants are used, and that doesn't seem to be working.
 
instead of class ProfileController, i use Application\Controller\Profile
@dyelawn , why not just create separate closure for each connection , which can provide you with the specific connection as soon as it is required ?
 
@blackbee: what error do you get?
 
10:27 PM
$provider['default'] = function()
{
    $instance = new PDO('mysql:......');
    $instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $instance->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
    return $instance;
};
 
> Before every flight, Ted Keller, the senior technical manager of the on-board shuttle group, flies to Florida where he signs a document certifying that the software will not endanger the shuttle.
@ircmaxell If only a similar requirement existed for every "secure" web application that get's released... ^^
 
@dyelawn , then you pass this array of providers to the factory , which will be creating the objects, that deal directly with storage
 
i entered hello into all the fields and the error is
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''language='hello',game_online='hello',music_genre='hello',movie_genre='hello',sp' at line 1
 
not quite sure I understand, but I would like to know why what I have set up currently is not working
e.g., I have namespaces \SourceA\DBObject\ and \SourceB\DBObject\. Then in a config file I have namespace SourceA {DB_HOST,DB_NAME,DB_USER,DB_PW} namespace SourceB {same}
when I declare a namespace at the top of an action file (e.g. namespace SourceA;), it just uses the first set of constants
 
@blackbee: you MUST escape all your data before using it in a MySQL query. See mysqli_real_escape_string
 
10:32 PM
and I think what I'm going for is what you're describing
 
done
 
yes , i was describing something, that does not require a global state in form of constants
something that follows OOP principles
my mistake
 
i defined
function clean($input)
{
$output=stripslashes(strip_tags($trim(input));
$filtrout=filter_var($output, FILTER_SANITIZE_STRING);
return $filtrout;
}
andthen
$language=mysqli_real_escape_string($dbc,clean($_POST['language']));
 
but what if you have a ten classes in the same namespace that all use the same db. where do you get the values from, or do you type them in to every function?
*method
 
@blackbee: I got confused with 'hello',sp, thinking there was an escaping problem. Remove the single quote in front of 'language and try again.
 
10:36 PM
ok
 
Field names may be enclosed with backticks but never with single or double quotes.
 
ow mistake of typing
one single quote made me a blind moron
problem solved
 
:)
 
for the time being
 
don't know well enough to distinguish OOP from procedural, but my database methods follow: $db = new mysqli(DB_HOST,DB_U,DB_PW,DB_NAME). I want the methods to use the values that correspond to their namespace
and would rather not have to set those variables inside each class
 
10:41 PM
@hakre .. the OP in that post obviously decided to accept the answer, which told him, that he is doing everything right.
7 mins ago, by dyelawn
but what if you have a ten classes in the same namespace that all use the same db. where do you get the values from, or do you type them in to every function?
@dyelawn, what are you talking about ?!?!
are you saying that you are creating a separate class for each DB configuration ?!?
it's like creating functions
 
no. I have one database class
 
function add2()
{
    global $foo;
    $foo = $foo + 2;
}

function add5()
{
    global $foo;
    $foo = $foo + 5;
}
this is how i understand your explanation
 
that connects using the variables DB_HOST, DB_USER, DB_PW, DB_NAME. Each namespace uses a different database. e.g. \CompanyA\Employees\, \CompanyA\Products\; \CompanyB\Employees\, \CompanyB\Products\. namespace CompanyA { DB_HOST = 'xxx', DB_USER = 'xxx', DB_PW = 'xxx', DB_NAME = 'xxx' } namespace CompanyB { DB_HOST = 'yyy', DB_USER = 'yyy', DB_PW = 'yyy', DB_NAME = 'yyy' }
 
why do you need constants , if you are using each value only once ?
 
I'm using them across multiple classes within the same namespace
and the database class is at the global level
 
10:50 PM
 
:)
 
i apologize for not understanding why the question is so stupid, but I'd like to know why the namespace declared before the include of the init file is not carried over to the config file that's required in the init file
 
@tereško is lucky... He has space on his desk enough to slam his head on it.... I am envious
 
using constants enables me to write standard methods for database objects that can be used across multiple classes, i.e. save(), create(), update(), delete()
 
@Justin if you don't have, then it's called
 
10:55 PM
@Justin and I even have a scarf there , to not mess up forearms on the sharp side of desk or ruin elbows by spending several hours while lean on the elbow
@dyelawn , the question is stupid because you do not understand OOP while trying to used advanced OO structures
 
lol... I've got a heavy head -- i'd break my laptop if i did the face-keyboard (dont know how to do the tag look).. and my desk is full of monitors, broken computers, and computer parts... why i don't know... but they are there
 
meet you people soon with problems
 
that's a very indirect answer, where a more direct one might help me to better understand such advanced OO structures
 
That's actually a very direct answer @dyelawn... can't get anymore direct than that really... Not understanding the basics of OOP while trying to utilize advanced OOP methods, always ends up in a horrible worded question and even worse code to look at..
 
the code that i've mentioned is not what i'm using in practice, it was a simplistic example to try and illustrate the issue that i'm having. moreover, what I'd really like to understand (and what the initial question referenced) was why a file with a declared namespace is not congruent with values drawn in from an included file.
and i don't think it's ever a bad idea for somebody to try to learn more advanced methods with the help of people that might be able to teach him
 
11:04 PM
Sometimes the objective falls outside the scope of either: A. What the "teacher" is willing to teach. B. What the "student" is capable of learning
 
without trying to sound like a prick, I'm capable of learning quite a bit more than you might expect.
 
Here is the rule of thumb , that i use:
> Everyone is stupid till proven otherwise
 
unfortunately i don't have a copy of my SAT scores or my diploma handy, so you're going to be without that proof
 
@dyelawn , the core of your problem is that you are trying to use constants at all costs
what you are doing this way is hard-coding the values in your classes
 
if my questions have been horribly worded, I'll make an effort to be more clear. I am trying to use the constants because the design I'm hoping to implement would make the addition of new modules extremely easy. What is a better way to carry those values around?
 
11:09 PM
@dyelawn honestly one of the best ways to learn "advanced OOP" is to read lots and lots of books.
 
no, I'm patently trying to avoid putting constants into my classes
 
@dyelawn and you would have to add new constants for each new module
 
correct
four lines of code in the config file
and the ability to use the global database class
 
whoooaaaahhhhh hit the brakes
 
11:10 PM
as opposed to writing in the necessary values for any method that needs to interact with a db
 
global database class???
 
can you please draw in paint?
 
database_object class, sorry, the database class is the built-in mysqli extension
 
what's the good word?
 
every time the words global and database occur in the same sentence, @tereško sacrifices a kitten to the clean code gods
@dyelawn nothing to do with the database should ever need to be global
@ircmaxell b-b-b-b-b-b-b-b-b-b-b-b-b-bird?
 
11:23 PM
sometimes I wish there was a +2 button... — alfasin 18 mins ago
 
11:34 PM
still not getting it
why doesn't it make sense to use a top-level class for methods that all extending classes will use?
and if the values for connecting to the database aren't defined at the namespace level, where should they be defined?
and most importantly (since it was kind of the original question i asked), if fileA declares namespace A, then includes fileB which has multiple namespace declarations, why wouldn't the namespace declared in fileA determine which namespace is used in fileB?
 
We had a demo of our app today for some clients. It is a really awesome feeling when you create something and actually see it being used and hear positive feedback about it.
 
11:55 PM
:-D
Congrats!
 
Thanks for you guys for making me build a great Social Network. just the HTML part is left --> 183.83.210.1/Startoff/home
 

« first day (661 days earlier)      last day (4286 days later) »