« first day (973 days earlier)      last day (3980 days later) » 

there is an SQL query used on a table product as follows
SELECT
name,
IF(LENGTH(description) <= 30, description,
CONCAT(LEFT(description, 30), '...')) AS description
FROM
product
ORDER BY name;
I am not clear with IF statement in query I never saw an if statement inside SQL the explainaition given in book is following use the LEFT(str, len) MySQL function to extract the first N (len) characters from
the product description, where N is the number of characters to be extracted. The following
SELECT command returns products’ descriptions trimmed at 30 characters, with “. . .” appended
to the end if the description has a length greater than 30 characters:
can any one point me to any resource which can explain me IF and CONCAT in SQL
 
3:35 PM
What about you check the mysql documentation?
 
where exactly
more over documentation is for experts
 
@RegisteredUser Where do you think?
 
I am a newbie
 
experts do not need documentations - they just know
 
The documentation is for people like you @RegisteredUser
@Telkitty猫咪咪 Not entirely through. Even more so with PHPs terrible API ;)
 
3:37 PM
I'd use notepad.exe before Dreamweaver; at least it behaves predictably. — Bracketworks 13 secs ago
 
see this link google.co.in/…
there is no IF in SQL
 
You just won the award for the fastest ignore in history of mankind. Gratz! and good bye
 
@RegisteredUser Documentation is for everybody; especially newbies.
 
@PeeHaa埽 for some reasons I kept on thinking PHP sits somewhere between perl and C++, but it is neither as easy as perl nor as versatile as C++.
 
If there's anything a newbie shouldn't use in many circumstances, it's third-party tutorials. Sure, they get you off the ground, but you end up flying sideways with your ass out. Read the documentation. (the preceding: IMHO)
 
3:41 PM
@Telkitty猫咪咪 PHP is shit easy (to get started)
 
@PeeHaa埽 What's the best example of PHP's unpredictable API? I always see parse_str as the least self-documenting function in the batch.
 
@PeeHaa埽 I am not a newbie, I am not learning PHP, the 'easy' bit will get me nowhere (for the task I want to carry out)
 
@Bracketworks best example would be array vs string functions arguments order
 
@Bracketworks name it parse_query_str
 
@PeeHaa埽 Oh, the $haystack and $needle confusion?
 
3:43 PM
parse_str is also pretty crappy named
@Bracketworks yes
 
@bwoebi I'll get right on that ;)
 
@Telkitty猫咪咪 Why wouldn't the easy bit get you anywhere?
 
we should make parse_str an alias of a parse_query_string or so. and remove the alias in 3 years
 
@bwoebi I think I have seen either a internals discussion or a bug report about this some while ago if I'm not mistaken
 
@bwoebi No, we should make $array = (new Uri($string))->getQueryArray()
As well as ->getQueryString()
 
3:47 PM
@Bracketworks this would be objective-c
 
@bwoebi No, this would be object oriented.
 
I mean. overly object oriented. like obj-c.
 
I think of URIs as first class objects; not sporadic collections of strings and arrays arranged to the developers liking; that creates confusion.
 
@bwoebi Nopez. That wasn't it. Basically same thing though
OMG @bwoebi
> However, there needs to be a vote on the naming conventions that are used. Perhaps following PSR-1 or PSR-2.
:P
 
@PeeHaa埽 nobody needs PSR's. We all only need to have a clean style. not a fix style.
 
3:50 PM
Everytime somebody mentions PSR-x I start twitching. Everytime I see it for core I start shooting :P
 
Sheesh, gotta love "Status: Wont fix".
 
@bwoebi I think it came up in the discussion about namespacing in php at some point
 
spaces, tabs and newlines are overrated. the parser ignores them either way.
 
@PeeHaa埽 you want to force users to use namespaces?
 
@igorw I always minify my PHP files before shooting it to production ;)
 
3:52 PM
@igorw this is not a clean style.
@PeeHaa埽 sure.
 
@bwoebi that's like.... your opinion, man.
 
@bwoebi No. The idea was to start introducing namespaces next to the non namespaced functions IIRC
 
@igorw and your opinion? :-P
 
3:53 PM
@bwoebi black
 
