php-general Digest 14 Feb 2010 13:18:13 -0000 Issue 6590
Topics (messages 302077 through 302083):
Re: Report generators: experience, recommendations?
302077 by: Al
Re: optional object arguments to a function
302078 by: Jochem Maas
302079 by: Rene Veerman
302080 by: Michael A. Peters
Re: SQL insert () values (),(),(); how to get auto_increments properly?
302081 by: Rene Veerman
302082 by: Larry Garfield
Inserting Associative array values into a MySQL INSERT statement?
302083 by: Ben Stones
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
On 2/13/2010 1:56 PM, Jonathan Sachs wrote:
I'm looking for a report generator which will be used to create
management reports for my client from a MySQL database. The web site
is implemented in PHP.
Some characteristics that would be nice to have, roughly in order of
importance:
* It is moderately priced (a few hundred dollars at most) or free.
* A developer can easily learn to create moderately complex reports.
* A developer can easily add code to provide functionality not
supported by the generator.
* The generator can be installed on a shared server (it doesn't
require any unusual extensions or changes to php.ino or the server
configuration.
* A non-technical user can easily learn to create simple reports
without help.
A client-server solution is OK. The client has to run on Windows.
I've found one PHP product so far, phpreports. There are many other
reporting tools that might be suitable, but most of them seem to be
written in Java, or else they're black boxes.
Has anyone had experience with report generators that meet these
criteria? What would you recommend; what would you stay away from?
Try Source Forge.....
--- End Message ---
--- Begin Message ---
Op 2/13/10 8:59 PM, Richard Quadling schreef:
> On 13 February 2010 10:07, Jochem Maas <[email protected]> wrote:
...
>>
>
> Try stdClass.
I guess you didn't read what I wrote then.
> If you know the class type, then that can be the type hint.
>
> You can also use func_get_args() to read all the parameters and type
> check them if there are MANY optional parameters.
>
--- End Message ---
--- Begin Message ---
On Sat, Feb 13, 2010 at 9:05 AM, Michael A. Peters <[email protected]> wrote:
> How do I specify a default null object, or otherwise make the argument
> argument optional?
>
To my knowledge: can't be done.
But you can check any args through the func_get_arg*() functions, then
per-parameter push 'm through a check function that checks if their
primary properties are set.
It's equivalent to checking for null ( / bad) objects.
--- End Message ---
--- Begin Message ---
Rene Veerman wrote:
On Sat, Feb 13, 2010 at 9:05 AM, Michael A. Peters <[email protected]> wrote:
How do I specify a default null object, or otherwise make the argument
argument optional?
To my knowledge: can't be done.
But you can check any args through the func_get_arg*() functions, then
per-parameter push 'm through a check function that checks if their
primary properties are set.
It's equivalent to checking for null ( / bad) objects.
Thank you to everybody. I think I will see how far I can get with
func_get_arg - it may solve the problem.
The other hackish solution I thought of is to put the object arguments
into a key/value array and pass the array as a single argument to the
function. That way I can check for the key and if the key is set, grab
the object associated with it.
--- End Message ---
--- Begin Message ---
On Sat, Feb 13, 2010 at 3:46 PM, Joseph Thayne <[email protected]> wrote:
> In order to make this as "sql server independent" as possible, the first
> thing you need to do is not use extended inserts as that is a MySQL
> capability. If you are insistent on using the extended inserts, then look
> at the mysql_info() function. That will return the number of rows inserted,
> etc. on the last query.
>
But as previous posters had pointed out (thanks) i can't see which rows failed.
As i'm dealing with 3rd-party data, that's an issue.
I also didn't know it was mysql-specific, that multi-insert..
And i tried looking up the sql-standard docs, only to find that they
cost over 200 euro per
part (14 parts).
I've sent angry emails to ansi.org and iso.org (commercial lamers
operating under .org, yuck), about how cool a business model that
charges a percentage of profits per implementation would be, instead
of charging high prices up-front for a potentially bad/complicated
piece of spec.
But back to the problem at hand; it looks like i'll have to forget
about using 100s of threads for my newsscraper at the same time, and
settle for a few dozen instead.
Then i can just do single inserts (per hit) and retrieve the last_insert_id().
One question remains: it is probably not (concurrently-)safe to do a
sql-insert from php and then a last_insert_id() also from php..?
I still have to build a stored procedure to do-the-inserting and
return the last_insert_id()?
--- End Message ---
--- Begin Message ---
On Sunday 14 February 2010 03:15:16 am Rene Veerman wrote:
> On Sat, Feb 13, 2010 at 3:46 PM, Joseph Thayne <[email protected]>
wrote:
> > In order to make this as "sql server independent" as possible, the first
> > thing you need to do is not use extended inserts as that is a MySQL
> > capability. If you are insistent on using the extended inserts, then
> > look at the mysql_info() function. That will return the number of rows
> > inserted, etc. on the last query.
>
> But as previous posters had pointed out (thanks) i can't see which rows
> failed. As i'm dealing with 3rd-party data, that's an issue.
>
> I also didn't know it was mysql-specific, that multi-insert..
>
> And i tried looking up the sql-standard docs, only to find that they
> cost over 200 euro per
> part (14 parts).
> I've sent angry emails to ansi.org and iso.org (commercial lamers
> operating under .org, yuck), about how cool a business model that
> charges a percentage of profits per implementation would be, instead
> of charging high prices up-front for a potentially bad/complicated
> piece of spec.
>
> But back to the problem at hand; it looks like i'll have to forget
> about using 100s of threads for my newsscraper at the same time, and
> settle for a few dozen instead.
> Then i can just do single inserts (per hit) and retrieve the
> last_insert_id().
>
> One question remains: it is probably not (concurrently-)safe to do a
> sql-insert from php and then a last_insert_id() also from php..?
> I still have to build a stored procedure to do-the-inserting and
> return the last_insert_id()?
That's perfectly safe to do as long as it's within the same PHP request.
(Well, the same DB connection, really, which is 99% of the time the same
thing.) last_insert_id() is connection-specific.
I believe (it's been a while since I checked) the MySQL documentation says
that last_insert_id() with a multi-insert statement is not reliable and you
shouldn't rely on it having a worthwhile meaning anyway. Or at least it said
something that made me conclude that it's safest to assume it's unreliable for
a multi-insert statement.
If you're concerned about performance of that many bulk writes, there's 3
things you can do to help:
1) Use InnoDB. It uses row-level locking so lots of writes doesn't lock your
whole table as in MyISAM tables.
2) Disable indexes on the table in question before running your bulk insert,
then re-enable them. That's considerably faster than rebuilding the index
after each and every insert as they only need to be rebuilt once.
3) If you're on InnoDB, using transactions can sometimes give you a
performance boost because the writes hit disk all at once when you commit.
There may be other side effects and trade offs here, though, so take with a
grain of salt.
--Larry Garfield
--- End Message ---
--- Begin Message ---
Hi,
I want to be able to create a function that acts as an insert mysql function
that accepts specific parameters for the fields and the values I want to
insert into those respective fields and I know I'll need to use associative
arrays to complete this task when passing values to the function, but I'm
not sure how to pass multiple values in an array through an insert
statement? Any help greatly appreciated!
Thanks.
--- End Message ---