« first day (919 days earlier)      last day (4254 days later) » 

19:00
@bwoebi
$search = 'aaa';
$replace = 'bbb';
$string = 'This is aaa test to replace the first aaa and not the other aaa';
$search = str_replace('#', '\#', $search);
$result = preg_replace("#$search#", $replace, $string, 1);
echo $result;
???
model is not a thing or a class or an object
model is a layer
@Gordon have you had a good MVC article here on SO?
@emma.fn2 while i'm not the person you want to direct specific, high-level questions towards, i'm relatively new to the concepts of and accordingly might be able to give you a broad picture.
as opposed to presentation layer which contains controllers, views and other UI related stuff
(or I remember wrong)
19:01
@bwoebi inception: replace in a replace :o
user1596138
I really can't figure this out...
@HamZaDzCyberDeV Yes. Or When I begin to insert here some parenthesis which preg_replace then recognizes as regex error...
Presentation layer? This is more than I've heard of then, I basically just understand this: Front controller/dispatcher takes all requests, loads the appropriate controller based on the request, and same for the requested action, which then calls the model to get the data, and the controller then puts that into a view
@emma.fn2 the model layer would essentially have three main groups of structures: domain objects (business laws, rules, logic) , mappers ( storage abstraction ) and services ( the application logic )
consider a model plane 1) Model: the "model" is not the finished product, but the ideas that describe what you will build. 2) Views: in the instruction manual, you might have sketches for particular steps which describe an aerial view, a side view, or a zoom view of a particular component. 3) Controller: you are the controller, using various tools (services) to alter the model and form it into the plane
19:02
That's the problem with using for example user input in some regex...
@dyelawn I'll welcome any help lol, this is too confusing to me right now!
Damn do I hate booking flights - it is impossible to find a fitting one
@JosiahSouth What's the array you have and what would you like to "pick" ?
@JosiahSouth
If you want to pick the last value:
$array = array(1,2,5,9);
You can do
echo $array[count($array)-1];
@emma.fn2 that's to be expected, but don't worry, it gets better (or so I'm told). additionally, when i say things which you might understand but also potentially highly inaccurate, the good people here will tell you why those things are wrong.
@bwoebi Then the explode func should do the job o.O ?
19:04
@Ocramius Some weeks ago I've tried to book a flight. The best (for some route which normally takes 4 hours direct way) to find was something for the triple price and 30 hours inclusive one night of 5 hours between two flights (when changing plane).
heh
same situation here
@Ocramius Thanks, just got an example of what to use for state space search demo :P
@HamZaDzCyberDeV Yep. This was only to show why using preg_replace is really not the best idea....
@HamZaDzCyberDeV or just end($array)
@igorw I though of using array_pop but that will affect the array :p
19:07
@Ocramius you must have luck that you're finding at least one possibility xD
end will modify the pointer to the array as well, so you'd need to reset before the next foreach
@dyelawn thanks ^^
@bwoebi found one with 3 stops @_@ + gotta take the train in the end
@Ocramius where are you going? amsterdam?
@Ocramius train is bad
19:09
@Ocramius I've never had such a situation the years before... Who's only trashing all these planes...
@emma.fn2 since i am currently really busy watching starcraft2 vods, then just read this
that will cover what i could tell you in about half an hour =P
user1596138
@HamZaDzCyberDeV I have an array that I'm accessing by $info[1] $info[2] $info[3] and so on.
@igorw no, beziers, web-5
@MPKaboose it cannot be as bad as italian trains :D
user1596138
@HamZaDzCyberDeV I need to access the last value in $info[2]
19:11
@JosiahSouth So $info[2] is an array ?
user1596138
@HamZaDzCyberDeV Right.
@JosiahSouth Just do it like this:
echo $info[2][count($info[2])-1];
user1596138
It's actually $info['contact']
@Ocramius trains here are pure evil, trust me you rather walk then go with them
@emma.fn2 the main things i see with this are your lexicon and verb choice. your understanding of "model" seems more like an "object" of particular interest. the "dispatcher" you're describing is more like a router. it doesn't "load" the appropriate controller, it points the request to the appropriate controller. and the "action" would be a function of the controller. the model describes the data, but it doesn't get the data; a service does that.
user1596138
19:12
@HamZaDzCyberDeV Hmm.... That makes sense.
user1596138
Thanks, I'll try it.
@tereško thanks, I'll have another read xd
Or like @igorw said
echo end($info['contact']);
note that this will change the pointer
@MPKaboose haha, I got a friend there eventually, so I may bug him in the middle of the night =D
@dyelawn would it help out more if I showed you an example of what my current code looks like? I'm useless at explaining what I mean properly
user1596138
19:14
@HamZaDzCyberDeV See I tried this though. It returned nothing.
@emma.fn2 and instead of the controller "put[ting]" an object or objects into the view, it manipulates the object(s) into a form that the view expects
@emma.fn2 yes
@JosiahSouth Can you provide a var_dump ?
user1596138
It would return something if I used end($info); but not end($info['contact']);
So, @tereško, how'd the resignation go?
@Ocramius ha! poor fella :P
19:15
@MadaraUchiha there was nobody to hand it ro
@JosiahSouth end() works for me ...
$array = array(
	range(1,4),
	range(5,10),
	range(11,20)
);
echo end($array[2]);
user1596138
Hmm... Let me try end() again first.
@MPKaboose indeed :D
@igorw no
user1596138
19:17
This is going back and forth between the sql server, and is nested under certain conditions and then a while loop for output. So it's not as simple as just using var_dump right now hahaha
user1596138
I always get "Warning: end() expects parameter 1 to be array, string given in "
@JosiahSouth lol no problem ... Anyway the count should work for sure ...
@NikiC no as in, does not apply to foreach?
@JosiahSouth that means it's a string and not an array :p
$array = array(
	range(1,4),
	range(5,10),
	range(11,20)
);
echo end($array[2]);
reset($array);// reset the pointer !!!
@igorw no as in foreach automatically resets
If it wouldn't, you couldn't iterate the same dataset twice without always resetting it, right?
user1596138
19:19
@HamZaDzCyberDeV Exactly lol. I fucked up.
user1596138
Anyway, not that I used count I'm getting 1 letter returned.
@JosiahSouth ofcourse xD
user1596138
This is inside of a while loop... I should've specified haha. I'll post a sample
@dyelawn okay, this is basically how I've got it working at the minute: cl.ly/image/383M3H34081y
19:21
@emma.fn2 putting it in a gist might be helpful
@NikiC yeah, you're right.
@PeeHaa埽 hola
user1596138
Nevermind. Basically I'm using mysqli_fetch_array to create my supposed array.
@dyelawn hmm?
@PeeHaa埽 evening
user1596138
19:22
using $info = mysqli_fetch_array()
@emma.fn2 gist.github.com
@NikiC it's only relevant if you use current and next to iterate the array without reset. which should never happen anyway.
thanks for pointing that out
@igorw A pity those functions even exist
(imho)
This concept of a "global" array iterator is really weird
user1596138
@HamZaDzCyberDeV I've been fucking stuff up a lot today. Any advice now that I actually know what $info is? lmao
19:24
@NikiC yeah, the array shouldn't store a location itself in the first place.
@JosiahSouth var_dump($info); o.O ?
user1596138
Sure
@emma.fn2 but what i can see up front is: A) learn about autoloading/namespacing B) FrontControlleris a Router. C) getFromDb() belongs in a separate Database class, and that database class should be injected into the Controller and D) (though i think it's more trouble than it's worth) you'll be told that your Model should not represent an instance of a thing, but a description of that thing.
Hey guys, just a question, I saw something today in some random code.
I wonder what's the "best" to do:
    if(isset($a) && isset(b)){
    	echo 'set';
    }
    or
    if(isset($a, $b, $c)){
    	echo 'set';
    }
