Re: [fw-general] Escape, stripslashes and html entities

2010-02-25 Thread troels knak-nielsen
On Wed, Feb 24, 2010 at 10:03 PM, Jurian Sluiman
 wrote:
>
> So actually it isn't the data *retrieval* but rather the *insertion* if I
> understand you right? The things I do are 99% from the manual:

Yes.

> After calling the method the strings are in the database like I said (so
> _with_ quotes). What's are the things I can look after (php settings, mysql
> settings, system settings) to solve this problem?
>

Magic quotes is an ini setting. It's by far the most plausible
explanation for your symptoms. Note that this kind of problem is a bit
tricky to deal with, because it happens on write-time. So even if you
correct the cause of the problem, you also need to go back and
manually fix the corrupted data.

-- 
troels


Re: [fw-general] Escape, stripslashes and html entities

2010-02-21 Thread troels knak-nielsen
On Sat, Feb 20, 2010 at 9:51 AM, Jurian Sluiman
 wrote:
> Enter this data:
>> Hello my name is Jurian. I'm a Zend Framework user
>
> This means my data is stored into the database like this (checked with
> phpmyadmin:
>> Hello my name is Jurian. I\'m a Zend Framework user

If that's the case, then you have double escaping going on. The data
should not contain the slash once it's in the database. The point of
adding the slash is to "protect" the data when it's embedded in *the
query*. That is also why you don't have to (and indeed should not)
unescape anything when reading from the database. The slashes are
*only* there because you're embedding data in a query.

Compare this with a string literal in php. Given the following:

echo "A \"double\" quote";

Running this php code will output:

A "double" quote

That's because the *data* doesn't contain any slashes. The slashes are
there so that the php parser can read the literal string. Once they
have been read into memory, the slashes are gone. Same thing with sql.

-- 
troels


Re: [fw-general] Broken link to CI server

2009-09-28 Thread troels knak-nielsen
On Mon, Sep 28, 2009 at 9:34 PM, Matthew Weier O'Phinney
 wrote:
> -- troels knak-nielsen  wrote
> (on Monday, 28 September 2009, 12:59 PM +0200):
>> http://framework.zend.com/build/ doesn't work.
>
> It's not supposed to. We're not exposing it publically currently.
>

Maybe you should remove the links then?

For example, here:

http://framework.zend.com/community/resources

--
troels


[fw-general] Broken link to CI server

2009-09-28 Thread troels knak-nielsen
http://framework.zend.com/build/ doesn't work.

--
troels


Re: [fw-general] Zend_Db_Table with multiple databases

2009-09-17 Thread troels knak-nielsen
Thanks - That was useful indeed.

--
troels

On Wed, Sep 16, 2009 at 11:46 PM, Paul M Jones  wrote:
>
> On Sep 16, 2009, at 14:02 , troels knak-nielsen wrote:
>
>> Hi.
>>
>> I'm looking into replacing a legacy system with Zend_Db + subpackages
>> (Zend_Db_Table and friends), but I'm running into some problems. The
>> setup we have is a master/slave. For offloading the main server all
>> read queries are channelled to the slave, while all write queries are
>> sent to the main server. The current library supports this by allowing
>> each method to fetch the appropriate link. From what I can see, there
>> is no direct support for such a thing in Zend_db_Table, but I can see
>> a couple of possible flex points in the framework.
>>
>> Before I start off a tangent myself, I was wondering if anybody else
>> have tried something like this?
>
> Hi Troels,
>
> You may find this earlier thread useful:
>
>  http://www.nabble.com/Best-practice-for-Master-Slave-Db-w--ZF--td24179039.html
>
> In particular there is this bit about Solar, which obviously is not Zend
> Framework but may provide useful hints.
>
>  http://www.nabble.com/Re%3A-Best-practice-for-Master-Slave-Db-w--ZF--p24204672.html
>
>> 
>>
>> This is as opposed to Solar's MysqlReplicated adapter, the SVN trunk
>> version of which works automatically.  Yes, it examines the first few
>> characters of the SQL statement to determine whether it should pick a
>> master or a slave, which is not exactly a big performance drain.  It
>> also manages GET-after-POST situations, so that if you insert or
>> update on one request, the very next request *also* uses the master
>> (even for reads), to allow time for data propagation to slaves.
>> Finally, you can switch back and forth between replicated and non-
>> replicated environments without changing your application code.
>>
>> See more here:
>>
>>   http://solarphp.com/blog/read/19-adapter-for-master-slave-my-sql-setups
>>
>> 
>
>
>
>
>
>
> --
>
> Paul M. Jones
> http://paul-m-jones.com/
>
>
>
>
>


[fw-general] Zend_Db_Table with multiple databases

2009-09-16 Thread troels knak-nielsen
Hi.

I'm looking into replacing a legacy system with Zend_Db + subpackages
(Zend_Db_Table and friends), but I'm running into some problems. The
setup we have is a master/slave. For offloading the main server all
read queries are channelled to the slave, while all write queries are
sent to the main server. The current library supports this by allowing
each method to fetch the appropriate link. From what I can see, there
is no direct support for such a thing in Zend_db_Table, but I can see
a couple of possible flex points in the framework.

Before I start off a tangent myself, I was wondering if anybody else
have tried something like this?

If not, would ZF be willing to accept patches?

Thanks.

--
troels


Re: [fw-general] Models as Singletons

2009-07-24 Thread troels knak-nielsen
On Thu, Jul 23, 2009 at 11:22 PM, Ed
Lazor wrote:
> I realize some people are saying that Singletons should never be used.
>  If that's the case, why are they used in Zend Framework?   For
> example, Zend_Auth, Zend_Registry, Zend_Loader_Autoloader, and
> Zend_Controller_Front.  Aren't these good examples of where Singletons
> are beneficial?

It's a trade off between two types of complexity; coupling on one hand
and abstraction on the other hand. You don't want coupling, because it
makes it hard to reason about your program, but you don't want too
much abstraction either. What is "too much" depends a whole lot on the
individual programmer, so it can be tricky to pick an appropriate
level.

There's a certain class of problems where a global symbol doesn't
hurt. This is in places where the language imposes global effects in
any case. For example, PHP doesn't allow redefining classes, so
therefore the autoloader is inherently global in any case. It's not
that a global doesn't add coupling here - it's just that the language
designers have already made the choice for you.

Everything else is a judgement call.

> How do you know when it's ok to use Singletons?  It seems like
> Singletons are beneficial, when used to share a single resource,
> because they have the potential for improving performance, and
> reducing application complexity.
> ...
> That way, instead of reinstantiating an instance of Users all over the
> application, you call getInstance and re-use the same object as often
> as you'd like - giving the 7X performance boost Michael was
> mentioning.

Now you're mixing apples and oranges again. Global symbols do not
improve performance. Shared resources improve performance. Globals are
just one way to share resources, but it's not the only one.

--
troels


Re: [fw-general] Models as Singletons

2009-07-21 Thread troels knak-nielsen
On Tue, Jul 21, 2009 at 8:03 PM, Ed Lazor wrote:
> On Tue, Jul 21, 2009 at 10:48 AM, troels knak-nielsen 
> wrote:
>> Irey wrote:
>>> That's a performance boost of 7X using a singleton versus not using a
>>> singleton.
>>
>> You're conflating two unrelated concepts.  The performance difference
>> that you observe is due to the difference between instantiating a new
>> object per iteration vs. reusing the same.
>
> Isn't that one of the benefits of using a singleton?

Yes, that's one of them. A big problem with singleton is that it does
two things. One one hand, it ensures a single instance in the
application, and on the other hand it provides a means to share this
instance. Those two things do not need to be coupled together.

>> You can reuse the same object in other ways than through a global symbol.
>
> Aren't singleton classes preferred over global variables?

Most people would say that, yes. And I agree, but I would really
prefer neither. Global variables and singletons and static methods and
static variables all share a similarity in that they are globally
scoped symbols. That makes all of them suspect.

--
troels


Re: [fw-general] Models as Singletons

2009-07-21 Thread troels knak-nielsen
On Tue, Jul 21, 2009 at 7:43 PM, Michael
Irey wrote:
> That's a performance boost of 7X using a singleton versus not using a
> singleton.

You're conflating two unrelated concepts. The performance difference
that you observe is due to the difference between instantiating a new
object per iteration vs. reusing the same. You can reuse the same
object in other ways than through a global symbol.

--
troels


Re: [fw-general] Models as Singletons

2009-07-21 Thread troels knak-nielsen
On Tue, Jul 21, 2009 at 1:52 PM, Marko
Korhonen wrote:
> - Is there performance gain or memory savings or something like that?

On the contrary. A singleton prevents the garbage collector from functioning.

> - Code syntax benefits?

That's rather subjective.

> - Something else?

Low level of abstraction means easy to understand. This is the only
benefit of a singleton. While it's real, it usually doesn't make up
for the high level of coupling it incurs. Ultimately it's a judgement
call, but most experienced programmers wouldn't use them in this
scenario (or at all).

> Only thing I really understand that it gets always the same instance of the
> class
> and does not create new ones.

If you don't fully understand the implications of singletons, you
should probably avoid them like the plague. If you *do* understand the
implications of singletons you *will* avoid them like the plague.

--
troels


Re: [fw-general] Re: How to contact the Zend Framework team about OOP bad practices/suggestions?

2009-02-12 Thread troels knak-nielsen
On Thu, Feb 12, 2009 at 2:25 PM, Matthew Weier O'Phinney
 wrote:
> Most issues that suggest changes merely for the sake of OO purity will
> be ignored in favor of _real_ issues/feature requests. There's simply
> very little, if any, benefit to investing the time to make the changes
> in most cases.

So good design is not a priority?

Sorry for the trolling, but really ...

--
troels


Re: [fw-general] Unit testing utf8 characters

2008-12-11 Thread troels knak-nielsen
On Thu, Dec 11, 2008 at 3:26 PM, Josh Lebal <[EMAIL PROTECTED]> wrote:
> Well, I checked the thing works like a charm manually so I thought maybe it
> was a unit test problem.

Which encoding are you saving the source-file in? If you save it as
UTF-8, then those characters will be utf-8 encoded. If you save it as
iso-8859-1, then those characters will be iso-8859-1 encoded.

--
troels


Re: [fw-general] Zend_PDF and Barcode

2008-03-14 Thread troels knak-nielsen
Not sure how Zend_PDF works, but drawing barcodes, can be done using a
special font. Each number is the rendered as a different sequence of
bars.

--
troels

On Fri, Mar 14, 2008 at 2:44 PM, Steven Brown <[EMAIL PROTECTED]> wrote:
> I imagine it would be something like drawing the lines yourself and setting
>  the line width etc...?
>
>
>
>  -Original Message-
>  From: billyildirim [mailto:[EMAIL PROTECTED]
>  Sent: Friday, 14 March 2008 10:11 PM
>  To: fw-general@lists.zend.com
>  Subject: [fw-general] Zend_PDF and Barcode
>
>
>  Hi there,
>  I am pretty sure it is possible to put Barcode in PDF file using Zend_Pdf
>  but I couldn't find any information about that.
>  Can someone show me any tutorial about it?
>
>  Thanks
>  B
>  --
>  View this message in context:
>  http://www.nabble.com/Zend_PDF-and-Barcode-tp16048071s16154p16048071.html
>  Sent from the Zend Framework mailing list archive at Nabble.com.
>
>
>
>



-- 
troels


Re: [fw-general] Zend_Lucene_Search for PDFs

2007-11-01 Thread troels knak-nielsen
Have you tried these:

http://linux.die.net/man/1/pdftotext
http://pdftohtml.sourceforge.net/

--
troels