« first day (802 days earlier)      last day (4161 days later) » 

12:00 PM
i have no freaking idea who you are , but i am capable of making the right-click, left-click & scroll necessary for viewing your top tags
and yes , i have a small monitor
 
Yea im here because im watching people suffer with a god aweful langauge while learning it myself. Might need it for a job
 
language is not so bad .. think of it as mix of java and javascript
... wait .. that sounds actually pretty bad
The main issue is the low entrance barrier. You do not need to know anything about programming to write code in PHP .. or to write a tutorial PHP.
 
But the problem with PHP is it does it wrong.
 
@JakobBowyer i would recommend for you to steal this book somewhere: amazon.com/Beginning-PHP-5-3-Wrox-Programmer/dp/0470413964
you should be able to flip through it in day or two
 
Im pretty confident I have grasped the basics
But thanks for the tip
 
12:06 PM
in that case , this would be useful for you: wiki.hashphp.org/Main_Page
and beware of bad tutorials
 
I avoid mysql as much as I can
 
well , the PDO interface works with Postgre too
and MSSQL =]
 
Im one of these new hip no-sql pricks
 
user1125394
ahh beware
 
user1125394
nosql is written in 1 word else
 
12:25 PM
Could anyone please help me with the deprecated function `mySQL_num_rows`. My code is:

`$result = mysql_query($query, $link)`

and I want to modify it so that if there are no rows returned by `mysql_query`is set to false. This should happen already according to the PHP manual but it isn't for me. Am I doing something wrong? Thanks!
As for using a deprecated function, I will update it soon :-)
 
show some code
 
echo "ok\r\n";
 
Please, don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.
@JakobBowyer there is actually PHP_EOL contant for that
 
screw EOL constants.
I don't want to write echo "ok" . PHP_EOL;
 
im assuming that you are not using non-US keyboard layout
 
12:39 PM
Hm?
British keyboard
 
well , in some layout you get ° , when trying to write \
 
Ah, well sucks to be them?
 
@tereško I did say that I was going to update them shortly! I'm just returning to using PHP after about 5 years and so I haven't learned the new methods for doing this, just trying to get some functionality up and running with what I know and will then update everything.
 
@tereško I was takling about that approach codepad.viper-7.com/IW1rCV. Any comment?
 
user1125394
1:17 PM
what a complex thing for nothing big
 
1:47 PM
@cyril ?
 
mornings
 
@NikiC mornings
 
morningly tingly
 
user1125394
@Eugene why do you need to add manually to a method stack, there are function like method_exists
 
@cyril where do you propose to use it?
 
2:01 PM
GM all !
 
@Eugene What are you trying to do exactly with this ?
 
@Touki doesn't matter. I've just wanted to know, why it is behaving like that.
 
user1125394
I have a problem concerning junction tables and multi-categories, sqlfiddle.com/#!2/818de/1 would like to be able to query for multiple tags
 
I understand, that parent private methods can't be used by child.
Only protected and public
 
user1125394
but I don't think junction tables allow to do it, so I have made tags aggregation, but it's crap
 
2:09 PM
@cyril select * from points JOIN pointstags USING(id) WHERE tag_id IN ("white","big"); ?
 
user1125394
@Touki oh yeah
 
user1125394
thx, because sqlfiddle.com/#!2/818de/6 was turning into crap
 
And you need OR not AND
You can't say WHERE 1=1 AND 1=2
 
user1125394
no I need, points that satisfy being white AND big, satisfies all tag criteria, not at least one
 
But what if public method calls private from within the class and this private checks whether this or in current example child class has given methods and what if some of those methods are private.
 
2:13 PM
Morning all
 
user1125394
@Touki so no, it's not what I need, I really want a AND, do you have in mind a way to write that query, without relying on the additionnal rows I inserted (bigwhite, ...)
 
@PeeHaa Morning
 
morning @PeeHaa
 
user1125394
@Touki of couse select * from points JOIN pointstags USING(id) WHERE tag_id="white" AND tag_id="big"; have no results, but do you know a way to find id's that have a row with white and big?
 
WHERE LIKE ?
 
user1125394
2:18 PM
hmm, how?
 
Uglyly SELECT * FROM points JOIN pointstags USING(id) WHERE tag_id LIKE "%white%" AND tag_id LIKE "%big%";
 
user1125394
and tag_id would be "big, white" then?
 
@PeeHaa Good Eastern Standard Time Morning to ya!
 
How's everybody this morning?
 
@cyril You'll just match any tag_id that contains "white" and "big"
 