@PeeHaa埽 I thought the idea was to use auto-boxing?
 
@PeeHaa埽 That's a spectacular idea. In @bwoebi's linked issue, two people brought up reasonable (responsible) solutions, such as flags to throw notices when using the deprecated aliases.
 
@igorw just inverted my screen's color to read this.
 
@igorw I prefer red
 
@ircmaxell sweeeeet
@bwoebi Not sure. You are probably right
 
3:56 PM
@PeeHaa埽 this rfc: wiki.php.net/rfc/autoboxing
 
off to go try to find something for Father's day... Later
 
@ircmaxell ok ... that's awesome
 
@ircmaxell when is Father's day in your country?
 
Tomorrow
 
I'm not sure where it was discussed. And I don't really want to look into it :-) @bwoebi
 
3:57 PM
ah okay. here it's in october.
 
@tereško yeah, I've heard acoustic sets before, but that's freaking rediculous
later
 
@PeeHaa埽 I think PHP's procedural system is basically very good, just not coherent enough in function names and parameters
 
@bwoebi Exactly. But since you cannot just change them
 
I really notice a difference in how often I need to lookup the C stdlib's reference and PHP's reference.
 
No surprise there
 
4:00 PM
@PeeHaa埽 we should maybe use some compliance mode you can change with ini-sett... wait... we all know this was no good idea when there was y2k compilance
 
:P
@bwoebi It would be almost impossible to fix this. Only thing I see is either namespacing or introducing the awesome "string"->replace('foo', 'bar');
Neither will happen soon I think :)
 
@PeeHaa埽 If this would be really awesome, I don't know.
 
primitive object literals?
 
I have a lexing problem. related code here and here. see also the edn format spec.
 
@Bracketworks I would also be fine with (new String('string'))->replace('foo', 'bar') :D
 
4:06 PM
@PeeHaa埽 Ok... allow me to revise: primitive objects?
 
Too much regex for my groggy head
 
@igorw who uses regex to parse large data should be burninated. use simple string accesses, strncasecmp etc.
regex is a) slow like hell and b) difficult to decipher.
it's okay to parse only a few commands… but not a whole language.
 
I want to be able to match +, - and . as single-char symbols. the problem is that they can also be part of numbers (+5, -5, 5.0). so I need to match them as symbols only if they are not part of a numeric sequence.
 
4:11 PM
@igorw Lookahead?
Negative lookahead specifically: [+-](?!\d)
 
if (in_array($string[$i], ["+", "-", "."]) && ($string[$i+1] < ord(0) || $string[$i+1] > ord(9))
    $matched = true;
 
@Bracketworks will try this.
 
@PeeHaa埽 you could write yourself such a lib
 
Also, to match . (dot) not as a decimal value (?<!\d)\.(?!\d)
But I don't know if you need to account for literals like .5
Is there a BNF for edn?
 
@bwoebi Sure I could. But I don't want to introduce extra dependencies on external libs for my codebase
 
4:15 PM
@Bracketworks unfortunately not :-/ it's rather loosely specified.
 
Don't know how adherent it is though.
Oh wait, that's the superset.
 
@PeeHaa埽 I think if you'd build a patch for the PHP core it would have a chance to get into it (I mean not the auto-boxing).
could go into /ext/spl
 
@bwoebi I doubt that it would have a big chance, but maybe I'm just getting old :)
 
why shouldn't it, in /ext/spl?
 
Dunno. Because internals?
 
4:20 PM
you mean the people?
 
I love the operator-overloading extension from PECL; old mind you, but even today, it would stand a snowball's chance in hell.
 
@Bracketworks this works for almost all cases. now I just need to match on surrounding whitespace to prevent +5symbol from being matched as [+5, symbol].
 
yeah @bwoebi
Note to self. user is a keyword in sql idiot
 
@Bracketworks see nikiC's pinned rfc?
 
@bwoebi No, I mean userland operator overloading.
class Foo { public function __op_plus($operand) { } }
Or whatever it was.
 
4:23 PM
this?
 
ah okay
 
Looks like it might be forked.
 
@Bracketworks I think this would also have no chances...
 
hello ;)
 
