« first day (243 days earlier)      last day (4708 days later) » 

1:48 AM
hi
 
sleepy sleepy morning guys
 
 
2 hours later…
3:25 AM
I neeeddd coffeeee
 
 
1 hour later…
4:27 AM
The exception handling in PHP is so confusing. Isnt it? What I want to say is, I have a function to get records from the database. Where I have been using try catch and throw to throw exceptions whenever something goes wrong. I call this funtion within try catch. But insttead of my custome message it displays annoying mysql errors. Why????
 
post your code
 
function getdata(){
Try{
//Run a query against database table
//etc etc
}catch(Exception $x){
throw("Something goes wrong");
}
}///end function

//------------Calling this function----------
try{
$data = getdata();
}catch(Exception $x){
echo $x->getMessage();
}
//----------------- On calling this function it displays mysql error instead of "Something goes wrong"
 
do you put throw inside your try?
throw doesn't accept string. You need to use the Exception constructor
 
4:53 AM
@Phelios, yes i used throw new Exception(); as well but did not work
 
it seems that it doesn't really hide the original error message
what kind of sql error are you trying to handle?
 
mysql error, it does not matter what error. I want to hide those and show my custom. The fucking PHP exception handling is extremely poor
 
you programming skills are extremely poor
 
PHP
lol
 
you are probably doing it the wrong way
 
5:03 AM
well .. since he have shown only the code he thinks is wrong , it is impossible to tell
 
@xcoder this is probably what you are looking for
 
PHP
do you guys also thinks that use of extract() [php.dzone.com/news/php-bad-practice-use-extract] function is a bad practice?
same as this blog
 
i use it for templating
 
first time heard about it
 
PHP
@teresko and what about the general purpose ?
 
5:10 AM
something teresko would use should be fine :)
 
PHP
do you think its not good at all
@Phelios.first time heard what ?about this function or about that its not a good practice?
 
about that function
 
It is a fact that PHP exceptional handling is none of use and extremely poor
 
PHP
@Phelios I found it simple if you have to fetch so many fields from your forms or tables .. but bit confuse about its use
or its practice you can say
 
haha.. I still use the normal form
arrayname['key']
:)
 
5:31 AM
@xcoder what his dress has to do with his profession... it is his wish... lets leave it
 
PHP
One ZCE question .. need help to find its answer.. please if you can
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>XML Example</title>
</head>
<body>
<p>
Moved to <<a href="http://example.org/">http://www.example.org/</a>.>
<br>
</p>
</body>
</html>
Quest- What is wrong with this document, and how can it be corrected?
 
<br> need to be closed properly
<br />
xml in html file?
hmm
but doctype have to be in the first line
 
PHP
let me post option.. that may help
 
<<
 
PHP
1)The document is completely valid

2)All special XML characters must be represented as entities within the content of a node

3)All tags must be closed

4)You cannot specify a namespace for the attribute

5)The DOCTYPE declaration is malformed
@Phelios .. am just thinking about declaration .. what you say?
 
it's probably xhtml
the xml declaration is commented out when run on Chrome
 
PHP
@Phelios hmm.. you right ... that means option 5?
 
wait
 
1. close the br like phelios said
 
PHP
am trying to validate as @iforce2d suggested
 
5:51 AM
those 5 are the multiple choice answer? haha
 
2. change <<a href to &lt;<a href
 
i think the answer is 3)All tags must be closed
 
PHP
@Phelios yeah these are option
@Phelios yeah these are option
@iforce2d and @Phelios I agree with br tag should be close
but still found that its not validate
@iforce2d you says about change the < to &lt;
but its not in 5 options.. I have given
 
the DOCTYPE is fine
not malformed as the validator.w3.org said :)
 
PHP
@Phelios yeah I found this..
I found so many good questions without them answers :(
@Phelios have you heard about "fingerprint of a string"?
 
6:37 AM
nope
 
PHP
ok
 
 
1 hour later…
eml
7:49 AM
A lil' SQL question to start the day off: I have two tables: event and eventbooking. SELECT event.* FROM event WHERE event.id=xyz

I also want to count() all matches in eventbooking according to ON event.id=eventbooking.eventid ... Which SQL JOIN operator? I'm getting a bit confused after trialing and erroring and now getting errors I don't quite understand.
 
use group by?
 
eml
Hmm?
 
@eml , not really on topic, but a suggestion : use the same name for column on every table .. instead of event.id and eventbooking.eventid , that column should be always named eventid or event_id
that will save you some confusion when it comes to larger/more complex db structures , and you will be able to use USING statement in JOIN operations
 
eml
@teresko Good suggestion, although I prefer the event.id naming I'll take that into account for my next project. :)
 
SELECT event.*, count(*) FROM `event` join `eventbooking` on event.id = eventbooking.eventid
group by event.id
not sure if it will work on yours
try it out
1 question
do you want to show the 0 count?
 
8:01 AM
( you might really want to look into what you can do with USING .. i too looked to use event.id , but i changed my mind )
.. oh.. and shouldn't table names be in plural ?
 
if you do, you would need to use left join on the above query
 
eml
I didn't name the tables. :)
 
use USING?
 
@Phelios in this case you cannot
 
hmm
show me some example for USING please :)
 