user1125394
2:20 PM
@Touki hthat must be not much performant, I prefer the concatenation trick that you have seen on the fiddle
 
user1125394
@tereško please could you see if you have any idea? ^^
 
user1125394
@Touki If there are 2 identical pointstags tables I can do select * from points JOIN pointstags as t1 USING(id) JOIN pointstags2 as t2 USING(id) WHERE t1.tag_id="big" AND t2.tag_id="white";
 
You need to match "bigwhite" and "whitebig" ?
But not "big" or "white" ?
 
user1125394
I need points entries that have both tags white and big
 
user1125394
(as an example, could be 3 conditions)
 
2:40 PM
hey @cyril what's the actuall problem?
 
user1125394
@andho getting a SQL structure to query entries with tag1 and tag2
 
why do you store tags like that, "tag1tag2"
should tag1t match with tag1tag2?
 
user1125394
this is only what I've found so far
 
Hi, I'm looking for the correct term to describe generic relationship paradigm in database where any object can be linked with any other object through a single table. There were some terms like "level 2, level 3" but I can't google up the correct wording.
 
user1125394
when you store a point that have tags t1, t2, you will store t1, t2, t1t2 in pointstags
 
2:45 PM
@cyril may i ask why?
 
user1125394
@romaninsh many-to-many relationship?
 
it's not that easy.
 
user1125394
@andho the search system have to find entries that match t1 and t2 tags, I'm problably wrong with the SQL structure, tell me..
 
@romaninsh find it in the depths of hellll
 
@OlegOrlov You know this is the [php] room right?
 
2:47 PM
i remember it had articles on wikipedia. The highest level allowed to have as dynamic fields in tables... it's like what Wordpress is using for storing configuration.
 
Seems like you are :)
 
instead of having id, option1, option2, it has key/value pairs in the table.
 
2 messages moved to C#
 
de-normalized!
found it.
Database normalization is the process of organizing the fields and tables of a relational database to minimize redundancy and dependency. Normalization usually involves dividing large tables into smaller (and less redundant) tables and defining relationships between them. The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships. Edgar F. Codd, the inventor of the relational model, introduced the concept of normalization and what we now know as ...
 
it's past the normalization efficiency point, that's actually highest point of normalization, extact opposite of denormalized
@cyril i have something, bit of a hack, but might be good on the performance end
 
2:54 PM
maybe that's not it.
 
but i have to brush up on the WHEN clause a bit before i can do it
 
all my tables in database relate to table "OBJECT" which then can be related with any other object through "RELATION" table. I need to know how this paradigm is called in SQL
 
user1125394
a rare thing where php > python is to convert list to dicts, it's native in php, in python dict(zip(xrange(len(l)), l))
 
@cyril what i'm thinking is group by the id, count if the tagid matched either
 
Hi all
 
2:55 PM
put a having clause for the number of tags
 
user1125394
@andho I see, so filtering only rows that appears at least (tagsNumber), could you show me teh code in the fiddle :D, I'm still a SQL noob
 
is anyone in here experienced in PDO?
 
i have an issue with a PDO
MySQL is returning PHP Fatal error: Call to a member function bindValue() on a non-object
my original question is here: stackoverflow.com/questions/14041372/…
 
bindValue only works on a prepared statement, of which you have none :) — Jack 6 mins ago
You already have your answer @user1809790
 
2:57 PM
so how do I pass values in this case?
 
select *, IF tag_id = 'white' THEN 1 ELSE ( IF tag_id = 'big' THEN 1 ELSE 0) from points JOIN pointstags USING(id) GROUP BY id;
 
to my query
 
@user1809790 Use a prepared statement
 
i'm not sure about the if syntac
 
user1125394
2:59 PM
/me should stop editing chat response message since it pings multiple time
 
@PeeHaa the issue is because I need to do 2 queries, first i need to check if the username is already taken, and then do the actual insert
is that possible with a prepared statement?
 
let me check it
@user1809790 prepared statement can do only wht a normal query can do
 
@user1809790 First read the tutorial after that I'm happy to answer any questions you still might have
 
@PeeHaa @andho thanks :)
 
user1125394
@andho why nor using groupby ang having
 
3:02 PM
@cyril should be there, working on the if part first
i used to do this all the time
 
Good Morning
 
Monring @ircmaxell
 
morning @irc
 
How goes it?
 
user1125394
@andho will try a select id, ..., count(id) .... groupby id having count(id) > tag_count
 