4:26 PM
I don't know how it would be with a String, Integer etc. class (without auto-boxing first) as this would only require a simple 50% votes majority
It's no language change, only function/class addition
 
Anybody have a good tip or source for getting a PHP site (MODx) with friendly URLs to play nice with Backbone routes?
 
I had a wacky idea: cross-cutting parameterless interface constructor invocations to select and return an implementation, thus: $o = new OInterface(); and $o's type is selected and constructed based on available implementations and run-time configuration.
Too fragile or crazy?
 
anyone can help me for this question wordpress.stackexchange.com/questions/103068/…
 
no
 
4:43 PM
@Bracketworks thanks for your help, all the tests are passing now \o/
 
@igorw Awesome! No prob man :)
positive/negative lookahead/behind are so under-used
a mod appears, everyone silently hides in the bushes
 
heya @minitech
 
1/4 pizza gone, going for 1/2
 
0
Q: Where/when to implement some COUNT() statements in my MVC application

DavidOk so I have my CustomerMapper mapping my Customer domain object perfectly but today I was in the middle of some business logic in one of my domain objects which uses my Customer object and I realized I needed to have some sort of if( $customer->getNumActiveOrders() > self::MAX_NUM_ORDERS ) C...

 
4:59 PM
Whenever you're on SO chat on mobile, and you lose connectivity, it informs you with a modal <div> popup. This is all fine and good, but everytime you dismiss it, it comes back about a second later.
I think I'm going to post to meta about a fix for this.
 
@tereško hey could you can give me some guidance on the question above please
 
@David would i be mistaken to assume that the amount of orders is required only in specific cases ?
i would have a collection of orders , which i would bind to the customer (or vice versa) and extract the amount from the collection
 
@tereško yeah I do not think I will need to know how many active orders a customer has more than 2 or 3 times I would say. when you bind what exactly do you mean?
 
$customer->assignOrders( $orders ); or $orders->setCustomer( $cutomer ); ... depends on which element depends on which
 
0
Q: The "loss of connectivity" modal in mobile chat is intrusive

BracketworksWhen connectivity is lost using the chat, a modal box politely indicates this. The issue is, while the box is dismiss-able, it will immediately reappear if connectivity has not been reestablished. This is problematic when I know I have no connection (elevator, basement, bomb-shelter) but intend...

 
5:11 PM
@tereško ah yes I get you thanks again
 
> depends on which element depends on which
I read that like 3 times to make sense of it.
 
sorry ... english is not my native tongue
 
Also, 1/2 pizza gone; going for 3/4's
Oh I wasn't criticizing, there's nothing wrong with it; it just reads very peculiarly.
;)
7/8's pizza gone; can't make it though...
 
 
Oh nice, you wrapped them all :)
Yea, they're wicked assertions; like regex-peek
 
5:18 PM
You are asking how to multiple it by 1.6? — PeeHaa 埽 22 secs ago
@PeeHaa埽 haha
 
@Nile I was tempted to suggest the super useful; $.multiply() plugin ;)
 
@PeeHaa埽 isn't that bundled with jquery-arithmetic-1.3.js?
 
.. also .. the gist code fragment illustrates jquery at it's best
 
yeah noticed that too :D
 
5:21 PM
(I don't know what would be worse, a jQuery arithmetic plugin, or that it would have a version higher than 1.0)
 
0
Q: .htaccess opencart rewrite script that is causing error

Rahul KhoslaI just need some basic help. A lot of people using GoDaddy may have the same issue. I'm using opencart on my main domain - http://graphicshop.net I have added domains on my GoDaddy hosting panel, http://rahulkhosla.co.uk and http://greenginger.info (this one works perfectly). The http://rahulk...

 
@PeeHaa埽 there already exists Math.imul()
 
@bwoebi wat!?
 
5:26 PM
Ah ecma 6 :)
Still, not enough jquery :P
 
@igorw I just remembered, years back I was doing some work for a company, log parsing etc., and was writing some complex regex to extract parts; ended up banging my head against the wall with catastrophic backtracking or something: lookaround assertions to the mother-effing rescue.
 
@PeeHaa埽 at least a function
 