@emma.fn2 so ... few comments on that fragment of code:
- do not append name "controller" at the end, instead use namespaces
- you have tight coupling the the name of "model" in your controller
- model is not a glorified DB abstraction
- stop using public variables
- look into `spl_autoload_register()`
- the `$controller->methodName()` is a mistake ... there is not such method
- controllers should not be passing data to the views
- you do not need the `?>` .. it actually can cause errors
- "model" should not be a class or an object
user1596138
19:26
@HamZaDzCyberDeV array(8) { [0]=> string(11) "BBQ_Ribfest" ["head"]=> string(11) "BBQ_Ribfest" [1]=> string(4) "Doug" ["submitter"]=> string(4) "Doug" [2]=> string(518) "***HIDDEN***" ["comment"]=> string(518) "***ALSO HIDDEN…***" [3]=> string(22) "Sun, Apr, 04 - 1:13 PM" ["time"]=> string(22) "Sun, Apr, 04 - 1:13 PM" }
if would use isset($a, $b, $c)
.. i was a short fragment of code to review
@HamZaDzCyberDeV The last I'd say, it's shorter and I think one parser instruction per argument less
@dyelawn I now understand why I did not fell ever into that MVC murks...
19:28
@emma.fn2 ah, didn't know @tereško was still helping, I'm gonna let you get on with his recs. he's more capable and i have to typeset some business cards woohoo!
@NikiC for the proxymanager thing, I was gonna ask how much I could expect from PHP_Parser in terms of stability
@Ocramius Which kind of stability?
I mean, I just finished hacking together this thing and am considering using PHP_Parser since it's so awesome, but I don't wanna rewrite it each month :D
BC breaks
array(){
	[0]=> string(11) "BBQ_Ribfest"
	["head"]=> string(11) "BBQ_Ribfest"
	[1]=> string(4) "Doug"
	["submitter"]=> string(4) "Doug"
	[2]=> string(518) "***HIDDEN***"
	["comment"]=> string(518) "***ALSO HIDDEN…***"
	[3]=> string(22) "Sun, Apr, 04 - 1:13 PM"
	["time"]=> string(22) "Sun, Apr, 04 - 1:13 PM"
}
@Ihsan huh? can you tell me what was wrong about my description?
19:29
@JosiahSouth there is no array...
wow, only code talk here ...
@bwoebi ty
Thanks dyelawn & teresko, I've got a Database class setup and I use that in my real code, I've not yet actually made my mvc-solution so that's why I don't have that included
This is the 9000002nd message in this chat!
@dyelawn i am busy , watching starcraft tournament =P
19:30
@MadaraUchiha the 9 mio plus 2 ^^
@MPKaboose Welcome to the PHP chat Room, you're obviously not in a supermarket ...
@emma.fn2 there are DB classes in PHP already: PDO and MySQLi
@tereško somehow seems more productive than typesetting business cards.
@hamza but I wanted to buy some classes
@PeeHaa埽 hhahahahahah
Also look at the related list :|
@tereško Oh I am using PDO, but I have a Queries class with all of the queries I will be using in the application, which use PDO
19:31
@MPKaboose hi, how are you feeling today? do you have any pets?
@HamZaDzCyberDeV I really thought it would be the supermarket of gratis answers to your shittiest questions :/
user1596138
@HamZaDzCyberDeV Here's a more realistic dump. pastebin.com/gPJHz1wY
@PeeHaa埽 R.i.p. these old questions...
@bwoebi ....
19:32
@tereško or @dyelawn am I best off just starting from scratch with building mvc again? ): I think my current idea is just totally going in the wrong direction now
@emma.fn2 here is a free hint: don't try to make an ORM to go with your MVC-like implementation. Everyone tries it , and it fails miserably and all over the place. Just skip that step
@igorw hello, good, and you? I only have a fluffy cactus (plant) ... no animals
user1596138
@HamZaDzCyberDeV Oh shit. I actually understand now.
@emma.fn2 IMHO, the first thing you need to do is figure out the routing mechanism
user1596138
The values are columns of data out of rows in my sql database... But they're simply strings.
19:33
@emma.fn2 i'd say you're best off describing a simple application you want to build (like a to-do list or something) and making it work without paralyzing yourself with MVC considerations. Then, when it works, create a new version and start with MVC organization.
@JosiahSouth ok ...
@Ocramius Doesn't have particularly many BC breaks, last more or less significant one was in July last year. Apart from that there are only slight changes in the node tree structure to accomodate new PHP versions
@dyelawn ^ that would work too
@dyelawn that's exactly what I've done lol, I've made an app work and now I want to make it work in MVC instead of how I have done it xd
user1596138
I need to only display the most recent rows data... But if they're strings I'm gonna have to come up with a different way to do this aren't I. They're dated already, so now I just need to take a new approach and sort them by date.
19:34
@HamZaDzCyberDeV SO is already hopeless... When you delete the old ones, there will appear 4 new for each one...
@bwoebi lol
@JosiahSouth Edit your query
the core idea behind MVC is Separation of Concerns. If you have a solid grasp on it, you will be able to figure MVC-like design on your own
@HamZaDzCyberDeV Yes, but it is ± true...
@bwoebi well atleast we're learning some stuff :-)
user1596138
@HamZaDzCyberDeV My query is $query = "SELECT * FROM posts`";`
user1596138
19:37
How would I find the most recent timestamp in using my query??
The problem is on line 73 in your CSS — Sten Petrov 56 secs ago
user1596138
Lol I've only been using sql for about a month.
@HamZaDzCyberDeV I'd learn something if there weren't these endless little typos in queries, parse errors etc.etc.etc....
@PeeHaa埽 LOL. I like this comment^^
@dyelawn nothing... The thing is about my philosophy of programming..
@JosiahSouth You have to insert the dates in a valid format for mysql so you can sort by date in the query
@Gordon Yes I can see that is a deep wound ...
@HamZaDzCyberDeV What's the horrible performance here?
@Ihsan oh sorry, misunderstood. my brain is fried from all this typesetting.
19:40
@bwoebi null
user1596138
@HamZaDzCyberDeV I'm using date("D, M, d - g:i A");...
user1596138
I would assume that's close at least.
@HamZaDzCyberDeV Do you mean this in the latin meaning?
@bwoebi Sorry it was in another language, I though it was an english word :p
user1596138
19:41
@HamZaDzCyberDeV That's ORDER BY right?
@HamZaDzCyberDeV but thanks, I didn't know that range has three parameters...
@bwoebi That's the disadvantage of knowing to speak in 4-5 languages
You're welcome
@JosiahSouth Yeah
@MikeB If only he would spend that effort closing those question SO would be clean like never before
user1596138
@HamZaDzCyberDeV Alright... Thanks for the head start.
@JosiahSouth You're welcome
19:43
@dyelawn I always objected to data and code duality and get used to write data driven code...
@tereško are there any decent frameworks which would help with this do you know? like codeigniter seemed good but I now know it's now lol
not*
@HamZaDzCyberDeV It's horrible when I begin to mix English and French sometimes... No problems with Latin, Luxembourgish or German...
@bwoebi Tu vien d'ou ?
@bwoebi I had a fast French course... After that I could not speak at all.
(in any language I know at all)
@HamZaDzCyberDeV There's an "s" missing^^ From Luxembourg.
19:44
@PeeHaa埽 That guy is a blood bank to help vampires
@Ihsan i get that. i don't have separate Model and Entity classes, and tend to write a lot less Abstract* classes bc they seem pointless. But I will say MVC has made my projects a lot more manageable and accelerated new feature introduction.
@MikeB At least he's helping :p
@bwoebi T'aS raison :p
@HamZaDzCyberDeV And there should be some accent on the u: "où" :P
@emma.fn2 i would say that the "usable" options currently are symfony2, zend2 and laravel4. You could take a look at how they solve one or another problem, but you should not be using them until you have a good grasp of MVC itself
I'm tired to search and tik ALT+0XXX
19:45
@dyelawn MVC from my point of view is just one way. I can see millions of paths.
@dyelawn why would you have "model classes" ?
@HamZaDzCyberDeV Parlons-nous du "pseudo-"français avec trop d'apostrophes? :p
@tereško oh, I was hoping I could use one to help me learn lol
it's the other way around
Arretez sil vous plait, c'etait un Chat Anglaise (meoouuvv)
@bwoebi J'ai oublié pas mal de règles d'orthographs :p
@Ihsan Uaaah, I cannot see this horrible French...
Hmm, I'm confused what to do now then xd your answer about how a model should be structured seems ahead of what I know
@PeeHaa埽 Shouldn't you close the new one ?
@HamZaDzCyberDeV Lalala^^ From where are you coming?
19:48
@bwoebi Well I know I am terrible at this...
@HamZaDzCyberDeV Neh the new one has answers
@bwoebi I'm living in the netherlands, but I'm not 100% dutch
@Ihsan At least you know it. I've already seen some French people whose spelling was worse than yours and thought their French would be correct.
@HamZaDzCyberDeV Helping what? He's helping with no regard to the purpose of this site or its target audience
He'd be better off 'helping' over at yahoo answers
@HamZaDzCyberDeV And in there Netherlands you're taught French? :o okay...
19:50
@bwoebi NO, in Algeria :p
@tereško i don't know, something about "Domain-Driven design"
@bwoebi I should add that I was in Bordeaux which means the French they talk is somehow weirdo.
@dyelawn model is the whole thing. Usually what you call models are "domain objects"
Kardesh, that's totally normal ?
@bwoebi J'spa instead of Je ne sais pas... etc...
19:52
@tereško domain objects being entities/value objects/domain services?
@tereško i'm not saying i get the duplication of Model and Entity just saying i've seen it in a bunch of places.
@Ihsan kardesh :p
i would understand if the entities were driver specific, EDIT: but would still argue it wouldn't be the best method
@HamZaDzCyberDeV Southern accent (bordeaux french) ... kardeş
19:53
Ah I only know the prononciation of kardeS:p
yep, and lack the keyboard with ş :)
xD :true:
although I have يسنتب سبعاسعبسععسعسعب عسبعساب عأ[شعابعب شب ش
:3
@tereško that page is rather vague. how do domain objects relate to entities?
@HamZaDzCyberDeV Ya halil, do not do that ya ammar...
19:55
:D
@HamZaDzCyberDeV in php please :P
@tereško one example from a library i use often: github.com/sonata-project/SonataUserBundle see the Model/User and the Entity/BaseUser
@igorw "entities" are usually a name used to refer to logical organization in database (usually single table, but is some case group of few tables)
hahhaha xD
19:56
Even if I knew to read the elif-ba, with that font it would not be possible for me ...
ive seen so many libraries today while doing some tests doing stuff like echo("stuff"); exit();.. or echo("some error"); exit(0);... waste of commands
my objection to the duplication is purely a lazy one; i usually build schema in YAML files and generate the Entity classes from there; don't want to have to write the Model classes as well if there's little to no difference between the two.
This is too absurd for me. The mvc thing... You invent an approach and overpopulate it floodingly with many fancy words, then nobody understands what other is telling.
2
19:59
@hamza lol
MVC is like the classical story of "Tower of Babel"

« first day (919 days earlier)      last day (4254 days later) »