8:05 AM
if you could then that query would look like :
SELECT Events.*, count(*) FROM Events LEFT JOIN Eventbooking USING(event_id) GROUPBY event_id
 
eml
@teresko I can change the column names, I have time to change all my queries. I should name the columns event_id in both event and eventbookingright?
 
any performance advantages?
 
none , nor there is any loose
it just makes queries easier to read
 
i see
 
though i suspect in a complex join you would gain some performance benefits
 
8:08 AM
but I think @eml naming is alright
id to specify a primary key
 
for what ?
 
while eventid means foreign key
 
and who told you that you need a primary key named "id" ?
 
I didn't say "you need"
 
eml
@teresko Awesome, thanks a bunch!
 
8:10 AM
for that last statement of yours , i would just point you to
 
eml
adds book to me-want-list
 
@Phelios , if you use column with name "id" then it adds ambiguity to your SQL statements
as for USING statements , it becomes especially handy , when you have large number of joins in your query
try it , you will see
 
eml
Great suggestions @teresko, I really need to read a book. I've never put any time into SQL, just started writing
read that book*
 
8:26 AM
haha.. too lazy for books now
 
8:36 AM
heh, spaghetti query. quite descriptive.
 
btw: anyone worked with oracle? :-D because there's one interesting "feature"... your query will probably not finish, if you're selecting from big table (millions of records) with even one tiny OR.
 
@KamilTomÅ¡ík - Been writing an oracle (oci) adapter
But as of yet, a load of untested code. Still need to see all kinds of bugs of different species in it.
 
@ChristianSciberras good for you, just remember to not write ORs - no kidding, we've done everything to avoid it - even temporary tables and it was always faster than OR
 
Is there anything similar to IN?
WHERE id IN (1,2,3,4) ?
I must say though, avoiding ORs is quite difficult.
 
@ChristianSciberras I'm not sure, if I remember correctly, ORM mapper called a lot of queries like this - so it should be
 
8:49 AM
It's like making a calculator without it being able to do a simple AND gate :)
 
@ChristianSciberras yeah, mostly depends on number of records - when you have so much data, it's real bottleneck to use OR
 
anyone has APC installed and running on windows?
 
lol ... you set up your testing server on windows only if you really love pain
 
@teresko that wasnt my question
 
9:27 AM
0
Q: returning a value usiong zend forward