can anyone suggest a good tv series to watch ?
 
@tereško Power Rangers; original run from 93 to whenever
 
... i will assume that you missed the "good" in the sentence
 
5:37 PM
@tereško Have you already seen mad men?
 
nope , but i seems like not my cup of tea
 
Ok, fair enough
The Super Mario Bros. Super Show! is an American television series based upon Nintendo's Super Mario Bros. and Super Mario Bros. 2 video games. It was originally broadcast via first-run syndication to mostly independent or Fox television stations from September 4, 1989, to December 1, 1989, with reruns continuing until September 6, 1991. The Family Channel picked up the series on September 23, 1991, and aired it until August 26, 1994. The show was produced by DiC Animation and was distributed by Viacom Enterprises in association with Nintendo. DHX Media, the successor company of Cookie ...
Lou Albano for the win.
 
Sorry to bother, but I can't figure out this:
$page=$_GET["page"];
$succes=false;
while(!$succes)
{
	try{
		chdir($page);
		$succes=true;
	}catch(){
		$page= some kind of code that would return all before last "/" ($page is a file tree)
	}
}
 
@Akxe edit select all and do a ctrl+k top format your code before it's too late ;)
 
@Akxe Why is it wrapped in a try/catch block?
 
5:44 PM
It is due the fact that the adress might be wrong and I need to find the nearest correct
 
Also why are you using data from the clientside to walk through the filesystem?
 
could be dangerous to trust the client blindly
 
it is from mod_rewrite, the adress is putted into the $_GET
 
0
Q: Postgis group by query

Chris PappasI have two tables: CREATE TABLE periphereies ( gid serial NOT NULL, per character varying(60), geom geometry(MultiPolygon), CONSTRAINT periphereies_pkey PRIMARY KEY (gid) ) WITH ( OIDS=FALSE ); CREATE TABLE archaia_theatra ( gid serial NOT NULL, "ΘΕΑΤΡΟ" character varying(254), ...

 
@Akxe If you want to implement some routing scheme I would rather just setup some array to handle this instead of trying to find a possible path
 
5:46 PM
but the script does have more permission than the user so the user could list restricted directory tree
 
@ChrisPappas How is that PHP related?
 
It's not, but it's just a chat
 
Who told you that?
 
everones says what it want
 
@Happyninja No I looked into that all ready now I am trying to correct user errors...
 
5:47 PM
@ChrisPappas Please read our room topic
Also your question is lacking a question
 
@Akxe oh okay good ;)
 
@PeeHaa埽 How you ment that?
 
you want to confirm directory exist?
 
@PeeHaa埽 i'm gonna try "Perception"
 
kind of I need to use chdir() anyway
 
5:49 PM
@tereško Don't know that one. Let me know whether it is worth the download will you
 
k
 
https://student.sps-prosek.cz/~eisead11it/web/a
is the adress I wanna find student.sps-prosek.cz/~eisead11it/web
Preg_match may solve it no?
 
... well .. if all that fails, i could re-watch "The Pretender" again
 
@tereško Saw Red Dwarf?
 