3:05 PM
@ircmaxell hey IRC, long time, I wonder if you could enlighten me, how is this SQL design paradigm called: raw.github.com/romaninsh/manytomany/master/screenshot.png
 
inheritance
 
oh, that's it ?
 
5
Q: Inheritance in Database Design

StevenI am designing a new laboratory database with MANY types of my main entities. The table for each entity will hold fields common to ALL types of that entity (entity_id, created_on, created_by, etc). I will then use concrete inheritance (separate table for each unique set of attributes) to store ...

 
yeah that works too
got it, want it?
 
is anyone familiar with passing data to PHP through ajax?
$.ajax({
type: 'GET',
data: registrationData,
dataType: 'JSONp',
instead of having data:registrationData
 
3:09 PM
@ircmaxell what about the relations between any 2 objects? Does it also have some fancy name ?
 
can anyone tell me how to mention the fields that I need to pass to PHP only?
rather than serializing the whole form
 
@romaninsh depends on relationship
 
@user1809790 build an object with the fields you want
 
parent child id and a type.
 
3:10 PM
can you give me an example please? I am new to this :(
 
data: {
    username: registrationData.username,
    password: registrationData.password,
}
 
excellent!!
@and
@andho thanks very much!!
 
you can do the opposite
remote the data you dont want from registrationData
delete registrationData.Submit;
 
how?
 
then data: registrationData
 
3:11 PM
@ircmaxell cool thanks. i'll bug you with something else in a year or so :)
 
@andho so I have data: registrationData {delete: registrationData.username }?
for example
 
:-D
 
@user1809790 no no, you have to delete the fields you want prior to the ajax call, it's a completely separate statement
delete registrationData.username;

$.ajax({
....
 
@andho

var registrationData = $('#registration').serialize();
delete registrationData.username;

$.ajax({
type: 'GET',
data: registrationData,
dataType: 'JSONp',
@andho
something like this
 
@user1809790 ya
 
user1125394
3:13 PM
@andho if you have something not too hacky ok, but the idea to build aggregated tag rows (with combinatorial) I like it cos it works on all databse systems
 
@andho let me try it out :)
 
@cyril select , COUNT() AS count from pointstags WHERE tag_id = 'white' OR tag_id = 'big' GROUP BY id HAVING count = 2;
i took just the pointstags for simplicity, but you got the idea right? You actually got the idea before me
 
user1125394
ok I'll see, thx
 
@cyril this is pretty standard SQL right, depends on what else you're gonna do with this query. In more advanced systems, these kinds of data is denormalized into an easier to query form
 
user1125394
yep (it's count >= 2))
 
3:19 PM
@cyril count = 2 should work right, would the same id have the same tag_id twice?
or are you also checking 'contains'
 
@andho unfortunately

var registrationData = $('#registration').serialize();
delete registrationData.username;

$.ajax({
type: 'GET',
data: registrationData,
dataType: 'JSONp',

Did not work :(
 
:6875625 var rdata = $(e.currentTarget).serializeArray();
    	        var registrationData = {};
    	        for (var i in rdata) {
    	        	registrationData[rdata[i].name] = data[i].value;
    	        }
 
user1125394
@andho o ur right sorry, they can't have more than 2
 
3:25 PM
damn, what's wrong with this code
@user1809790 check that out, i'm converting the values into keyvalue pairs
 
@andho ok
@andho just for curiosity, would something like this make sense?
$.ajax({
type: 'GET',
data: {username: $("#username").val(), password: $("#password").val()},
 
Thanks all for help, especially @ircmaxell, here is what I ended up with github.com/romaninsh/manytomany - ORM handling inheritance and any-to-any relations without database overheads.
 
@user1809790 yeah
 
@user1809790 Sounds moar like you need to do a post
 
Ok, but read that book ;-)
 
3:30 PM
Also you may want to read into the .serialize() method.
 
@PeeHaa at the moment I am using the serialize method, however there is 1 value that I do not want to pass
that is why I ended up with the above
 
@user1809790 What is the reason you don't want to pass it?
Is it big?
As in lots of data?
 
@PeeHaa let's all join hands to reduce the worlds bandwidth, every byte counts
 
@PeeHaa I have a form that contains:
username
password
password-check (for validation).

Now with serialize I pass the 3 values. However for some reason I am getting a php error and thought that maybe the reason is because I am sending 3 values when it expects 2
 
@user1809790 Error must be somewhere else, because on the PHP end it is just an array with values. Unless there is something stupid going in in the backend code like checking for number of items in the array (which I doubt)
BTW. You either way want to validate all the data on the serverside
 
3:34 PM
can I upload a php file to show you or paste it here
not sure how it works here
first time using the chat
 
What is the error you are getting?
@user1809790 Of it's a large code block either dump it on some paste service or in a github gist
 
@ircmaxell yeah for sure, certainly will do.
 
But first... what's the error?
 
hmm funny enough now PHP is not giving me any more errors
but logcat is telling me: Uncaught SyntaxError: Unexpected token : at mydomain.com/php/…
opsie:
mydomain . com/php/registration.php?callback=jQuery1720723289319556206_135653954858&username=995544&password=test&_=13656539579068:1
 
What is that :1 at the end of the URI?
 
3:39 PM
no clue where that is coming from :(
ah... wait
let me send you the code maybe you understand
basically I am checking if a username exists, and if no, do an insert
so, if a username exists, in php I am returning 1, otherwise 0
then in the success of the ajax call I am doing this
success: function(response){
if(response==1){
// user already taken
} else {
// user added
}
this is the php code:
header('content-type: application/json; charset=UTF-8');

$db = new PDO('mysql:host=' . $config['db']['host'] . ';dbname=' . $config['db']['dbname'], $config['db']['username'], $config['db']['password']);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$query = $db->prepare("SELECT `user_profile`.`Username` FROM `user_profile` WHERE `user_profile`.`Username` = :username LIMIT 1");
$addQuery = $db->prepare("INSERT INTO `user_profile` (`user_profile`.`Username`, `user_profile`.`Password`) VALUES :username, :password");
 
@user1809790 edit message and hit ctrl+k.
 
(obviously the host, dbname etc are all defined
 
Also a service like pastie is better for big code blocks
 
let me try it - never used pastebin
 
and also check the line that the error occurs on
wait, that's a javascript error right
 
3:43 PM
yep
think it's a js error. Not sure whether there is something wrong happening in the PHP/Database side and then screwing up the js
or whether my PHP PDO code is completely wrong
I am new to this so might be the case :(
 
You probably have invalid json
$_GET['jsoncallback'] . '(' . json_encode($response) . ');';
and echo $_GET['jsoncallback'] . '(' . json_encode($response) . ');'; don't produce valid json
 
are you using jsonp?
 
Who dares to mock PHP?!
 
@andho:
You mean define it in the js?

$.ajax({
type: 'POST',
data: {username: $("#username").val(), password: $("#password").val()},
dataType: 'JSONp',
url:
 
3:47 PM
-2
A: How appropriate is it to ask for upvotes in chat?

amanaP lanaC A nalP A naM AI am the offender (apparently). I see no issue in asking people to upvote a question or answer if it is a good contribution to Stack Overflow. Nowhere did I mention hats in my chat message there, but yes, hats were in mind. But I was not forcing anybody to vote! I was asking for votes, I assu...

 
Just inspect the request in your browser, with firebug for FF or developer tools for Chrome and check the response
 
you're using JSONP, so you're response should be wrapped in a function call, the function name should be the value of callback from the url
for example jQuery1720723289319556206_135653954858({status: true, otherdata:{}});
 
the problem im having is that since im developing for mobile I am using some touch events etc, and these are not working on my pc
so I can only test it on mobile and I cannot launch debugging tools
@andho what do you mean? Sorry I am a newbie :/
 
if you're current json response is:

    {status: true, otherdata:{}}

then for JSONP it should be something like:

    jQuery1720723289319556206_135653954858({status: true, otherdata:{}});
the function name 'jQuery1720723289319556206_135653954858' is provided as a url parameter: $_GET['callback'] which should be used as the function name for you're output
assuming you know what i mean by json response
 
@PeeHaa Consider yourself flagged as "offensive"...for shame, for shame — Bart 40 secs ago
 
3:54 PM
I HATE HATS! @Bart — PeeHaa 5 mins ago
 
@andho this is a bit techy for me :(
sorry was looking at some other answers provided to my question in the meantime
bindValue only works on a prepared statement, of which you have none :) — Jack 1 hour ago
 
@user1809790 guess you should read a little about jsonp, although i found examples of backend code for it lacking on the internet
 
yeah that is one of the problems i found
 
what i mean by json response, is the output of your php script
what you output from php is a response to the browser
usually the response format is HTML, sometimes JSON, in this case, jquery.ajax is expecting a response in JSONP format
 
wtf got down vote on right answer ... stackoverflow.com/a/14041349/1723893
 

« first day (802 days earlier)      last day (4161 days later) »