dean jasei have a function in another controller which i want to access using the zend forward function, public function creanAction(){ $myvbale=22; return $myvbale *2; } in my other controller i have this: public function localForwardAction { this->view->message=$this->_forward("crea...

this is not my question but i am very much curious to know the answer.. i tried but i am not getting..
 
@teresko I love pain so I use DOS 6.22
 
10:06 AM
What are good reasons for me to get into PHP rather then node.js ?
The few advantages I've heard of PHP are the language differences and that PHP is available on every linux server
 
@Raynos its every where!
lots of example codes, scripts out there
its designed to be a templating language.
ecmascript isn't.
there is lots of nice libraries out there
basically for everything
look at GD how cool is that !
interface for almost every database out there!
 
 
1 hour later…
11:30 AM
PHP vs. javascript. hmm, that's a tough question.
NOT!
 
Sid
Hi all, I am trying to generate a CSV file using the php function fputcsv() - the file gets generated but the data doesn't seem to get written to the file, I am stumped. Appreciate any advice...
 
@Sid write a unit-test
 
Sid
hmm I have no idea how to...
 
@UniqueKey troll.
@OmeidHerat meh there are plenty of nodejs database libraries
I dont need badly written example/scripts
js has some really nice efficient templating engines I prefer to use. (Seriously who inlines PHP into a html page these days)
 
@Sid but you are a smart guy and can learn how to do it. And you can google ;)
 
11:41 AM
@OmeidHerat I'll give you one on the image library though. Havn't seen any nodejs libraries that work out of the box for images.
Then again theres plenty of node SVG / canvas libraries where you can render canvas elements on the server and stream it to the browser.
Which is a good alternative to dynamically generated images.
@UniqueKey you don't seriously think PHP is a superior language to javascript do you? I mean there different, I think ES5 is slightly nicer then PHP because PHP just has so much API bloat
 
Sid
@Gordon haha :-D am on the case. I know whats causing the problem, its because I am trying to change the headers on the page.
@Gordon Thanks for your help dude.
 
@Raynos people who write pages in php
because php IS a templating language
 
@Sid np
 
which is one thing that javascript is definitely NOT
 
@teresko I agree with that. But what makes PHP a better templating language other then in build support for it?
I guess the way it does string manipulation
Show me a PHP template I couldn't do with a js templating engine
 
11:58 AM
@Raynos i don't believe i'm a troll for stating the obvious, and that remark was uncalled for. they're completely different languages, not necessarily qualitatively.
if you're wondering whether you should use one or the other for achieving the same purpose, then maybe you're misusing either one of them
 
12:20 PM
posted on June 16, 2011

Here's what was popular in the PHP community one year ago today:Otto on WordPress: WordPress 3.0: Multisite Domain Mapping Tutorial PHPBuilder.com: Three Advanced Object-Oriented PHP Features You Need to Know phpRiot.com: Combining PHP, JSON and jQuery Screencast Chris Hartjes' Blog: Book Review - CodeIgniter 1.7: Professional Development Listmania: 10 Books To Help You Master PHP Development

 
hey anybody know the ans of stackoverflow.com/questions/6371607/…
 
@RockDance there is four answers and two deleted ones. how about you tell the people who wrote them why they dont work for you instead of asking for new ones?
@RockDance you also might want to clarify your stackoverflow.com/questions/6368535/… because its pretty unclear what you are trying to replace with what. provide input and output examples.
 
'lo all
 
@Raynos , show me anything that cannot be written pure assembler .. there are tools for the job .. and then there are trolls who cannot see further then own "favorite language"
 
12:38 PM
@teresko Stop mis interpreting me.
It was a serious question. What parts of PHP make it a better templating language then any other language like haml.
@UniqueKey I'm looking for reasons to use PHP instead of server-side javascript. I'm not knowledgable in PHP and I just wanted to know good reasons for me to go and explore it.
If you prefer a more common question then something along the likes of what does the PHP based server-side stack bring that Ruby or Python stacks do not.
 
@Raynos , to begin with , it is an object-oriented language
 
Oh.
 
@Raynos , you said "compared to HAML"
stop flip-floping
 
@Raynos - aren't you asking for templating language like haml?
 
@teresko your right.
How does one apply OO techniques in templates?
 
12:42 PM
you do , in MVC
because you sometimes pass into template a Model
 
@Raynos exploring php for the sake of exploring php is a good enough reason :)
 
+1
 
@Gordon given infinite time yes
 
@Raynos and why would you even ask such a retarded question ?!? php is not mainly used for template , but for web application in general
... which means that you bias is showing through .. again
 
...
 
12:45 PM
here is one other reason:
PHP is backwards too but scales from a simple web form to Facebook. One can only dream to make software as useful as PHP...
 
I'm asking about the general strengths of PHP over other serverside stacks
I'm trying to make it as unbiased as possible :\
 
and we are saying that you have no clue what you are talking about
 
@teresko I agree.
That's why I'm asking you people what the strengths of PHP are over other stacks
 
@teresko s/we/you ;)
 
maybe just go and learn asp.net
 
12:47 PM
You might also want to consider how many people here know Python or Ruby or whatever as well as they know PHP
 
@teresko I already know asp.net
 
then stick with it
 
No. Stop being an idiot.
6
asp.net is an abomination
Constructively rephrased :
In what type of web applications does PHP shine and why?
 
anyone know good tools to do system architecture block diagrams? preferably free ones?
@Raynos in any but real time apps because php has connectivity galore. it might not look as fancy or pretty as in other languages, but in general php can do almost everything
 
@Gordon creately.com
 
12:51 PM
what do you mean with "connectivity galore"
 
@Gordon , if you need something UML'ish , then VisualParadigm is pretty ok , and the community version is free
 
@Raynos what i mean is php can talk to a vast amount of external systems and services
@Raynos just look at the amount of db extensions de.php.net/manual/en/refs.database.php
 
@Gordon I presume almost any web development environment can call any arbitary shell command
Can php do "more/better" talking then running arbitary commands on the unix shell?
 
@Raynos its not shell commands. its native extensions. its api
 
12:54 PM
@Raynos that would be good if all environments had a standard way to do things
 
I see. so the comparison is you can call git on the command line. Or you can have a ready made abstraction / API around the git command line that you can just plug into PHP
 
@Raynos so your argument is: all a programming language needs is a function to call the command line?
 
PHP is more "Write once, run anywhere" than Java ^_^
 
what i meant with connectivity galore is, php has a lot of connectivity out of the box. this makes php a fine glue language between external subsystems. need mysql? pick your api. need stomp mq? no problem. php has it. need to interface with java? can do too. windows com? sure thing. etc etc
 
@Gordon no it's not
@JohnP yes thats a strong advantage.
@Gordon those APIs are by Zend ? are they open source extensions?
 
12:59 PM
and then of course, php is shared nothing which makes it extremely easy to scale. just throw more hardware
 
Some are by zend, most are open source
 

« first day (243 days earlier)      last day (4708 days later) »