i tried , but it felt too old (and that's from a guy who puts Babylon5 in the "best series" list)
 
5:56 PM
What is an room that could help me with preg_match?
 
@Akxe Why do you think you need preg_match?
As I see it a simple strpos() === 0 will work just fine
 
hmm ... i will have to start using limit for torrent download speed =/ .. the 5GB season has 40 minute ETA
 
well I would try to return all before last "/" form a string as this:
~eisead11it/web/a
that should give me: ~eisead11it/web
@PeeHaa埽 where and how? don't get it you mean like get position and return all before?
 
I thought you just wanted to match the two strings
 
@tereško breaking bad
 
6:04 PM
@Akxe I'm guessing this should do what you want (.*)[\/][^\/]*$ untested. But I would rather use strrpos and substr for this I think
 
@PeeHaa埽 why that? I thouth the preg_match may be clearner
 
Meh. I like the verbosity of it more
 
@Bracketworks there's an XKCD reference hiding in there somewhere
 
"Info", "Data", & "Object" in class names are correctly pronounced "ummm"
 
@PeeHaa埽 Actually could I get a bit of explenation of the piece of pattern since I dont understand it at all... :/
 
6:09 PM
.. has been posted here , but i felt like re-positing it
 
"Manager", "Util", "Helper"
 
those actually seem more like namespaces
 
@PeeHaa埽 And return "web" in place of ~eisead11it/web from ~eisead11it/web/a
 
@Akxe huh. neh that shouldn't. Let me test whether I screwed up
@Akxe works for me: rubular.com/r/F8SbWcxfv8
basically match everything up to a / and everything that is not a / anchored to the end
 
@PeeHaa埽 Thanks for the page
 
6:13 PM
np
 
$page=preg_match("(.*)[\/][^\/]*$", $page); This is what I did with your code, is it wrong?
 
See the manual about the functions you are using
 
@igorw it's best if you combine them... ManagerUtilHelper, MangerHelperUtil, UtilHelperManager, UtilManagerHelper, HelperManagerUtil, HelperUtilManager all do different things!
 
6:30 PM
$pattern="(.*)[\/][^\/]*$";
$subject=$page;
preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, 3);
Directly from php.net and $matches=null
$page=preg_match("(.*)[\/][^\/]*$", $page);
return into $page string "web"
 
@Akxe You don't think you need delimiters?
 
@PeeHaa埽 I hadn't really used preg_things before I have no clue... what an delimiter is
 
6:46 PM
Hello, everybody!
 
@PeeHaa埽 Hola, como estás?
 
Pretty good now that I have had a good meal and hydrated a bit
 
Good! I thought you speak a Spanish sorry!
 
I feel really dumb... still can't figure this one out...
 
6:55 PM
Hi every one
My html form is like this

<html>
<body>
<form action="createconnection.php" method="post">

Firstname : <input type="text", name="Fname"> </br>
Lastname : <input type="test" name="LName"> </br>
Age : <input type="text" name="Age"></br>

<input type="submit">

</form>
</body>
</html>
and php file :

<?php
if (!empty($_POST))
{

$con = mysqli_connect('127.0.0.1:3306' ,'root','root','my_db');
if($con->connect_error)
die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());

$stmt = $con->prepare("INSERT INTO table1 (Fname, LName, Age) VALUES (?,?,?)");
$stmt->bind_param('ssi',$_POST['fname'],$_POST['lname'],$_POST['age']);

if (!$stmt->execute())
die('Insert Error ' . $con->error);

echo "1 record added";
$stmt->close();
$con->close();
}
?>

But it's not working
any idea
 
@Programming_crazy "it's not working" is not a problem description. related: whathaveyoutried.com
 
Ok sorry dude! problem is when I click submit button on html form, it shows code of .php file rather executing php script
 
@Programming_crazy btw I would use type='number' in the age since it's fall back is into text and it have more options as min='0'
have you apache or some kind of php procesor installed?
 
I have installed wamp server
 
@Programming_crazy try using <? instead of <?php but it shouldn't change much
 
7:01 PM
class helper{
public function __set($table,$type){
global $dbConfig;
$pardConfig=new PDO('mysql:host='.$dbConfig[0].';'.'dbname='.$dbConfig[1],$dbConfig[2],$dbConfig[3]);
$sql=$pardConfig->prepare("SELECT * FROM ".$table." WHERE menu_type=?");
$sql->execute(array($type));

$result=$sql->fetchALL(PDO::FETCH_ASSOC);

}
}

$helper = new helper();
How to call to the $result array
?
 
You are pretty new to programming, aren't you?
 
can anybodoy help me please ?
 
I use:
$db = new PDO(
"mysql:host=" .dbserver. ";dbname=" .dbname, dbuser, dbpass,
array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
PDO::MYSQL_ATTR_INIT_COMMAND => "SET CHARACTER SET utf8"
)
);
And then for fetch I use:
$db->query($sql)->fetch();
$db->querry($sql); for inserting
 
I want to use $result array for foreach.How could i get that result array to it ? how to call it from the object ?
 
user652649
@Samithaఠ_ఠ you are using __set the wrong way, a global variable, and you're using an array instead of an associative array/dictionary.... just saying xD
 
7:09 PM
@Samithaఠ_ఠ foreach ($db->query($sql) as $result)
If I understood you right
 
Akxe did you get my problem?
 
@Wes So how wiould i modify my code ?
 
@Programming_crazy Did any of your othe php code work?
 
yes, i created script which insert data in table
 
user652649
what are you trying to do? why is that code inside __set ? __set can't return (at least using it in the magic way) so if you are planning to use the fetch outside of that method, you have to store the resultset elsewhere
 
7:12 PM
but when I work with html form then it gives this error
 
user652649
but i'd use instead a normal method like setSomething()
 
@Wes is that easy ?
 
user652649
@PeeHaa埽 watching ita-ned? xD
 
@Programming_crazy Link please it is wierd
 
user652649
@Samithaఠ_ఠ no, what are you trying to do?
 
7:14 PM
@Samithaఠ_ఠ What are you actually trying to do?
 
user652649
public function setSomething($table,$type){

...
$sql->execute(array($type));
$result=$sql->fetchALL(PDO::FETCH_ASSOC);
return $result;

}

$recordset = $obj->setSomething($a, $b);
// use $recordset here..
 
When I click submit buton it shows this :

connect_error) die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error()); $stmt = $con->prepare("INSERT INTO table1 (Fname, LName, Age) VALUES (?,?,?)"); $stmt->bind_param('ssi',$_POST['fname'],$_POST['lname'],$_POST['age']); if (!$stmt->execute()) die('Insert Error ' . $con->error); echo "1 record added"; $stmt->close(); $con->close(); } ?>
 
@Wes I'm going to create a Helper class with sql select,update,insert statement.So i use __set magic method.it's worked nicely.but the problem is i can't get the $result array outside from class
 
@Wes nopez. Neither have I seen many matches of <21
Is my side winning? :)
 
@Programming_crazy pure copy of error?
 
user652649
7:19 PM
me neither, but ita-ned is a match that must be seen xD 0-0 anyway, ned is playing better
 
yay :D
 
user652649
@Samithaఠ_ఠ exactly, __set can't return anything
 
user652649
why don't you use __get instead?
 
user652649
because apparently you want to get data, not setting something
 
7:21 PM
@Wes #if i use __get how would i set my 2 parameters,($table and type)
 
@Programming_crazy try var_dumb($con);
 
@Wes $helper->pard_menu = "main"; i did it like this ... i used var_dump($result) and i get the array .but i can't get the array to foreach
 
user652649
@Akxe lolz
 
@Wes why not? no idea why it is doing it...
 
user652649
@Akxe lolz xD var_dumb()
 
7:27 PM
@Wes ah :D
 
user652649
@Samithaఠ_ఠ so on the right of = you're not passing data to store, but you're using __set as a shortcut of a "one parameter function" ? you're doing really wrong...
 
user652649
@PeeHaa埽 do you remember ita-ned of euro 2000? best match i've ever seen, not for you probably xD it was an actual war, i think netherlands would have deserved to win anyway xD
 
@Programming_crazy var_dump() sorry misspelled
@PeeHaa埽 sorry I still hadn't figgured it out could you help? :)
 
@Wes Was that the match that ended in penalties?
 
user652649
yes, don't you remember Toldo? :P
 
7:31 PM
@ Akexe: where to use it? I am new to php
 
$con = mysqli_connect('127.0.0.1:3306' ,'root','root','my_db');
var_dump($con);
die();
if($con->connect_error)
 
user652649
@PeeHaa埽 x youtube.com/…
 
@Programming_crazy To make an answer use the little arrow in the right bottom corner of bubble ;)
 
@Akxe yeak ok got it!
 
7:35 PM
@Wes Thanks for reminding me... :P
 
user652649
aha xD
 
@Programming_crazy Did you used the code I posted a moment before? If you did what is inside?
 
user652649
i don't have good memories neither of that event... france won :( damn cheese eating frenchmen!!! xD
 
@Akxe Yeah I did it but when I click submit button it redirects to createconnection.php page and shows nothing!
 
@Wes Yes! Those wine drinking bastards
 
user652649
7:38 PM
lol
 
class helper{
public function setSomething($table,$type){
global $dbConfig;
$pardConfig=new PDO('mysql:host='.$dbConfig[0].';'.'dbname='.$dbConfig[1],$dbConfig[2],$dbConfig[3]);
$sql=$pardConfig->prepare("SELECT * FROM ".$table." WHERE menu_type=?");
$sql->execute(array($type));

$result=$sql->fetchALL(PDO::FETCH_OBJ);
return $result;
}
}

$helper = new helper();

$MainMenu = $helper->setSomething("pard_menu", "main");
@Wes finally wrote this
Thanks guys
 
Try (place into the original code)
if($con->connect_error){
die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
}
 
@Samithaఠ_ఠ WHY?! do you have a global in there?
44
A: Use global variables in a class

PeeHaa 埽The correct way to solve this would be to inject the database handle into the other class (dependency injection): $db = new DB_MySQL("localhost", "root", "", "test"); // connect to the database include_once("pagi.php"); $pagination = new pagi($db); $records = $pagination->get_records("SELECT th...

 
$dbhost=null;
$dbname=null;
$dbuser=null;
$dbpass=null;

$file = __DIR__ ."/config.json";

$array = file_get_contents($file);
$dbConfig=json_decode($array);

$pardConfig=new PDO('mysql:host='.$dbConfig[0].';'.'dbname='.$dbConfig[1],$dbConfig[2],$dbConfig[3]);
 
user652649
@Samithaఠ_ఠ also, don't use numeric indexes for $dbConfig, use an object or an associative array.... also don't use globals...
 
user652649
7:40 PM
@Samithaఠ_ఠ
 
user652649
why are you using json to store config data?
 
Just a question what definition does (memory, processor)
 
Hey guys. Why would placing the sql connect variables like $dbname, $dbuser, etc. inside of an if or switch prevent the php program from connecting to the database?
 
@wes i have a installed directory. users installed my application in their host.In my admin panel i used a form to get host,db,use and pass.and i'll store that into the json file.I know it is wrong.
 
@Samithaఠ_ఠ That isn't an answer why?!?! you would use global
 
user652649
7:45 PM
plus, why are you using two database connections? seems you have already $pardConfig active
 
@PeeHaa埽 i'm using that to get $dbConfig array into the Helper function
@Wes yes it is active but i don't know how to use it with helper function ?
 
@Samithaఠ_ఠ why?!!?
Please read the post I linked
 
@PeeHaa埽 i was get that and create another PDO object inside the Helper class
 
user652649
new Helper($pardConfig)
 
user652649
and inside __construct
 
user652649
7:49 PM
$this->connection = $pardConfig;
 
user652649
then use $this->pardConfig->prepare(....)
 
@Wes can you changed my code in full.seems like i messed everything
<?php


$file = __DIR__ ."/config.json";

$array = file_get_contents($file);
$dbConfig=json_decode($array);

$pardConfig=new PDO('mysql:host='.$dbConfig[0].';'.'dbname='.$dbConfig[1],$dbConfig[2],$dbConfig[3]);


class helper{
public function setSomething($table,$type){
global $dbConfig;
$pardConfig=new PDO('mysql:host='.$dbConfig[0].';'.'dbname='.$dbConfig[1],$dbConfig[2],$dbConfig[3]);
$sql=$pardConfig->prepare("SELECT * FROM ".$table." WHERE menu_type=?");
$sql->execute(array($type));

$result=$sql->fetchALL(PDO::FETCH_OBJ);
 
user652649
yes, but why you would create a second database connection while you already have one? you should reuse it
 
I have a knowledge in those.but yet i don't know how to use it
@PeeHaa埽 reading
 
user652649
@Samithaఠ_ఠ pastebin.com/Qu70R7WH
 
* imitating @ircmaxell * ... blah!
 
@Wes I would not expect something called set* to return an entire result set
 
user652649
yeah xD better than __set though xD
 
@Wes do i want to use new PDO('mysql:host='.$d ???????
 
user652649
7:58 PM
@Samithaఠ_ఠ i don't know. do you? xD
 

« first day (973 days earlier)      last day (3980 days later) »